At-New using ALV  Function Modules

Hi,
Could anyone post how to handle control break command 'AT NEW' in ALV Reports using Function Modules.

Hi Amit,
you've posted the question asked by me in another thread, Also one is related to oops and the other is related to Function modules. For my issue I have know about both of them.
Waiting for ur reply in form of solution.
Thanks,
G Sandeep Kumar.

Similar Messages

  • How to use the alv function module

    hi all,
            can  any one help me out how to use reuse_alv_block_list_append function module, what parameters shall i pass  to it, so that i get top of page and end of page events and report data in two blocks, can any one tell how can i didvide the data into block, at a particular line

    hi,
    this is  my simple alv blockedlist programme.go through it.it will definrtley help u.
    REPORT  z50870alv_blocked.
    TYPE-POOLS : slis.
    *&      structure declaration
    TYPES : BEGIN OF st_ekko,
              ebeln TYPE ekko-ebeln,    "Purchasing Document Number
              bstyp TYPE ekko-bstyp,    "Purchasing Document Category
              bsart TYPE ekko-bsart,    "Purchasing Document Type
              aedat TYPE ekko-aedat,    "record created on
              ernam TYPE ekko-ernam,    "Person who Created the Object
            END OF st_ekko.
    TYPES : BEGIN OF st_ekpo,
              ebeln TYPE ekko-ebeln,
              ebelp TYPE ekpo-ebelp,    "Item Number of Purchasing Document
              ematn TYPE ekpo-ematn,    "Material number
              matkl TYPE ekpo-matkl,    "Material group
              netpr TYPE ekpo-netpr,    "Net price in purchasing document
            END OF st_ekpo.
    *&      internal table and work area declaration
    DATA : it_ekpo       TYPE STANDARD TABLE OF st_ekpo,
           it_ekko       TYPE STANDARD TABLE OF st_ekko,
           it_fieldcat1  TYPE slis_t_fieldcat_alv,
           wa_fieldcat1  TYPE slis_fieldcat_alv,
           it_fieldcat2  TYPE slis_t_fieldcat_alv,
           wa_fieldcat2  TYPE slis_fieldcat_alv,
           it_events     Type slis_t_event,
           wa_layout     TYPE slis_layout_alv.
    *&      data declaration
    DATA : v_ebeln TYPE ekko-ebeln.
    *&      selection-screen
      SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-000.
      SELECT-OPTIONS : so_ebeln FOR v_ebeln.
      SELECTION-SCREEN END OF BLOCK a.
    *&      At-selection-screen
    at selection-screen on so_ebeln.
    perform validate_ebeln.
    *&      start-of-selection
    START-OF-SELECTION.
      PERFORM data_retrieval.
    *&      end-of-selection
    END-OF-SELECTION.
      PERFORM initialize_alv_block.
      PERFORM build_fieldcatalog1.
      PERFORM build_fieldcatalog2.
      PERFORM build_layout.
      PERFORM get_events .
      PERFORM append_ekkodata_to_alv_block.
      PERFORM append_ekpodata_to_alv_block.
      PERFORM display_blocked_alv.
    *&     FORM initialize_alv_block
    FORM initialize_alv_block.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
      EXPORTING
        i_callback_program             = sy-repid.
    endform.
    *&     FORM validate_ebeln
    form validate_ebeln.
    select ebeln
       from ekko
       into table it_ekko
       where ebeln in so_ebeln.
      if sy-subrc ne 0.
        message text-003 type 'W'.
      endif.
    endform.
    *&     FORM data_retrieval
    FORM data_retrieval.
    SELECT ebeln bstyp bsart aedat ernam
        FROM ekko
        INTO TABLE it_ekko
        WHERE ebeln IN so_ebeln.
      if sy-subrc ne 0.
       message text-001 type 'I'.
      endif.
    SELECT ebeln ebelp ematn matkl netpr
        FROM ekpo
        INTO TABLE it_ekpo
        WHERE ebeln IN so_ebeln.
      if sy-subrc ne 0.
       message text-002 type 'I'.
      endif.
    endform.
    *&      Form  build_fieldcatalog1
    FORM  build_fieldcatalog1.
      wa_fieldcat1-fieldname   = 'EBELN'.
      wa_fieldcat1-seltext_l   = 'PURCHASE ORDER'.
      wa_fieldcat1-col_pos     = 0.
      APPEND wa_fieldcat1 TO it_fieldcat1.
      wa_fieldcat1-fieldname   = 'BSTYP'.
      wa_fieldcat1-seltext_l   = 'DOCUMENT CATEGORY'.
      wa_fieldcat1-col_pos     = 1.
      APPEND wa_fieldcat1 TO it_fieldcat1.
      wa_fieldcat1-fieldname   = 'BSART'.
      wa_fieldcat1-seltext_l   = 'DOCUMENT TYPE'.
      wa_fieldcat1-col_pos     = 2.
      APPEND wa_fieldcat1 TO it_fieldcat1.
      wa_fieldcat1-fieldname   = 'AEDAT'.
      wa_fieldcat1-seltext_l   = 'DATE'.
      wa_fieldcat1-col_pos     = 3.
      APPEND wa_fieldcat1 TO it_fieldcat1.
      wa_fieldcat1-fieldname   = 'ERNAM'.
      wa_fieldcat1-seltext_l   = 'NAME'.
      wa_fieldcat1-col_pos     = 4.
      APPEND wa_fieldcat1 TO it_fieldcat1.
    ENDFORM.                    "build_fieldcatalog
    *&      Form  build_fieldcatalog2
    FORM  build_fieldcatalog2.
      wa_fieldcat2-fieldname   = 'EBELN'.
      wa_fieldcat2-seltext_l   = 'PURCHASE ORDER'.
      wa_fieldcat2-col_pos     = 0.
      APPEND wa_fieldcat2 TO it_fieldcat2.
      wa_fieldcat2-fieldname   = 'EBELP'.
      wa_fieldcat2-seltext_l   = 'ITEM NUMBER'.
      wa_fieldcat2-col_pos     = 1.
      APPEND wa_fieldcat2 TO it_fieldcat2.
      wa_fieldcat2-fieldname   = 'EMATN'.
      wa_fieldcat2-seltext_l   = 'MATERIAL TYPE'.
      wa_fieldcat2-col_pos     = 2.
      APPEND wa_fieldcat2 TO it_fieldcat2.
      wa_fieldcat2-fieldname   = 'MATKL'.
      wa_fieldcat2-seltext_l   = 'MATERIAL GROUP'.
      wa_fieldcat2-col_pos     = 3.
      APPEND wa_fieldcat2 TO it_fieldcat2.
      wa_fieldcat2-fieldname   = 'NETPR'.
      wa_fieldcat2-seltext_l   = 'NET PRICE'.
      wa_fieldcat2-col_pos     = 4.
      wa_fieldcat2-do_sum      = 'X'.
      APPEND wa_fieldcat2 TO it_fieldcat2.
    ENDFORM.                    "build_fieldcatalog
    *&      form build_layout.
    FORM build_layout.
      wa_layout-zebra ='X'.
      wa_layout-no_vline = 'X'.
      wa_layout-no_hline = 'X'.
      wa_layout-colwidth_optimize = 'X'.
      wa_layout-window_titlebar = 'PURCHASE ORDER HEADER AND ITEM DETAILS'.
    ENDFORM.                    "build_layout
    *&      form append_ekkodata_to_alv_block
    FORM append_ekkodata_to_alv_block.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        is_layout                        = wa_layout
        it_fieldcat                      = it_fieldcat1
        i_tabname                        ='it_ekko'
        it_events                        = it_events[]
      IT_SORT                          = IT_SORT
      I_TEXT                           = ' '
      TABLES
        t_outtab                         = it_ekko
    EXCEPTIONS
       PROGRAM_ERROR                    = 1
       MAXIMUM_OF_APPENDS_REACHED       = 2
       OTHERS                           = 3.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    endform.
    *&      form append_ekpodata_to_alv_block
    FORM append_ekpodata_to_alv_block.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        is_layout                        = wa_layout
        it_fieldcat                      = it_fieldcat2
        i_tabname                        ='it_ekpo'
        it_events                        = it_events[]
      IT_SORT                          = IT_SORT
      I_TEXT                           = ' '
      TABLES
        t_outtab                         = it_ekpo
    EXCEPTIONS
       PROGRAM_ERROR                    = 1
       MAXIMUM_OF_APPENDS_REACHED       = 2
       OTHERS                           = 3.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    endform.
    *&      FORM display_blocked_alv.
    FORM display_blocked_alv.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
    endform.
    *&      Form  GET_EVENTS
    FORM get_events .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 2
        IMPORTING
          et_events       = it_events[]
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " GET_EVENTS\
    regards,
    pavan t.

  • How to EDIT a particular Row in ALV using normal function module Reuse_alv_grid_display

    Hi experts..
    i got one requirement like i need to edit some rows particularly in alv....
    Edit in alv output....is it possible to get  that .....using normal function module with out using oops concept...
    could any one pls help me...

    Hi Pendurti ,
    If you want a particular field to be editable , simply define the fieldcatalog as
    wa_fieldcatalog-edit          = 'X'.
    wa_fieldcatalog-input         = 'X'.
    for that field.
    and
    Now when you use FM ' Reuse alv grid display '
    define USER_COMMAND
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = v_repid
          i_callback_pf_status_set = 'SET_PF_STATUS'
          i_callback_user_command  = 'USER_COMMAND'
          it_fieldcat              = int_fieldcatalog
          is_layout                = wa_layout
        TABLES
          t_outtab                 = t_disp.
    and now in form USER_COMMAND ; code as per following
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                                rs_selfield TYPE slis_selfield.
         DATA ref1 TYPE REF TO cl_gui_alv_grid.
         CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
           IMPORTING
             e_grid = ref1.
         CALL METHOD ref1->check_changed_data.
    endform.
    Regards,
    Yogendra Bhaskar

  • ALV function module usages in report

    Hi All,
    I am writing an ALV report and would like to know whether the following function modules can add some value for my report. The report displays in Grid format using ALV_GRID_DISPLAY.
    REUSE_ALV_EVENTS_GET
    REUSE_ALV_COMMENTARY_WRITE
    REUSE_ALV_VARIANT_F4
    REUSE_ALV_VARIANT_EXISTENCE
    REUSE_ALV_VARIANT_DEFAULT_GET
    I got some example programs for this from the forum but did not quite understand the need of this. So please explain in a simple way how to use this in reports.
    Thanks
    Ricky

    Hi,
    SAP provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to beautify the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in SAP when the output of a report contains columns extending more than 255 characters in length.  In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain upto 90 columns in the display with the wide array of display options.
    The commonly used ALV functions used for this purpose are;
    1.     REUSE_ALV_VARIANT_DEFAULT_GET
    2.     REUSE_ALV_VARIANT_F4
    3.     REUSE_ALV_VARIANT_EXISTENCE
    4.     REUSE_ALV_EVENTS_GET
    5.     REUSE_ALV_COMMENTARY_WRITE
    6.   REUSE_ALV_FIELDCATALOG_MERGE
    7.   REUSE_ALV_LIST_DISPLAY
    8.     REUSE_ALV_GRID_DISPLAY
    9.     REUSE_ALV_POPUP_TO_SELECT
    The different steps used for getting the above function modules into use are :
    Step 1
    DATA DECLARATION
    Sap standard type pools: SLIS, KKBLO.
    Sap standard tables types taken from the type pools are:  SLIS_LAYOUT_ALV,
                                             SLIS_T_FIELDCAT_ALV,
    SLIS_T_LISTHEADER,
    SLIS_T_EVENT,
    SLIS_SELFIELD.
    Internal tables to used in the program declared based on the above table types
    DATA:  I_LAYOUT TYPE SLIS_LAYOUT_ALV,
                I_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
               I_HEADING TYPE SLIS_T_LISTHEADER,
    I_EVENTS TYPE SLIS_T_EVENT.
    TYPES:  KKBLO_SELFIELD TYPE SLIS_SELFIELD.
    Step 2 (Optional)
    SELECTING THE VARIANTS FOR INITIAL LIST DISPLAY (DEFAULT VARIANT)
    The variants in the list display can be both user-specific and general. The user can programmatically set the initial (default) variant for list display.
    The default variant can be found using the function module 'REUSE_ALV_VARIANT_DEFAULT_GET'.
    Sample code:
    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                i_save     = variant save condition ( A=all, U = user-specific )
           CHANGING
                cs_variant = internal table containing the program name (and the default variant---optional )
           EXCEPTIONS
                not_found  = 2.
    The user can also choose from the list of existing variants using the function module ‘REUSE_ALV_VARIANT_F4’.
    Step 3
    DEFININING OUTPUT CHARACTERISTICS: PREPARING DISPLAY FIELDS CATALOG
    A field catalog is prepared using the internal table (I_FIELDCAT) of type SLIS_T_FIELDCAT_ALV. Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields).
    A field catalog is required for every ALV list output to add desired functionality (i.e. Key, Hotspot, Specific headings, Justify, Col. position etc) to certain fields of the output. If not mentioned specifically, then the defaults are taken. The possible values and defaults are listed below.
    The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module.
    The minimal field catalog is documented below. This can be done in a routine using a local variable. The user can use the other optional parameters to assign output attributes to different fields in the output, which differ from the default.
    A field catalog need not be built-up and passed explicitly only under the following conditions:
    1.     The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE. In this case the attributes of the different fields is taken directly from the table and the attributes (key fields, length, texts etc) need to state explicitly.
    2.     all fields in this structure are to be output
    3.     The structure name is passed to ALV in the parameter I_STRUCTURE_NAME of the function module REUSE_ALV_LIST_DISPLAY.
    All the values entered in the catalog are specific to the particular field whose name is entered in the fieldname FIELDNAME of the fieldcat structure. The name of the table is also entered in the corr. Fieldname TABNAME of the structure.
    The different possible attributes are:
    •     Row_pos (row position): Only relevant if the list output is to be multi-line (two or three lines) by default. So, this attribute can be used maintain certain level of alignment in the output.
                         Value set: 0, 1 – 3
    •     Col_pos (column position): This parameter is relevant when the fields in the output are to be different from the sequence of the fields in the internal table used for display.       The parameter specifies the relative column position of the field in the list output. The column order can be changed interactively by the user. If this parameter is initial for all field catalog entries, columns appear in the internal table field sequence.
    Value set: 0, 1 – 60
    •     Fieldname (field name): This is the name of the internal table field for which the parameters are passed in the catalog.
    Value set: internal output table field name (required parameter)
    •     Tabname (internal output table): Name of the internal output table that contains the field FIELDCAT-FIELDNAME above.
                         Value set: SPACE, internal output table name.
    •     Ref_fieldname (reference field name): Name of the Data Dictionary field referred to. This parameter is only used when the internal output table field described by the current field catalog entry has a reference to the Data Dictionary (not a program field), and the field name in the internal output table is different from the name of the field in the        Data Dictionary. If the field names are identical, naming the Data Dictionary structure or table in the FIELDCAT-REF_TABNAME parameter is sufficient.
        Value set: SPACE, Data Dictionary field name.
    •     Ref_tabname (reference table/structure field name): Structure or table name of the referred Data Dictionary field.        This parameter is only used when the internal output table field described by the current field catalog entry has a Data Dictionary reference (not a program field).
    Value set: SPACE, name of a Data Dictionary structure or table
    Link to currency unit
    •     Cfieldname (currency unit field name): This is used for currency fields that have a reference to any unit field. This is only relevant for amount columns with associated unit. This parameter contains the Name of the internal output table field containing the currency unit associated with the amount field FIELDCAT-FIELDNAME. The field in FIELDCAT-CFIELDNAME must have its own field catalog entry.
    Value set: SPACE, output table field name
    •     Ctabname (internal currency unit field output table): Name of the internal output table containing the FIELDCAT-CFIELDNAME field.
    Value set: SPACE, output table field name.
            Link to measurement unit
    •     Qfieldname (measurement unit field name): Only relevant for quantity columns with unit link. Name of the internal output table field containing the measurement unit associated with the quantity field FIELDCAT-FIELDNAME. The field in FIELDCAT-QFIELDNAME must have its own field catalog entry.
    Value set: SPACE, output table field name.
    •     Qtabname (internal measurement unit field output table): Name of the internal output table containing the FIELDCAT-QFIELDNAME field.
    Value set: SPACE, output table field name.
    •     Outputlen (column width): This parameter is used if the desired output length for a field is desired to be different from the internal output table field. For fields with a Data Dictionary link this parameter can be left initial. For fields without a Data Dictionary link (program field) the parameter must be given the value of the desired field list output length (column width).
    Initial = column width is the output length of the referred Data Dictionary field (domain).
    N = column width is n characters.
          Value set: 0 (initial), n.
    •     Key (key column): By default, the system makes some fields in the output as key fields, provided the fields are key fields in their referencing table. Using this parameter, fields other than key fields of the referencing table can be made key field. This parameter is most important if the output needs to contain some field which are not scrollable or cannot be hidden.
    If the internal output table contains fields that are key fields from different tables, then all those fields in the report output becomes unscrollable and cannot be hidden. So, the fields in the output internal table should not be referenced from tables in which they are key fields. Instead, they should be referenced to the tables in which they are not key fields, incase they are not desired as key field in the output.
    'X' = key field (key field output in color) and Key fields can not be interactively hidden. Parameter FIELDCAT-NO_OUT must be left initial.
          Value set: SPACE, 'X'.
    •     Key_sel (hideable key column): This parameter is only relevant for the fields which are made key fields using FIELDCAT-KEY = 'X'. Using this parameter the Key field can be hidden interactively.
    The key column sequence cannot be changed interactively by the user. The output is controlled by the FIELDCAT-NO_OUT parameter analogously to non-key fields.
    Value set: SPACE, 'X'.
    •     No_out (field in field list): This parameter is used to remove certain fields from the output during initial display.  The user can however interactively choose the field for output from the field list in the display variant.
                'X' = field is not displayed in the current list.
            Value set: SPACE, 'X'.
    •     Tech (technical field): This parameter is used to make certain field display only in the field catalog. The fields with this parameter set cannot be output in the list nor can they be displayed interactively from the catalog.
                        'X' = technical field.
           Value set: SPACE, 'X'.
    •     Emphasize (highlight columns in color): As name suggests, this field parameter is used to highlight certain field with chosen colors.
    Value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off ,'1'=on).
    'X' = column is colored with the default column highlight color.
                        'Cxyz' = column is colored with a coded color:
                      -  C: Color (coding must begin with C)
                     -  X: color number
                      -  Y: bold
                       -  Z: inverse
    •     Hotspot (column as hotspot): This parameter is used to make certain field appear as hotspot i.e. a hand is displayed if the cursor is positioned on the field value. Single click on such fields cause the PICK OR F2 events to happen.
             Value set: SPACE, 'X'.
                        'X' = column cells are output as hotspots.
    •     Fix_column (fix column): This parameter is used to fix certain columns in the output. All columns to be fixed must have this flag, starting from the left. If a column without this flag is output, only the columns to the left of this column are fixed. The user can change the column fixing interactively.
                         Value set: SPACE, 'X'.
            'X' = column fixed (does not scroll horizontally).
    •     Do_sum (sum over column): the user can also call this function interactively.
                      Value set: SPACE, 'X'.
    'X' = a sum is calculated over this internal output table field.
    •     No_sum (sums forbidden): No sum can be calculated over this field, although the data type of the field would allow summing.
             Value set: SPACE, 'X'.
    •     Icon: The parameter displays certain column contents as icons. The internal output table column contents must be valid icon strings.
                        Value set: SPACE, 'X'.
                         'X' = column contents to be output as an icon.
    •     Symbol: The internal output table column must be a valid symbol character.
    Value set: SPACE, 'X'
                        'X' = column contents are to be output as a symbol.
    •     Just (justification): This parameter is used for alignment of the contents of the output table. This is only relevant for CHAR or NUMC fields in the output internal table. The justification of the column header always follows the justification of the columns. Independent justification of the column header is not possible.
    Value set: SPACE, 'R', 'L', and ‘C’.
           ' ' = Default justification for this data type
           'R' = right-justified output
           'L' = left-justified output
           'C' = centered output.
    •     Lzero (leading zeros): By default ALV outputs NUMC fields right-justified without leading zeros. Using this parameter only the NUMC fields can be displayed with leading zeroes.
                       Value set: SPACE, 'X'.
                        'X' = output with leading zeros.
    •     No_sign (no +/- sign): This parameter is used to suppress the signs of the output fields. It is only relevant for the value fields.
        Value set: SPACE, 'X'.
               'X' = value output without +/ sign.
    •     No_zero (suppress zeros): Only relevant for value fields.
                 Value set: SPACE, 'X'.
                        'X' = suppress zeros.
    •     Edit_mask (field formatting): To apply the report output formatting options same as in the WRITE statement in report writing.
               Value set: SPACE, template.
    The following parameters are used for customizing the texts in the heading of the output of the columns. The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are then ignored.
    If the user changes the column width interactively, the column header text with the appropriate length is always used.
    The interactive function 'Optimize column width' takes account of both the field contents and the column headers: if all field contents are shorter than the shortest column header, the column width depends on the column header.
         The 'long field label' is also used in display variant definition,
            Sort, etc.  Popup.
    •     seltext_l (long field label)
    •     seltext_m (medium field label)
    •     seltext_s (short field label)
    •     reptext_ddic(header) Analogous to the Data element main header
    •     Ddictxt (specify text) : You can specify with values 'L', 'M',  and 'S', the keyword that should always be used as column header. If the column width changes, no attempt is made in this case to find an appropriate header for the new output width.
    Value set: SPACE, 'L', 'M', and ‘S’.
    Sample code:
    Suppose I_PO_DETAILS is an internal table containing two fields EBELN (PO number) and EBELP (PO item no).
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.     “Local variable to hold the parameters                                                                               
    for a particular field of the field catalog
      CLEAR L_FIELDCAT.
      L_FIELDCAT-TABNAME   = 'I_PO_DETAILS'.
      L_FIELDCAT-FIELDNAME = 'EBELN'.
      L_FIELDCAT-KEY = 'X'.         “The PO no is made the key field,
                          “Colored and non scrollable
      L_FIELDCAT-HOTSPOT = 'X'.     “The po no becomes a hotspot
      L_FIELDCAT-SELTEXT_S = ‘P.O No’.
      L_FIELDCAT-SELTEXT_M = 'P order No'.
      L_FIELDCAT-SELTEXT_L = 'Purchase order No'.
      APPEND L_FIELDCAT TO I_FIELDTAB.
      CLEAR L_FIELDCAT
      L_FIELDCAT-TABNAME   = 'I_PO_DETAILS'.
      L_FIELDCAT-FIELDNAME = 'EBELN'.
      L_FIELDCAT-KEY = 'X'.         “The po item no is made the key field,
                          “Colored and non scrollable
      L_FIELDCAT-SELTEXT_S = 'Item No'.
      L_FIELDCAT-SELTEXT_M = 'Item No`.
      L_FIELDCAT-SELTEXT_L = 'PO Item No'.
      APPEND L_FIELDCAT TO I_FIELDTAB.
      CLEAR L_FIELDCAT
    Thus the catalog for the report output is prepared.
    Step 4
    The next step is to build an event table, which are used for firing both user commands and the system dependent events i.e. top of page, end of page etc.
    A list of possible events is populated into an event table (I_EVENTS) when this table is passed to the function module REUSE_ALV_EVENT_NAMES_GET. The return table from this function module contains all the possible events.
    The function module contains following import and export parameters.
    IMPORTING PARAMETERS: I_LIST_TYPE
    This parameter has possible values from 0-4.
    The parameter I_LIST_TYPE is of TYPE SLIS_LIST_TYPE and is DEFAULT 0 .
    EXPORTING PARAMETERS:  I_EVENTS table.
    This table is of TYPE SLIS_T_EVENT and returns to the program the name of all the possible events.
    The table structure contains the fields:
         I_EVENTS-NAME: Name of the Callback event.
    I_EVENTS-FORM: Name of the form routine that should be called in the calling program at the event.
    Only events with a form routine name are processed.
    The I_EVENTS table returns with the following possible constants:
    1.     Slis_ev_item_data_expand TYPE slis_formname VALUE 'ITEM_DATA_EXPAND'.     
    Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT. Exit for passing item entries (ITEM table) for a header record that was expanded interactively by the user.
    2.     Slis_ev_reprep_sel_modify TYPE slis_formname VALUE 'REPREP_SEL_MODIFY'.
    RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to       be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header that is to be expanded.
    RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that    entries are not repeated in the item table.
        RS_SELFIELD is initial in this case.         
    3.     Slis_ev_caller_exit_at_start TYPE slis_formname VALUE 'CALLER_EXIT'.
    Is called at the beginning of the function module to make special settings. It is not usually used.          
    4.     Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
    As this is a frequently-used Callback event, the form routine can also be passed        directly in the interface by passing the user command in the IMPORTING parameter           I_CALLBACK_USER_COMMAND.
    5.     Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
       Equivalent to the list processing TOP-OF-PAGE event.           
    6.     Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'.       
    The selection information and list status are output together (if they exist) on a separate page by default
    7.     Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'.       
    Analogously to TOP_OF_COVERPAGE the user can add other information
    to the information output by ALV (selection information, list status) at this event.
    8.     Slis_ev_foreign_top_of_page TYPE slis_formname VALUE ‘FOREIGN_TOP_OF_PAGE'.
    The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).
    In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.
    9.     Slis_ev_foreign_end_of_page TYPE slis_formname VALUE 'FOREIGN_END_OF_PAGE'.  
    The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).
    In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.                             
    10.     Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'.
    If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).
    The STANDARD status of the function group SALV should be used as a          template for a user-specific status. As this is a frequently used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.
    11.     Slis_ev_list_modify TYPE slis_formname VALUE 'LIST_MODIFY'.     
    LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME
                                             R_INDEX LIKE SY-TABIX
                                             R_INDEX_ITEM LIKE SY-TABIX
                                             R_INDEX_SUM LIKE SY-TABIX.
    12.     Slis_ev_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'.  
    Information output at the start of the list     
    13.     Slis_ev_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.
    Information output at the end of a page. This is only called for printing.
    14.     Slis_ev_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.     
    Information output at the end of the list
    15.     Slis_ev_after_line_output TYPE slis_formname VALUE 'AFTER_LINE_OUTPUT'.
    Output information after each output line. Should only be used in justified cases because it costs a lot of performance.
    16.     Slis_ev_before_line_output TYPE slis_formname VALUE   'BEFORE_LINE_OUTPUT'.       
    Output information before each output line. Should only be used in justified cases because it costs a lot of performance.         
    17.     Slis_ev_subtotal_text TYPE slis_formname VALUE  'SUBTOTAL_TEXT'.                        
    This event table (I_EVENTS) is now checked with the desired constants. If the desired constant is found, then the corresponding field for the FORM NAME is populated with the name of the routine containing the corresponding event.
    Sample code :
    FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
    FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE', FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
    DATA: L_I_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
               I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = I_EVENTS.
      READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                               INTO L_I_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_TOP_OF_PAGE TO L_I_EVENT-FORM.
        APPEND L_I_EVENT TO I_EVENTS.
      ENDIF.
      READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
                               INTO L_I_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_END_OF_PAGE TO L_I_EVENT-FORM.
        APPEND L_I_EVENT TO I_EVENTS.
      ENDIF.
      CLEAR L_I_EVENT.
      READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
                               INTO L_I_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_USER_COMMAND TO L_I_EVENT-FORM.
        APPEND L_I_EVENT TO I_EVENTS.
      ENDIF.
    This will prepare the events table for the report.
    The report will contain three forms for the above events:
    1.     FORM TOP_OF_PAGE : This form will contain the top of page event for the report i.e header etc
    Using the function module ‘REUSE_ALV_COMMENTARY_WRITE’, the internal table containing the headings for top of page event can be passed to the list output. Also, any logo specific to the report can be passed to the function module.
    2.     FORM END_OF_PAGE : This form will contain the end of page event for the report i.e footer etc
    3.     FORM USER_COMMAND : This form will contain the desired user command i.e pick/line selection
    Step 5
    A layout is build for the report output list description USING the internal table declared above (I_LAYOUT).
    Output list description structure.
         The parameters are described under the following heads:
    •     Display options
    •     Exceptions
    •     Totals
    •     Interaction
    •     Detail screen
    •     Display variants (only for hierarchical-sequential lists)
    •     Color
    •     Other
    The layout table is of type slis_layout_alv_spec and has the following fields:
    Display options                                                
    1. Colwidth_optimize (1) TYPE c: This parameter optimizes the length of the different columns in the output. The width of the different col. now depends on the max. Length of the data in the column.
    Value set: SPACE, 'X'
    'X' = optimizes the column width so that all contents are displayed completely.                   
    2. No_colhead(1) TYPE c : This parameter suppresses the column headings                    
    Value set: SPACE, 'X'.
    'X' = column headers are not output
    3. No_hotspot(1) TYPE c :  The heading of the report output are not output as hotspot.       
    Value set: SPACE, 'X'.
    'X' = column headers are not output as hotspot
    4. Zebra(1) TYPE c : The report is output in the striped pattern.             
    Value set: SPACE, 'X'.
    'X' = striped pattern (e.g. for wide lists)
    5. No_vline(1) TYPE c : The report output contains columns only separated by space and no lines.  It is not relevant for: hierarchical-sequential lists and multiple-line lists.
    Value set: SPACE, 'X'.
    'X' = columns separated by SPACE
    6. No_min_linesize(1) TYPE c : The report  line size is equal to the width of the list. It is not relevant for block lists.
    Value set: SPACE, 'X’.
    'X' = line size depends on list width
    '  ' = Line size is set to 80 or MIN_LINESIZE (if > 0) .
    7. Min_linesize LIKE sy-linsz: The report output contains a minimum possible length of line. If initial min_linesize is set to 80 by default, then this parameter is used to customize it. The prerequisite for this is that the parameter no_min_linesize should be ' '.
    Value set: 0, 10 - 250
    If the list is wider, the format uses the list width (maximum 250 or MAX_LINESIZE (if > 0)).
    8. Max_linesize LIKE sy-linsz: The default max. Linesize is 250. To change this default value, this parameter can interactively-define the maximum list width setting.
    Value set: 0, 80 - 1020
    9. Window_titlebar LIKE rsmpe-tittext: To set the titlebar on the report output.                            
               10. No_uline_hs(1) TYPE c.
    Exceptions                                                 
    11. Lights_fieldname TYPE slis_fieldname: Internal output table field containing the codes of exceptions to be output.
                      Output table field code:  '1' = red traffic light
                                    '2' = yellow traffic light
                                         '3' = green traffic light Fieldname for exception 
         Value set: SPACE, internal output table field name.
    12. Lights_tabname TYPE slis_tabname: Name of the internal output table that contains the field in the parameter LIGHTS_FIELDNAME. If LIGHTS_FIELDNAME is not empty, this field must also be filled for hierarchical-sequential lists. Only relevant for hierarchical-sequential lists.
    .     Value set: SPACE, internal output table name.
    13. Lights_rollname LIKE dfies-rollname: The documentation of this data element is displayed when you call F1 help for an exception column.
    Value set: SPACE, data element name.
               14. Lights_condense(1) TYPE c : If a list record is output with 'red traffic light', each
               Subtotal that includes this record is also output with 'red traffic light'.
               Value set: SPACE, 'X'
               'X' = the 'maximum' exception of the items in the subtotal is output at subtotal level.
    Sums                                                       
    15. No_sumchoice(1) TYPE c : This parameter allows the choice for summing up
    Only by fieldcatalog.
    Value set: SPACE, 'X'
    'X' = fields which are to be summed, passed by the calling program (FIELDCAT-DO_SUM = 'X'). The user should not be able to change this value interactively.
    16. No_totalline(1) TYPE c : Removes the option of having totals after sub-totals.
    Value set: SPACE, 'X'
    'X' = no total record is to be output. Subtotals can still be calculated and output. The fields in the subtotals are flagged DO_SUM = 'X' in the field list.
    17. No_subchoice(1) TYPE c : Does not allow the user to interactively change the field chosen for subtotals.
    Value set: SPACE, 'X'
    'X' = value whose change triggers subtotals, provided by the calling program. The user should not be able to change this value interactively.
    18. No_subtotals(1) TYPE c : No subtotals possible          
    Value set: SPACE, 'X'
    'X' = no subtotals.
    19. Numc_sum(1)  TYPE c : Totals only possible for NUMC-Fields.
    20. No_unit_splitting TYPE c: No separate total lines by inh.units   
    21.totals_before_items TYPE c: Display totals before the items   
    22. Totals_only(1) TYPE c :  Show only totals      
    Value set: SPACE, 'X'
    'X' = only total records are output.
    23. Totals_text(60) TYPE c : Text for 1st col. in totals   
    Value set: SPACE, string (max.60)
    ' ' = The first column in the total record contains an appropriate number of '*'s to indicate the total by default. If the first column is wide enough, the string 'Total' is output after the asterisks.
    'String’ = The string passed is output after the total indicated by '*', if the column is wide enough.
    24. Subtotals_text(60) TYPE c : Texts for subtotals
    Value set: SPACE, string (max.60)
    ' ' = In the first column of subtotal records, the subtotal is indicated by an appropriate number of '*' by default. If the first column is not a subtotal criterion, the string 'Total' is output after the asterisks, if the column is wide enough.
    'String’ = the string passed is output after the subtotal indicated by '*', if the column is wide enough and the first column is not a subtotal criterion. If it is a subtotal criterion, its value is repeated after the total, if the column is wide enough.
    Interaction                                                      
    25. Box_fieldname TYPE slis_fieldname: Fieldname for checkbox in the report output. If the list has checkboxes at the start of records (for selecting several records), this parameter contains the internal output table field name indicated by the checkbox selection column. The field is a checkbox at the start of list records without a list header.
    Value set: SPACE, internal output table field name
    26. Box_tabname TYPE slis_tabname: Name of the internal output table that contains the field in the parameter BOX_FIELDNAME. If BOX_FIELDNAME is not empty, this field must also be filled for hierarchical-sequential lists.
    Value set: SPACE, internal output table name.
    27. Box_rollname LIKE dd03p-rollname: rollname for checkbox          
    28. Expand_fieldname TYPE slis_fieldname: fieldname flag ‘expand’. The user can show or hide the items by clicking on the folder symbol (hotspot). If the items for a header entry are only to be read by the calling program and passed to ALV when a header has been expanded interactively, this can be controlled via the CALLBACK event        'ITEM_DATA_EXPAND'.
    29. Hotspot_fieldname TYPE slis_fieldname: Used to make the fieldname flag hotspot.
    30. No_input(1) TYPE c : The fields are only display fields.
            Value set: SPACE, 'X'
    'X' = all ready-for-input fields in a list are displayed as not ready-for-input. (Record selection checkboxes and fields which can be made ready-for-input via the field list parameter FIELDCAT-INPUT = 'X')
    31. F2code LIKE sy-ucomm: To assign an ALV standard function code to double-click (F2), assign the function code to this parameter. Ex.: to assign the ALV standard function 'Detail' ('&ETA') to F2.
                      => LAYOUT-F2CODE = '&ETA'.
    Value set: SPACE, function code
    32. Confirmation_prompt: confirm. Prompt when leaving       
    Value set: SPACE, 'X'
    'X' = if one of the functions ‘Back (F03)', ‘Exit (F15)' or ‘Cancel (F12)' occurs, a confirmation prompt appears.
    33. Key_hotspot(1) TYPE c : The key fields are displayed as hotspot. The columns defined in the field catalog as key fields (FIELDCAT-KEY = 'X') are output as hotspots, i.e. clicking on a key column (highlighted in color in the list) calls the function under F2.
    Value set: SPACE, 'X'.
    34. Reprep(1) TYPE c :  report report interface active.     
    35. Group_buttons(1) TYPE c :  group-buttons for COL1 - COL5 . Group output fields via FIELDCAT-SP_GROUP in the field list, and pass the group name to the list module in the interface parameter IT_SPECIAL_GROUPS.           
    Value set: SPACE, 'X'.
    36. No_keyfix(1) TYPE c : Used to make the key fields scrollable.
    Value set: SPACE, 'X'.
    ' ' = The key columns defined in the field catalog by FIELDCAT-KEY = 'X' are fixed in the list output. These columns do not scroll horizontally. The item table key columns are fixed in hierarchical-sequential lists. The header table key fields are not considered here.
    'X' = key columns not fixed
    37. Get_selinfos(1) TYPE c : To read selection screen.
    Value set: SPACE, 'X'.
    If the calling program is a report with an ABAP/4 selection screen, setting this parameter makes ALV read the selection screen again. If the selections are read successfully, a pushbutton, via which the user can call a popup which lists the report selections in a simple form, becomes active on the results list output by ALV.
    38.     group_change_edit(1) TYPE c :  Settings by user for new group     
    Value set: SPACE, 'X'
    'X' = the user can enter a format option for each sort criterion in the sort/subtotal popup, for the list format when this value changes (e.g. new page or underline).
    39.     No_scrolling(1) TYPE c : Does not allow scrolling of the list to the right.
    Value set: SPACE, 'X'.
    40. Expand_all(1) TYPE c : Expand all positions                   
    Detailed screen                                                    
    40.     Detail_popup(1) TYPE c : show detail in popup.
    Value set: SPACE, 'X'
    '  '  = List record detail display in full-screen mode, with top-of-page.
    'X'  = list record detail display in popup (without top-of-page).
    41. Detail_initial_lines(1) TYPE c : show also initial lines   
    Value set: SPACE, 'X'
    '  ' = Only fields whose contents are not initial are output in the detail view.
    'X' = initial field contents are also output in detail.
    41.     detail_titlebar(30) type c : Titlebar for detail screen
    Value set: SPACE, string (max.30)
    ` ' = ' Detail: Display' is output as the title of the detail window.
                  'String’ = the string passed is output as the title of the detail window. 
    Display variants                                                   
    42. Header_text (20) TYPE c: Text for header button. Only relevant for hierarchical-sequential lists. You can toggle between display field and field list views via pushbuttons in the display variant definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is technically a toggle between the header table and item table fields.   
    Value set: SPACE, CHAR (20)
    ' ' = The header table field pushbutton text is 'Header' by default.
    CHAR (20) = header table field pushbutton text.
    43.item_text(20) TYPE c : Text for item button. Only relevant for hierarchical-sequential lists. You can toggle the view between the display fields and the field list via pushbuttons in the display variant definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is technically a toggle between the header table and item table fields.        
    Value set: SPACE, CHAR (20)
    ' ' = The pushbutton text for the item table fields is 'Item' by default.
    CHAR (20) = item table field pushbutton text.
    44.default_ item(1) TYPE c : Items as default. Only relevant for hierarchical-sequential lists.
         Value set: SPACE, 'X'
    ' ' = The header table fields are displayed by default in the display variant definition popup. The user can switch to the item table fields interactively.
    'X' = the item table fields are displayed by default in the display variant Definition Popup.    The user can switch to the header table fields interactively.
    Colour                                                       
    45. Info_fieldname TYPE slis_fieldname: infofield for listoutput. A whole list record can be colored individually using a color code in a column of the internal output table for the record. Assign the name of the field containing the color code to this parameter.
    Value set: SPACE, internal output table field name
    The internal output table field must be of type CHAR(3).
    The code must have the following syntax:  'Cxy':
            C = color (all codes must start with 'C')
            X = color number ('1'-'9')
            Y = bold ('0' = off, '1' = on)
    46. Coltab_fieldname TYPE slis_fieldname: Cells can be colored individually using a color code which is contained in a column of the internal output table for the record containing the cell. Assign the name of the field to this parameter.       
    Others                                                
    47. List_append(1) TYPE c :  no call screen. It is only useful to output block-lists without specifying the above modules if the number of list blocks exceeds, or may exceed, the maximum number specified in the block module documentation. These operations are not possible for user-defined block lists.
    Example code :
           I_LAYOUT-f2code       = ws_fcode.
           I_LAYOUT-zebra        = 'X'.
    I_LAYOUT-colwidth_optimize = 'X'.
    I_LAYOUT-no_keyfix = 'X'.
    I_LAYOUT-get_selinfos = 'X'.
    I_LAYOUT-no_hotspot = 'X'.
           I_LAYOUT-no_input = 'X'.
    I_LAYOUT-hotspot_fieldname = FIELDNAME.
    I_LAYOUT-no_input          = ‘X’.
    I_LAYOUT-no_vline          = `X’.
    I_LAYOUT-no_colhead        = ‘ ‘.
    I_LAYOUT-lights_condense   = ` `.
    I_LAYOUT-totals_text       = ` `.
    I_LAYOUT-subtotals_text    = ` `.
    I_LAYOUT-totals_only       = ` `.
    I_LAYOUT-key_hotspot       = ‘X’.
    I_LAYOUT-detail_popup      = ‘X’.
    I_LAYOUT-group_change_edit = ‘X’.
    I_LAYOUT-GROUP_BUTTONS     = ‘X’.
    Step 6
    This step is required to get the selection screen information in the report output.
    The prerequisite for this is to set the parameter LAYOUT-GET_SELINFOS of the IMPORTING structure.
    The parameters to be passed in the IS_SEL_HIDE table are:
    o mode:              'R' = only the entries passed in the internal table IS_SEL_HIDE-T_ENTRIES       
    Are output in the pop up. Selection info, which the list tool read in the selection screen (when called by a report with a selection screen), is replaced by the values passed.
    'S' = the selection info which the list tool read in the selection screen of the calling report are modified by the entries in the table IS_SEL_HIDE-T_ENTRIES.
    o t_entries:         Selection info table
    o t_entries-mode:   'A' = output the selection info for the current table record in the info popup.
    'D' = do not output select option or SELNAME parameter selection info in   the popup.
    o t_entries-selname: (only used in t_entries-mode = 'D') : Name of the select option or parameter.
    The following table fields are only used in t_entries-mode = 'A'. They contain the selection information to be added.
    •     t_entries-field:  DDIC field name of the field for which selection information is to be output.
    •     t_entries-table:  DDIC table names of t_entries-field.
    •     t_entries-stext:  Field name in info popup.
    •     If t_entries-field and t_entries-table have been entered, this text is taken from DDIC.
    •     t_entries-valuf:  Selection condition 'from' value (external format)
    •     t_entries-valut:  Selection condition 'to' value (external format)
    •     t_entries-sign0:  (I)nclusive (E)xclusive
    •     t_entries-option:  All values of the select options Option field allowed.
    Step 6
    The Table IT_SORT is populated with the sort criteria for the different fields.
    The caller specifies the sorting and/or subtotaling of the basic list in the internal table IT_SORT.
    This internal table has the following fields:
         o spos :  Sort sequence
         o fieldname :  Internal output table field name
         o tabname : Only relevant for hierarchical-sequential lists. Name of the internal output table.
         o up : 'X' = sort in ascending order
         o down : 'X' = sort in descending order
         o subtot : 'X' = subtotal at group value change
         o group : '* ' = new page at group value change ,'UL' = underline at group value change
                             Step 7
    The final step in the output of the report is the use of two ALV functions modules.
    1.     REUSE_ALV_FIELDCATALOG_MERGE
    2.     REUSE_ALV_LIST_DISPLAY
    The first function module is used to pass the field catalog to the report output and merge it with the internal output table.
    FUNCTION reuse_alv_fieldcatalog_merge.                                
    ""Lokale Schnittstelle:                                             
    *” IMPORTING                                                    
    *"             VALUE(I_PROGRAM_NAME) LIKE  SY-REPID OPTIONAL          
    *"             VALUE(I_INTERNAL_TABNAME) TYPE  SLIS_TABNAME OPTIONAL  
    *"             VALUE(I_STRUCTURE_NAME) LIKE  DD02L-TABNAME OPTIONAL   
    *"             VALUE(I_CLIENT_NEVER_DISPLAY) TYPE  SLIS_CHAR_1        
    *"                             DEFAULT 'X'                            
    *"             VALUE(I_INCLNAME) LIKE  TRDIR-NAME OPTIONAL            
    *"       CHANGING                                                     
    *"             VALUE(CT_FIELDCAT) TYPE  SLIS_T_FIELDCAT_ALV           
    *"       EXCEPTIONS                                                   
    *"              INCONSISTENT_INTERFACE                                
    *"              PROGRAM_ERROR                                         
    Import parameters 
    I_PROGRAM_NAME: Program in which the internal output table is declared and populated   
    I_INTERNAL_TABNAME: Internal output table name
    I_STRUCTURE_NAME: Structure name (structure, table, and view)
    I_CLIENT_NEVER_DISPL: Hide client fields default ‘X’
    I_INCLNAME: Data declarations include name
    CHANGING parameter
    CT_FIELDCAT: Field catalog with field descriptions
    The variant based on a program-internal table should only be used for rapid prototyping since the following restrictions apply:                                                                               
    1.   Performance is affected since the code of the table definition must always be read and interpreted at runtime.                                                                               
    2.   Dictionary reference are only considered if the keywords LIKE or  INCLUDE STRUCTURE (not TYPE) are used.
    Step 8
    The other function module is used to display the internal output table with the contents
    FUNCTION reuse_alv_list_display.                                          
    ""Lokale Schnittstelle:                                                 
    *” IMPORTING                                                        
    *"             VALUE(I_INTERFACE_CHECK) DEFAULT SPACE                     
    *"             VALUE(I_CALLBACK_PROGRAM) LIKE  SY-REPID DEFAULT SPACE     
    *"             VALUE(I_CALLBACK_PF_STATUS_SET) TYPE  SLIS_FORMNAME        
    *"                             DEFAULT SPACE                              
    *"             VALUE(I_CALLBACK_USER_COMMAND) TYPE  SLIS_FORMNAME         
    *"                             DEFAULT SPACE                              
    *"             VALUE(I_STRUCTURE_NAME) LIKE  DD02L-TABNAME OPTIONAL       
    *"             VALUE(IS_LAYOUT) TYPE  SLIS_LAYOUT_ALV OPTIONAL            
    *"             VALUE(IT_FIELDCAT) TYPE  SLIS_T_FIELDCAT_ALV OPTIONAL      
    *"             VALUE(IT_EXCLUDING) TYPE  SLIS_T_EXTAB OPTIONAL            
    *"             VALUE(IT_SPECIAL_GROUPS) TYPE  SLIS_T_SP_GROUP_ALV         
    *"                             OPTIONAL                                   
    *"             VALUE(IT_SORT) TYPE  SLIS_T_SORTINFO_ALV OPTIONAL          
    *"             VALUE(IT_FILTER) TYPE  SLIS_T_FILTER_ALV OPTIONAL          
    *"             VALUE(IS_SEL_HIDE) TYPE  SLIS_SEL_HIDE_ALV OPTIONAL        
    *"           VALUE(I_DEFAULT) DEFAULT 'X'
    "             VALUE(I_SAVE) DEFAULT SPACE                             
    "             VALUE(IS_VARIANT) LIKE  DISVARIANT                      
    "                             STRUCTURE  DISVARIANT DEFAULT SPACE     
    "             VALUE(IT_EVENTS) TYPE  SLIS_T_EVENT OPTIONAL            
    "             VALUE(IT_EVENT_EXIT) TYPE  SLIS_T_EVENT_EXIT OPTIONAL   
    "             VALUE(IS_PRINT) TYPE  SLIS_PRINT_ALV OPTIONAL           
    "             VALUE(IS_REPREP_ID) TYPE  SLIS_REPREP_ID OPTIONAL       
    "             VALUE(I_SCREEN_START_COLUMN) DEFAULT 0                  
    "             VALUE(I_SCREEN_START_LINE) DEFAULT 0                    
    "             VALUE(I_SCREEN_END_COLUMN) DEFAULT 0                    
    "             VALUE(I_SCREEN_END_LINE) DEFAULT 0                      
    "       EXPORTING                                                     
    "             VALUE(E_EXIT_CAUSED_BY_CALLER)                          
    "             VALUE(ES_EXIT_CAUSED_BY_USER) TYPE  SLIS_EXIT_BY_USER   
    "       TABLES                                                        
    "              T_OUTTAB                                               
    "       EXCEPTIONS                                                    
    "              PROGRAM_ERROR
    Import parameters
    I_INTERFACE_CHECK: Interface consistency check log output.
    I_CALLBACK_PROGRAM: Name of the calling program
    I_CALLBACK_PF_STATUS_SET: Set EXIT routine to status.   
    I_CALLBACK_USER_COMMAND: EXIT routine for command handling
    I_STRUCTURE_NAME: Internal output table structure name     
    IS_LAYOUT: List layout specifications 
    IT_FIELDCAT: Field catalog with field descriptions
    IT_EXCLUDING: Table of inactive function codes   
    IT_SPECIAL_GROUPS: Grouping fields for column selection
    IT_SORT: Sort criteria for first list display
    IT_FILTER: Filter criteria for first list output
    IS_SEL_HIDE     : Selection information modification
    I_DEFAULT:      Initial variant active/inactive logic
    I_SAVE: Variants can be saved
    IS_VARIANT     : Variant information
    IT_EVENTS: Table of events to perform  IT_EVENT_EXIT :  Standard fcode exit requests table 
    IS_PRINT: Print information
    IS_REPREP_ID: Initialization keys for Re/Re interface
    I_SCREEN_START_COLUMN: Coordinates for list in dialog box
    I_SCREEN_START_LINE: Coordinates for list in dialog box
    I_SCREEN_END_COLUMN: Coordinates for list in dialog box        
    I_SCREEN_END_LINE: Coordinates for list

  • "CNTL_ERROR" raised , when using a Function Module

    Hi All,
    I am trying to reuse an existing Function module. This function module, fetches data in an internal table and creates a popup using ALV, using the Call Screen statement. I cannot modify this function module.
    Is there any method, how I can use this Function Module in Web Dynpro Application(which would be executed from portal) , because if I use it directly, I get an error .. Exception condition " CNTL_ERROR" raised as the Custom Container object doesn't get created. As far as  I understand, we cannot use such a function module directly, but please let me know if there Is any work around apart from creating a new function module.
    Best Regards,
    Preethi Santhanam.

    Refer these threads (Ans by Thomas) :
    CNTL_ERROR while calling an FM through WebDynpro

  • How to use SO_OBJECT_SEND function module

    Hi friends,
       how to use SO_OBJECT_SEND function module in 4.0B Server .

    hi
    good
    check this code
    REPORT ZTSAPMAIL.
    DATA: X_OBJECT_TYPE LIKE SOOD-OBJTP.
    DATA: BEGIN OF X_OBJECT_HD_CHANGE.
    INCLUDE STRUCTURE SOOD1.
    DATA: END OF X_OBJECT_HD_CHANGE.
    DATA: BEGIN OF X_OBJCONT OCCURS 10.
    INCLUDE STRUCTURE SOLI.
    DATA: END OF X_OBJCONT.
    DATA: BEGIN OF X_OBJHEAD OCCURS 0.
    INCLUDE STRUCTURE SOLI.
    DATA: END OF X_OBJHEAD.
    DATA: BEGIN OF RAW_HEAD.
    INCLUDE STRUCTURE SORH.
    DATA: END OF RAW_HEAD.
    DATA: BEGIN OF X_RECEIVERS OCCURS 0.
    INCLUDE STRUCTURE SOOS1.
    DATA: END OF X_RECEIVERS.
    PARAMETERS: RECEIVER LIKE X_RECEIVERS-RECNAM. " Name
    *BUILD MESSAGE HEADER
    MOVE 'Sort field goes here' TO X_OBJECT_HD_CHANGE-OBJSRT. " Sort field
    MOVE 'Name of the object goes here' TO X_OBJECT_HD_CHANGE-OBJNAM. " Name
    MOVE 'Document title goes here' TO X_OBJECT_HD_CHANGE-OBJDES. " Title
    MOVE 'F' TO X_OBJECT_HD_CHANGE-OBJSNS. " Functional OBJECT
    MOVE 'E' TO X_OBJECT_HD_CHANGE-OBJLA. " Language
    Object type of the new document
    MOVE 'RAW' TO X_OBJECT_TYPE.
    CLEAR X_OBJCONT.
    MOVE 'Contents of mail' TO X_OBJCONT-LINE.
    APPEND X_OBJCONT.
    CLEAR X_OBJCONT-LINE. APPEND X_OBJCONT.
    MOVE 'More contents' TO X_OBJCONT-LINE.
    APPEND X_OBJCONT.
    MOVE 'Still more contents'
    to x_objcont-line.
    APPEND X_OBJCONT.
    MOVE ' ' TO X_OBJCONT-LINE.
    APPEND X_OBJCONT.
    Specific header (Dependent on the object type, here RAW)
    REFRESH X_OBJHEAD.
    DESCRIBE TABLE X_OBJCONT LINES RAW_HEAD-RAWSIZ.
    MOVE RAW_HEAD TO X_OBJHEAD.
    APPEND X_OBJHEAD.
    *RECEIVERS table
    CLEAR X_RECEIVERS.
    REFRESH X_RECEIVERS.
    MOVE RECEIVER TO X_RECEIVERS-RECNAM. " Name
    MOVE 'B' TO X_RECEIVERS-RECESC. " Receiver type
    MOVE 'X' TO X_RECEIVERS-SNDCP. " Send as a copy
    MOVE 'X' TO X_RECEIVERS-SNDEX. " EXPRESS DOCUMENT
    APPEND X_RECEIVERS.
    CALL FUNCTION 'SO_OBJECT_SEND'
    EXPORTING
    folder_id = 'OUTBOX'
    forwarder = x_forwarder
    object_fl_change = x_object_fl_change
    OBJECT_HD_CHANGE = X_OBJECT_HD_CHANGE
    object_id = x_object_id
    OBJECT_TYPE = X_OBJECT_TYPE
    OUTBOX_FLAG = 'X'
    OWNER = SY-UNAME
    store_flag = x_store_flag
    importing
    object_id_new = x_object_id_new
    sent_to_all = x_sent_to_all "May need to use
    TABLES
    OBJCONT = X_OBJCONT
    OBJHEAD = X_OBJHEAD
    objpara = x_objpara
    objparb = x_objparb
    RECEIVERS = X_RECEIVERS.
    reward point if hlepful.
    thanks
    mrutyun^

  • Using a function module in ABAP Query

    Hi All,
    I want to use a function module in ABAp query in the Record Processing Section.
    In the report program we click on Pattern button to inser the function module so that all the Importing and exporting parameter automatically appears.
    Similarly is there any particular method of inserting a function module in ABAp Query.
    Regards
    Manipal Parkala

    When you are doing the infoset for the query (SQ02) you can add coding by clicking the coding tab. You can chose in wich event you want your coding and there is Pattern Button for  you to easy use.
    If you don't want to put the code in the infoset just in the query then is not posible.
    Nevertheless, I higly descourage the use of coding in queryies. If you need to insert some coding make an ALV its easier, clearer and much easier to mantain.
    Hope it helps.

  • How to Use ECC function Module

    Hi Experts - We need to execute the function module in ECC and need to write data in Oracle table.
    We are using BODS 4.0.
    How to use function module in data flow ? how it can work as a source ?
    I just need some basic steps how to use function module as a source and do the transformation to target.
    Thanks
    R

    Hi Ashwani,
    It is still not possible to use a FM as a source in DS.
    You can use a FM in a transformation but you have to start from a file or table as a source and load into a target (a FM can not be an end point of a dataflow - as it is used in the transformation and each transformation requires a source and a target.
    The scenario I described above was based on a situation where you have a source (flat file or table) and want to use a Function Module to transform your data and/or load the data in a transparant table in SAP.
    Your scenario is different, as your source is not a table/ff but a FM.
    In your case, I can see two scerio's:
    - Use an ABAP dataflow. Although I haven't got any experience with this I do believe this would be an option for your scenario. Please referer to the Data Services documentation on ABAP dataflows for further guidance.
    - As suggested earlier, you can create a bespoke (BW) Datasource based on a Function Module. Please refer to SAP help for creating a generic datasource:
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    Depending on your scenario there might be a third option:
    - Use a SAP transparant table as a source. Create a transformation into the designated Oracle table. In the transformation call a FM which executes whatever logic you require. This solution will work if you have a table which produces the same number of records as your FM. If your function module produces more or less records (than there are in the transparant table), then this might become a bit tricky. It might work, but I have never tried it.
    Instead of a transparant table you can also use a table join, obviously. Perhaps part of the complexity of your FM could be resolved by using a join and you can create a new simpler FM for the remaining logic?
    Good luck,
    Jan.

  • What is the difference b/w ALV Function Module and ALV Methods?

    Hello Friends,
          Can anybody help me in finding out the difference between ALV Function Modules and ALV methods?
    Thanks & Regards
    Sathish Kumar

    Hi Sathish,
    Plz go through this info. It is very useful.
    hi,
    chk these excellent links.
    http://www.geocities.com/mpioud/Abap_programs.html
    http://www.sapdevelopment.co.uk/reporting/reportinghome.htm
    Simple ALV report
    http://www.sapgenie.com/abap/controls/alvgrid.htm
    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
    http://www.sapgenie.com/abap/controls/alvgrid.htm
    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
    ALV
    1. Please give me general info on ALV.
    http://www.sapfans.com/forums/viewtopic.php?t=58286
    http://www.sapfans.com/forums/viewtopic.php?t=76490
    http://www.sapfans.com/forums/viewtopic.php?t=20591
    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
    2. How do I program double click in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=11601
    http://www.sapfans.com/forums/viewtopic.php?t=23010
    3. How do I add subtotals (I have problem to add them)...
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    4. How to add list heading like top-of-page in ABAP lists?
    http://www.sapfans.com/forums/viewtopic.php?t=58775
    http://www.sapfans.com/forums/viewtopic.php?t=60550
    http://www.sapfans.com/forums/viewtopic.php?t=16629
    5. How to print page number / total number of pages X/XX in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
    6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
    http://www.sapfans.com/forums/viewtopic.php?t=64320
    http://www.sapfans.com/forums/viewtopic.php?t=44477
    7. How can I set the cell color in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    8. How do I print a logo/graphics in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=81149
    http://www.sapfans.com/forums/viewtopic.php?t=35498
    http://www.sapfans.com/forums/viewtopic.php?t=5013
    9. How do I create and use input-enabled fields in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    10. How can I use ALV for reports that are going to be run in background?
    http://www.sapfans.com/forums/viewtopic.php?t=83243
    http://www.sapfans.com/forums/viewtopic.php?t=19224
    11. How can I display an icon in ALV? (Common requirement is traffic light icon).
    http://www.sapfans.com/forums/viewtopic.php?t=79424
    http://www.sapfans.com/forums/viewtopic.php?t=24512
    12. How can I display a checkbox in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=88376
    http://www.sapfans.com/forums/viewtopic.php?t=40968
    http://www.sapfans.com/forums/viewtopic.php?t=6919
    Go thru these programs they may help u to try on some hands on
    ALV Demo program
    BCALV_DEMO_HTML
    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
    BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
    BCALV_GRID_DEMO Simple ALV Control Call Demo Program
    BCALV_TREE_DEMO Demo for ALV tree control
    BCALV_TREE_SIMPLE_DEMO
    BC_ALV_DEMO_HTML_D0100
    OOPs:
    Check this for basic concepts of OOPS
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/abap%20objects/abap%20code%20sample%20to%20learn%20basic%20concept%20of%20object-oriented%20programming.doc
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20display%20data%20in%20alv%20grid%20using%20object%20oriented%20programming.doc
    Tabstrip
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20for%20tab%20strip%20in%20alv.pdf
    Editable ALV
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20edit%20alv%20grid.doc
    Tree
    http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_usrint.htm
    General Tutorial for OOPS
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an%20easy%20reference%20for%20alv%20grid%20control.pdf
    Rewords some points if it is helpful.
    Rgds,
    P.Naganjana Reddy

  • Regarding how to use the function module *control_form* in scripts

    HI friends,
    Can any one tell why and where do we use the function module control_form in scripts. Can you give me a small scenario how to use in scripts.

    hi satish,
    by using this function module we can pass the control
    commands to FORM THROUGH ABAP/4 PROGRAM.
    see the following example:
    TABLES: kna1.
    DATA: BEGIN OF it_kna1 OCCURS 0,
          kunnr LIKE kna1-kunnr,
          name1 LIKE kna1-name1,
          ort01 LIKE kna1-ort01,
          land1 LIKE kna1-land1,
          END OF it_kna1.
    DATA:records TYPE i,
         window TYPE i value 1.
    select-options:s_kunnr for kna1-kunnr.
    SELECT kunnr name1 ort01 land1 FROM kna1 INTO TABLE it_kna1
    where kunnr in s_kunnr.
    CALL FUNCTION 'OPEN_FORM'
      EXPORTING
        form     = 'ZSCRIPT4'
        language = sy-langu.
    LOOP AT it_kna1.
      CALL FUNCTION 'WRITE_FORM'
        EXPORTING
          element  = 'ELE1'
          function = 'SET'
          type     = 'BODY'
          window   = 'MAIN'.
      DESCRIBE TABLE it_kna1 LINES records.
      IF window lt records.
        window = window + 1.
      CALL FUNCTION 'CONTROL_FORM'
       EXPORTING
            command         = 'NEW-WINDOW'
    EXCEPTIONS
      UNOPENED        = 1
    UNSTARTED       = 2
    OTHERS          = 3
      ENDIF.
    ENDLOOP.
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
      RESULT                         =
      RDI_RESULT                     =
    TABLES
      OTFDATA                        =
    EXCEPTIONS
      UNOPENED                       = 1
      BAD_PAGEFORMAT_FOR_PRINT       = 2
      SEND_ERROR                     = 3
      SPOOL_ERROR                    = 4
      CODEPAGE                       = 5
      OTHERS                         = 6
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    thanks,
    raji

  • How to use the function module /IRM/IPBB_AGREEMENT_CREATE.

    Hi all,
    Please help me how to use the function module /IRM/IPBB_AGREEMENT_CREATE.
    It is a Vistex fuction module which is used to create Sales contract in SAP-Vistex. If anyone has use the function module and do have the sample code please share it.
    Thanks.

    FORM create_agreement TABLES pt_agreement
                                           CHANGING po_agreement .
      CONSTANTS: c_strt_knumh TYPE knumh VALUE '0000000000'.
      DATA: lc_kona  TYPE /irm/s_gkona,
            lc_cbasp TYPE /irm/s_ipcbasp,
          lt_cbapr TYPE /irm/t_ipcbapr,         "Partners
          lc_cbapr TYPE /irm/s_ipcbapr,
          lt_cbadt TYPE  /irm/t_ipcbadt,        "Dates
          lc_cbadt TYPE  /irm/s_ipcbadt,
          lt_cbafs TYPE  /irm/t_ipcbafs,
          lc_cbafs TYPE  /irm/s_ipcbafs,
          lt_cbacn TYPE  /irm/t_ipcbacn,
          lc_cbacn TYPE  /irm/s_ipcbacn,
          lt_cbacl TYPE  /irm/t_ipcbacl,
          lc_cbacl TYPE  /irm/s_ipcbacl,
          lt_cbtpv TYPE  /irm/t_ipagtpv,
          lc_cbtpv TYPE  /irm/s_ipagtpv,
          lt_texts TYPE  text_lh,
          lc_texts TYPE  itclh,
          lt_cbasd TYPE  /irm/t_ipcbasd,
          lc_cbasd TYPE  /irm/s_ipcbasd,
          lc_agreement    TYPE  /irm/s_ipcbasp_doc,
          lc_e_log_number TYPE  balognr,
          lt_messages     TYPE  /irm/t_gprolog.
      DATA: lt_vake      TYPE  cond_vakevb_t,
            lc_vake      TYPE LINE OF cond_vakevb_t,
            lt_konh      TYPE  /irm/t_gkonh,
            lc_konh      TYPE LINE OF /irm/t_gkonh,
            lt_konp      TYPE  /irm/t_gkonp,
            lc_konp      TYPE LINE OF /irm/t_gkonp,
            lt_konw      TYPE  /irm/t_gkonwu,
            lc_konw      TYPE LINE OF /irm/t_gkonwu,
            lt_konm      TYPE  /irm/t_gkonmu,
            lc_konm      TYPE LINE OF  /irm/t_gkonmu,
            lt_komg      TYPE  /irm/t_gkomg_index,
            lc_komg      TYPE LINE OF /irm/t_gkomg_index,
            lt_user_data TYPE  /irm/t_gpraxfu_index,
            lc_user_data TYPE LINE OF /irm/t_gpraxfu_index.
      DATA: lc_updt(1) TYPE c.
      DATA: lc_knumh TYPE knumh.
      DATA: BEGIN OF lc_str_knumh,
             hd(2) TYPE c VALUE '$$',
             inc_num(8) TYPE c,
            END OF lc_str_knumh.
      DATA: blank_agree_key TYPE knuma VALUE '~~~~~~~~~~'.
      FIELD-SYMBOLS <konh_line> LIKE LINE OF lt_konh.
      FIELD-SYMBOLS <konp_line> LIKE LINE OF lt_konp.
      DATA: lc_rule TYPE type_key_rule.
      READ TABLE pt_agreement INTO lc_rule INDEX 1.
    SELECT SINGLE * FROM  kona
            WHERE  vkorg   = lc_rule-vkorg
            AND    vtweg   = '10'
            AND    spart   = '10'
            AND    boart   = 'ZPS1'
            AND    botext  = lc_rule-sap_agkey.
    IF sy-subrc = 0.
       lc_updt = 'U'.
    ELSE.
      lc_updt = 'I'.
    ENDIF.
      LOOP AT pt_agreement INTO lc_rule.
        MOVE sy-tabix TO lc_str_knumh-inc_num.
        CONDENSE lc_str_knumh-inc_num NO-GAPS.
        WHILE lc_str_knumh-inc_num+7(1) = ' '.
          CONCATENATE '0' lc_str_knumh-inc_num INTO lc_str_knumh-inc_num.
          CONDENSE lc_str_knumh-inc_num NO-GAPS.
        ENDWHILE.
        CONCATENATE '$$' lc_knumh INTO lc_knumh.
        MOVE lc_str_knumh TO lc_knumh.
       MOVE c_strt_knumh TO lc_knumh.
        CLEAR: lc_konh, lc_konp, lc_komg.
        MOVE: lc_rule-vkorg    TO lc_komg-komg-vkorg,
              '10'             TO lc_komg-komg-vtweg,
              '10'             TO lc_komg-komg-spart,
              p_waers          TO lc_komg-komg-waerk,
              '1300'           TO lc_komg-komg-bukrs,
              lc_rule-lifnr    TO lc_komg-komg-lifnr,
              lc_knumh         TO lc_komg-knumh,
              lc_knumh         TO lc_konh-knumh,
              lc_knumh         TO lc_konp-knumh,
              lc_rule-datab    TO lc_konh-datab,
              lc_rule-datbi    TO lc_konh-datbi.
        CASE lc_rule-tablnam.
          WHEN 'A701'.                   "Every Agreement will have a A701 rule -
            "Therefore we acn setup the header using A701
            MOVE: 'New       '  TO lc_kona-knuma,
                  lc_rule-vkorg TO lc_kona-vkorg,
                  '10'          TO lc_kona-vtweg,
                  '10'          TO lc_kona-spart,
                  'ZPS1'        TO lc_kona-boart,
                  'C'           TO lc_kona-abtyp,
                  'V'           TO lc_kona-kappl,
                  p_waers       TO lc_kona-waers,
                  lc_rule-knuma_ag TO lc_kona-abrex,
                  'ZPS2'        TO lc_kona-kobog,
                  lc_rule-datab TO lc_kona-datab,
                  lc_rule-datbi TO lc_kona-datbi,
                  lc_rule-sap_agkey TO lc_kona-botext,
                  '1300'        TO lc_kona-bukrs,
                  'I'           TO lc_kona-updkz.
            MOVE: 'New       '  TO lc_cbasp-knuma_ag,
                  'ZPS1'        TO lc_cbasp-boart_ag,
                  p_waers       TO lc_cbasp-waers,
                  'A'           TO lc_cbasp-setl_mth,
                  'B'           TO lc_cbasp-setl_typ,
                  'A2'          TO lc_cbasp-ident,
                  'E'           TO lc_cbasp-setlm,
                  'ZPDA'        TO lc_cbasp-pargr,
                  'X'           TO lc_cbasp-npric,
                  'LF'          TO lc_cbasp-stprl,
                  lc_rule-lifnr TO lc_cbasp-stpar,
                  lc_rule-contract_rev  TO lc_cbasp-rvnum,
                  'I'           TO lc_cbasp-updkz.
            CONCATENATE: blank_agree_key
                   lc_rule-lifnr        INTO lc_konh-vakey.
            MOVE: lc_rule-lifnr TO lc_konp-lifnr.
          WHEN 'A703'.
            CONCATENATE: blank_agree_key
                         lc_rule-kunnr      INTO lc_konh-vakey.
            MOVE lc_rule-kunnr TO lc_komg-komg-kunnr.
          WHEN 'A709'.
            CONCATENATE: blank_agree_key
            lc_rule-zzprodh1  lc_rule-zzprodh2  lc_rule-zzprodh3
                   lc_rule-zzprodh4  lc_rule-zzprodh5 INTO lc_konh-vakey.
            CONCATENATE: lc_rule-zzprodh1  lc_rule-zzprodh2  lc_rule-zzprodh3
                   lc_rule-zzprodh4  lc_rule-zzprodh5 INTO lc_komg-komg-prodh.
          WHEN 'A710'.
            CONCATENATE: blank_agree_key
                lc_rule-matkl   INTO lc_konh-vakey.
            MOVE lc_rule-matkl TO lc_komg-komg-matkl.
          WHEN 'A711'.
            CONCATENATE: blank_agree_key
                 lc_rule-matnr   INTO lc_konh-vakey.
            MOVE lc_rule-matnr TO lc_komg-komg-matnr.
            IF lc_rule-kschl = 'ZPPL'.
              MOVE: 'C'              TO lc_konp-krech,
                    'CAD'              TO lc_konp-konwa.
              lc_konp-kbetr = lc_rule-net_po_price * 1.
            ENDIF.
          WHEN 'A717'.
          WHEN 'A718'.
            CONCATENATE: blank_agree_key
                 lc_rule-zzextwg INTO lc_konh-vakey.
            MOVE lc_rule-zzextwg TO lc_komg-komg-zzextwg.
         WHEN 'A719'.
           CONCATENATE: blank_agree_key
                lc_rule-werks INTO lc_konh-vakey.
           MOVE lc_rule-werks TO lc_komg-komg-werks.
         WHEN 'A721'.
           CONCATENATE: blank_agree_key
                 lc_rule-kunnr lc_rule-werks INTO lc_konh-vakey.
           MOVE: lc_rule-kunnr TO lc_konp-kunnr,
                 lc_rule-kunnr TO lc_komg-komg-kunnr.
          WHEN 'A722'.
            CONCATENATE: blank_agree_key
                         lc_rule-vkbur INTO lc_konh-vakey.
            MOVE lc_rule-vkbur TO lc_komg-komg-vkbur.
          WHEN 'A724'.
            CONCATENATE: blank_agree_key
                          lc_rule-kunnr lc_rule-vkbur INTO lc_konh-vakey.
            MOVE: lc_rule-kunnr TO lc_konp-kunnr,
                  lc_rule-kunnr TO lc_komg-komg-kunnr,
                  lc_rule-vkbur TO lc_komg-komg-vkbur.
        ENDCASE.
        MOVE: 'A'                  TO lc_konh-kvewe,
              lc_rule-tablnam+1(3) TO lc_konh-kotabnr,
              lc_rule-kappl        TO lc_konh-kappl,
              lc_rule-kschl        TO lc_konh-kschl.
        REPLACE ALL OCCURRENCES OF '~' IN lc_konh-vakey WITH ' '.
        APPEND lc_konh TO lt_konh.
        CLEAR lc_konh.
    *--- Add in the KONP.Do we need to add
        MOVE: lc_rule-kappl        TO lc_konp-kappl,
              lc_rule-kschl        TO lc_konp-kschl,
              'G'                  TO lc_konp-krech.
        IF lc_rule-kschl+3(1) = '%'.
          MOVE: 'A'              TO lc_konp-krech,
                '%'              TO lc_konp-konwa.
          lc_konp-kbetr = lc_rule-rebate_perc * 1.
        ENDIF.
        APPEND lc_konp TO lt_konp. CLEAR lc_konp.
        APPEND lc_komg TO lt_komg. CLEAR lc_komg.
      ENDLOOP.
      IF  lc_updt = 'I'.
        CALL FUNCTION '/IRM/IPCB_AGREEMENT_CREATE'
          EXPORTING
          I_MESSAGES_DISPLAY        = ' '
          I_SAVE_MESSAGES           = ' '
          I_COMMIT_WORK             = 'X'
          I_CALL_FROM_WS            = ' '
            is_kona                   = lc_kona
            is_cbasp                  = lc_cbasp
            it_cbapr                  = lt_cbapr
            it_cbadt                  = lt_cbadt
            it_cbafs                  = lt_cbafs
            it_cbacn                  = lt_cbacn
            it_cbacl                  = lt_cbacl
            it_cbtpv                  = lt_cbtpv
            it_texts                  = lt_texts
            it_cbasd                  = lt_cbasd
          IMPORTING
            es_agreement              = lc_agreement
            e_log_number              = lc_e_log_number
          TABLES
            t_messages                = lt_messages
         CHANGING
          CT_VAKE                   = lt_vake
          ct_konh                   = lt_konh
          ct_konp                   = lt_konp
          CT_KONW                   = lt_konw
          CT_KONM                   = lt_konm
           ct_komg                   = lt_komg
          CT_USER_DATA              = lt_usr_data
          EXCEPTIONS
            no_documents_to_process   = 1
            no_authorization          = 2
            creation_failed           = 3
            new_pricing_not_maitained = 4
            OTHERS                    = 5.
        IF sy-subrc <> 0.
    Implement suitable error handling here
        ELSE.
          MOVE: lc_agreement-knuma_ag TO po_agreement,
                lc_agreement-knuma_ag TO lc_kona-knuma.
        ENDIF.
        APPEND LINES OF lt_messages TO gt_messages.
      ELSE.
        MOVE-CORRESPONDING kona TO lc_kona.
      ENDIF.
      LOOP AT lt_konh ASSIGNING <konh_line>.
        MOVE lc_kona-knuma TO <konh_line>-vakey+0(10).
       move '&'           to <konh_line>-knumh+0(1).
      ENDLOOP.
      LOOP AT lt_konp ASSIGNING <konp_line>.
       MOVE lc_kona-knuma TO <konp_line>-vakey+0(10).
        move '&'           to <konh_line>-knumh+0(1).
      ENDLOOP.
      lc_kona-updkz = 'U'.
      lc_cbasp-updkz = 'U'.
      CLEAR lt_messages.
      CALL FUNCTION '/IRM/IPCB_AGREEMENT_CHANGE'
        EXPORTING
        I_MESSAGES_DISPLAY      = ' '
        I_SAVE_MESSAGES         = ' '
        I_COMMIT_WORK           = 'X'
        I_INIT_DATA             = 'X'
          is_kona                 = lc_kona
          is_cbasp                = lc_cbasp
         it_cbapr                = lt_cbapr
         it_cbadt                = lt_cbadt
         it_cbafs                = lt_cbafs
         it_cbacl                = lt_cbacl
         it_cbacn                = lt_cbacn
        IT_FIELDS               =
         it_texts                = lt_texts
       IMPORTING
         e_log_number            = lc_e_log_number
         TABLES
           t_messages              = lt_messages
        CHANGING
          cs_agreement            = lc_agreement
        CT_VAKE                 = lt_vake
          ct_konh                 = lt_konh
          ct_konp                 = lt_konp
        CT_KONW                 = lt_konw
        CT_KONM                 = lt_konm
          ct_komg                 = lt_komg
        CT_USER_DATA            = lt_usr_data
        EXCEPTIONS
          no_documents_to_process = 1
          no_authorization        = 2
          change_failed           = 3
          agreement_locked        = 4
          OTHERS                  = 5.
    IF sy-subrc <> 0.
    Implement suitable error handling here
    ENDIF.
      APPEND LINES OF lt_messages TO gt_messages.
    ENDFORM.                    " CREATE_AGREEMENT

  • How to Use the Function Module 'BAPI_BUSPROCESSND_CHANGEMULTI'

    Dear Experts,
             Can anyone Explain me how to Use the Function Module 'BAPI_BUSPROCESSND_CHANGEMULTI'.My Requirement is i want to change the Partners of the Service Order.It is Very Urgent Requirement Please Help me.
    Thanks & Regards,
    Ashok.

    Hi,
    For service order you can use FM 'BAPI_ACTIVITYCRM_CHANGEMULTI' as it is much easier to use.
    Sample code is below. You can use that:
    "fill the details of partner which is
              "to be added as main partner or in place of Interaction Agent
              wa_partner_new-ref_guid = w_guid_ref.
              wa_partner_new-ref_handle = '0000000000'.
              wa_partner_new-ref_kind = 'A'.
              wa_partner_new-kind_of_entry = wa_partner-kind_of_entry.
              wa_partner_new-ref_partner_handle = '0000'.
              wa_partner_new-ref_partner_fct = 'Z_IA'.
    "wa_partner-partner_no : New partner no.
              wa_partner_new-ref_partner_no = wa_partner-partner_no.
              wa_partner_new-ref_no_type = wa_partner-ref_no_type.
              wa_partner_new-ref_display_type = wa_partner-ref_display_type.
              wa_partner_new-display_type = 'BP'.
              wa_partner_new-no_type = 'BP'.
              wa_partner_new-partner_fct = 'Z_IA'.
    "w_partner_no : Old partner no. which is to be changed
              wa_partner_new-partner_no = w_partner_no.
              wa_partner_new-mainpartner = 'X'.
              INSERT wa_partner_new INTO TABLE it_partner_new.
              wa_partner_newx-display_type = 'X'.
              wa_partner_newx-no_type = 'X'.
              wa_partner_newx-partner_fct = 'X'.
              wa_partner_newx-partner_no = 'X'.
              wa_partner_newx-mainpartner = 'X'.
              INSERT wa_partner_newx INTO TABLE it_partner_newx.
      IF it_partner_new[] IS NOT INITIAL AND it_partner_newx[] IS NOT INITIAL.
        "maintain all changes to be done
        CALL FUNCTION 'BAPI_ACTIVITYCRM_CHANGEMULTI'
          TABLES
            partner  = it_partner_new
            partnerx = it_partner_newx.
        CLEAR : wa_guid1.
        REFRESH : it_guid1.
        wa_guid1-guid = w_guid_ref.
        APPEND wa_guid1 TO it_guid1.
        "save the changes
        CALL FUNCTION 'BAPI_ACTIVITYCRM_SAVE'
          TABLES
            objects_to_save = it_guid1.
        "commit the transaction
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      ENDIF.
    Reply fro any further help.
    Please reward points if helpful.
    Regards,
    Ashlesha

  • Unalbe to delete lock entry table using Dequeue function module

    Friends,
    I display a base ALV list with custom app. tool bar. When i click on a button, i submit another report which updates a z-table for that corresponding row. I create a lock object for this entry before submitting the report. After updating the table, I try to delete the lock object using dequeue function module in the called report, but though the subrc is 0, the lock entry is not getting deleted in SM12. The called report, after dequeue, again submits report 1 (the caller). So, when i try to do some operation for the same row which I first selected, it triggers Foreign_lock exception. When I completely go out of the base list, only then the entry is deleted. Can anyone tell me the reason? I have tried with parameters _SCOPE & _SYNCHRON, but same result.
    Regards,
    Sathish R

    Hi,
    The triggering of the dequeue is not in the proper position as it need to be placed.
    Thats the only problem as per u have described the issue.
    Place the deque as soon as the report is return the value.
    I hope it may work ur issue.

  • Updation of material data using a function module

    HI
      i want to update fields in the mvke table,but the field is a Customer field in the table, not sap table field.i want to update the field using a program , not going to mm02. which function can i use for the updation.There is a function module MATERIAL_MAINTAIN_DARK for updation,will this funtion module update the customer fields also. Can anyone tell me about this function module and how to use this function module or MATERIAL_MAINTAIN_DARK.

    Using the function Module BAPI_MATERIAL_SAVEDATA , you can also update the custom fields.
    This is the documentation for the extension fields:
    <b>Reference Structure for BAPI Parameters EXTENSIONIN/EXTENSIO
    Description
        You use this structure to transfer the material's customer-defined
        fields. For information on transferring these fields, see the function
        module documentation.
    Note
        Besides the table fields already defined, customer-defined table fields
        can also be supplied with data. Since these fields are created by the
        customer, they are known only during the runtime and must therefore be
        determined dynamically.
        The structures BAPI_TE_<NAME> (<NAME> = MARA, MARC, MARD, MBEW, MLGN,
        MLGT, MVKE) and the relevant checkbox structures BAPI_TE_<NAME> (<NAME>
        = MARAX, etc.) must first be extended by the customer to include the
        fields required. The standard structures contain only the corresponding
        key fields. When including new fields in these structures, make sure
        that the field has the same name as the field in the database table. In
        addition, the fields in the structures BAPI_TE_<NAME> may only be of the
        type CHARACTER. The data element BAPIUPDATE must be used for the fields
        in the checkbox structure (except for key fields).
        The two parameters EXTENSIONIN and EXTENSIONINX are used to transfer the
        data to the method. The field STRUCTURE contains the name of the
        structure (for example, BAPI_TE_MARA or BAPI_TE_MARAX) used to identify
        the work area (for example, WA_BAPI_TE_MARA or WA_BAPI_TE_MARAX) to
        which the data is transferred. The remaining fields for the parameter
        EXTENSIONIN or EXTENSIONINX contain the data for the key fields (for
        example, the material number) and the data for the customer-defined
        fields. The number of characters reserved in the two parameters for the
        content of a customer-defined field must be the same as the number of
        characters for the corresponding work area field. If the number of
    characters required is smaller, the remaining characters in the two
    parameters must be filled with blanks. Only then may the content of
    another field be transferred. Here too, remember that the data is
    written to the database only if the corresponding indicator has been set
    in the work area.</b>
    Regards,
    ravi

  • Extracting Text Field using a function module

    Hi Experts,
          We are trying to extract a test field from the R3 using a Function Module.
                  The Text from R3 Looks like this
                 Input Parameters
                  ID -1
                  SEQ 2
    It displays
              Column 1 Column2
               This is test
               strategy for Function
               Module xxxx
    So we put in some parameters to get this test field displayed. As you see the above is just one field but they are in different lines
            So what happens when we put in the database is it adds a new field
    Eg
    ID SEQ Column 1 Column2
    1   2        *            This is test
    1   2        *            strategy for Function
    1   2        *            Module xxxx
    The result that we need is
    D SEQ Column 1 Column2
    1   2        *            This is test strategy for Function Module xxxx
    How can we handle this in the Query Transform
    Your help in advance is appreciated.
    Thanks
    Edited by: alangilbi on Nov 17, 2010 3:49 AM

    Have you considered using a pivot transform to get your rows into columns and then a query transform to concatenate the columns together?

Maybe you are looking for

  • Using External HD as well as local drive for iTunes?

    So, I just got my brand spanking new 160GB Classic today. I have an external HD I have never set up but am thinking now is the time so I can load all of the music there and sync the iPod accordingly (as well as have a back up if I need to reset the i

  • NavigationModel GetCurCommunityID doesn't work for me

    using com.plumtree.portalpages.common.uiparts; NavigationModel navModel = (NavigationModel)_asCurrentSpace.GetModel(NavigationModel.STR_MVC_CLASS_NAME); int y = navModel.GetCurCommunityID(); This returns id = 0 on the login page, but once I login and

  • Looking For 'Thee' Adobe Air Juggernaut...

    Hello Community, My partner and I are both developers looking to hire/partner with 'thee' juggernaut of Adobe Air.  We are looking to outsource a large majority of the heavy lifting to someone who has serious experience with this framework.  If there

  • Unwanted automounts under a MobileMe account name

    I am sitting at my desktop staring at the Finder, where I see my laptop downstairs mounted as an AFP volume with my MobileMe address ([email protected]) as the logged-in user. If I unmount it, it immediately remounts itself. I have defined no unix or

  • SRM 7, PO list in POWL

    Hi Experts, In the POWL of the Purchasing tab(SRM 7), all the purchase order is displaying. User requirement is that they want only those PO list which belongs to their Purchase Org. how to acheive this, points will be rewared. Reg, Rajesh.