Variant Load in ALV GRID

Hi ,
      I am using CL_GUI_ALV_GRID  and at runtime we are maintaining variants for this grid , so initially variant is loading properly,
    but for one function we are setting some what different fieldcatalog by using SET_FRONTEND_FIELDCATALOG after this method execution variant is not working properly.
    i want variant to be loaded after this method also. is there any way to do it.
Thanks and Regards,
shiva.

If you are trying to modify how the column heading in the ALV grid looks(color, or any other attribute), it simply can not be done, not in the ALV Grid.
Regards,
Rich Heilman

Similar Messages

  • Problem with same layout (variant) for two ALV Grid and ALV Tree

    Hello!
    I have two docking containers on the screen. On the left i have cl_gui_alv_tree, on the right cl_salv_table.
    When a user set a default layout for ALV Grid (or ALV Tree), raport starts and sets this layout in both objects (tree and grid).
    How to avoid this?

    Hi,
    Take Two radio buttons.
    First radion button display the two containers in grid format,
    second radio button display the two containers in tree format base on user selection.
    CREATE OBJECT G_DOCING_CONTAINER
        EXPORTING PARENT = G_CUSTOM_CONTAINER."G_CONTAINER.
    DISPLAY THE DATA IN GRID FORMATA
    CREATE OBJECT r_grid
        EXPORTING
          i_parent          = G_DOCING_CONTAINER
    CALL METHOD g_docing_container->set_width
          EXPORTING
            width      = 1300.
    DISPLAY THE GRID DATA IN SECOND CONTAINER
    CREATE OBJECT r_grid1
        EXPORTING
          i_parent          = G_DOCING_CONTAINER
    CALL METHOD g_docing_container->set_width
          EXPORTING
            width      = 1300.
    OTHERWISE WE CAN DISPLAY THE TWO CONTAINERS DATA IN A GRID FORMAT
    CREATE OBJECT g_tree
        EXPORTING
          parent                = g_docing_container"g_custom_container
    IF R1 = 'X'.  "FOR GRID DISPLAY
    CALL METHOD r_grid1->set_table_for_first_display
    CALL METHOD r_grid2->set_table_for_first_display
    ELSE.
    ************TREE DISPLAY
    ENDIF.
    regards,
    muralii

  • Varying ALV grids

    Could anyone suggest how to display varying number of alv grids based on the selection criteria (eg if 1 then a single alv must be displayed, if 2 then two alvs and so on)

    Rakesh,
    The grids would be placed one after the other in the screen.  Build a screen with a custom container that spans the entire width of the screen.  Then under that one, place another, etc.  However, you must pick a finite number of custom containers.
    If you can not, then I would suggest that you re-visit the user requirement.  Sounds like the user needs to create multiple reports... creating a "super" report is a bit far fetched.
    Reward points accordingly.

  • How to set variant for ALV grid from ABAP

    Hello,
    I have a program which displays some data with ALV grid. Then after some operation I would like to set different layout for the grid, but not by choosing it manually but by the program. I thought that it would be enough to use the method SET_VARIANT, so I'm setting DISVARIANT structure properly, using SET_VARIANT method and after that I'm calling REFRESH_TABLE_DISPLAY but layout is not changed. What else should I do? Is that possible?
    Best regards,
    Marcin

    Hi,
    Check this
    * While declaring select-options
    parameters: p_vari        like ltdx-variant.  " Layout
    * then add the following code in
    at selection-screen on value-request for p_vari.
      perform f_variant_f4 using p_vari.
    * Code for f_variant_f4
    form f_variant_f4 using  p_vari.
    * private variables
      data : v_exit    type c.
      clear gs_variantt.
      v_variant_save = 'U'.
      call function 'LVC_VARIANT_F4'
        exporting
          is_variant    = gs_variant
          i_save        = v_variant_save
        importing
          e_exit        = v_exit
          es_variant    = gs_variantt
        exceptions
          not_found     = 1
          program_error = 2
          others        = 3.
      if sy-subrc ne c_0.
        message i999(yscc) with text-064.    " No Layout Available for F4
      endif.
      if v_exit is initial.
        gs_variant-variant = gs_variantt-variant.
        p_vari             = gs_variantt-variant.
      endif.
    endform.                                 " F_variant_f4
    * In PBO
        call method grid1->set_table_for_first_display
          exporting
            is_layout                     = gs_layout
            is_variant                    = gs_variant
            i_save                        = 'A'
            it_toolbar_excluding          = i_exclude[]
          changing
            it_outtab                     = i_output[]
            it_fieldcatalog               = i_fieldcat[]
          exceptions
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            others                        = 4.

  • Variant of ALV-Grid

    Hi folks,
    I’m using the variant function of the ALV Grid. The screen you get by creating or saving a variant contains the following tabstrips: Sort Order, Filter, View and Display.  My aim is to hide all tabstrips except the ‘Sort Order’ one. Is there any way to do this?
    thanks in advance

    Check this code that I got from Rich Heilman when I had the same problem. If you find out which you have by using
    RS_CUA_GET_STATUS_FUNCTIONS and then exclude the ones you don't want.
    Sure...check out the following code.
    Its the IT_TOOLBAR_EXCLUDING parameter of the interface of method SET_TABLE_FOR_FIRST_DISPLAY.
    look a the form EXCLUDE_TB_FUNCTIONS.
    REPORT ZRICH_0001.
    TABLES: MARA.
    DATA: BEGIN OF I_ALV OCCURS 0,
          MATNR TYPE MARA-MATNR,
          MAKTX TYPE MAKT-MAKTX,
          END OF I_ALV.
    DATA: ALV_CONTAINER  TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    DATA: ALV_GRID       TYPE REF TO CL_GUI_ALV_GRID.
    DATA: LAYOUT    TYPE LVC_S_LAYO.
    DATA: FIELDCAT  TYPE LVC_T_FCAT.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
    SELECTION-SCREEN END OF BLOCK B1.
    START-OF-SELECTION.
      PERFORM GET_DATA.
      CALL SCREEN 100.
         Module  status_0100  OUTPUT
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS '0100'.
      SET TITLEBAR '0100'.
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
      DATA: VARIANT TYPE  DISVARIANT.
      VARIANT-REPORT = SY-REPID.
      VARIANT-USERNAME = SY-UNAME.
    Create Controls
      CREATE OBJECT ALV_CONTAINER
             EXPORTING
                   CONTAINER_NAME    = 'ALV_CONTAINER'.
      CREATE OBJECT ALV_GRID
             EXPORTING
                   I_PARENT          =  ALV_CONTAINER.
    ALV Specific. Data selection.
    Populate Field Catalog
      PERFORM GET_FIELDCATALOG.
    Exclude functions
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
      CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
               IS_LAYOUT              = LAYOUT
               IS_VARIANT             = VARIANT
               I_SAVE                 = 'U'
               I_STRUCTURE_NAME       = 'I_ALV'
               it_toolbar_excluding   = lt_exclude
          CHANGING
               IT_OUTTAB       = I_ALV[]
               IT_FIELDCATALOG = FIELDCAT[].
    ENDMODULE.
         Module  USER_COMMAND_0100  INPUT
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK' OR 'CANC'.
          IF NOT ALV_CONTAINER IS INITIAL.
            CALL METHOD ALV_CONTAINER->FREE.
            CLEAR: ALV_CONTAINER.
            FREE : ALV_CONTAINER.
          ENDIF.
          IF SY-SUBRC = 0.
            SET SCREEN 0.
            LEAVE SCREEN.
          ELSE.
            LEAVE PROGRAM.
          ENDIF.
        WHEN 'EXIT'.
          IF NOT ALV_CONTAINER IS INITIAL.
            CALL METHOD ALV_CONTAINER->FREE.
            CLEAR: ALV_CONTAINER.
            FREE : ALV_CONTAINER.
          ENDIF.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.
    FORM GET_DATA
    FORM GET_DATA.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE I_ALV
            FROM MARA
              INNER JOIN MAKT
                ON MARAMATNR = MAKTMATNR
                   WHERE MARA~MATNR IN S_MATNR
                     AND MAKT~SPRAS = SY-LANGU.
      SORT I_ALV ASCENDING BY MATNR.
    ENDFORM.
         Form  Get_Fieldcatalog - Set Up Columns/Headers
    FORM GET_FIELDCATALOG.
      DATA: LS_FCAT TYPE LVC_S_FCAT.
      REFRESH: FIELDCAT.
      CLEAR: LS_FCAT.
      LS_FCAT-REPTEXT    = 'Material Number'.
      LS_FCAT-COLTEXT    = 'Material Number'.
      LS_FCAT-FIELDNAME  = 'MATNR'.
      LS_FCAT-REF_TABLE  = 'I_ALV'.
      LS_FCAT-OUTPUTLEN  = '18'.
      LS_FCAT-COL_POS    = 1.
      APPEND LS_FCAT TO FIELDCAT.
      CLEAR: LS_FCAT.
      LS_FCAT-REPTEXT    = 'Material Description'.
      LS_FCAT-COLTEXT    = 'Material Description'.
      LS_FCAT-FIELDNAME  = 'MAKTX'.
      LS_FCAT-REF_TABLE  = 'I_ALV'.
      LS_FCAT-OUTPUTLEN  = '40'.
      LS_FCAT-COL_POS    = 2.
      APPEND LS_FCAT TO FIELDCAT.
    ENDFORM.
         Form  EXCLUDE_TB_FUNCTIONS
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
      DATA LS_EXCLUDE TYPE UI_FUNC.
    Row manipulation
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    Sort buttons
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SORT_ASC.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SORT_DSC.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    This excludes all buttons
    LS_EXCLUDE = '&EXCLALLFC'.
    APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.
    Best Regards Benita

  • Multiple ALV Grid Controls per report - problem with default displ.variant

    Hi,
    I have a report with few screens called sequentialy. Each one of the screens has implemented own instance of ALV Grid Control within custom container, means:
    - screen 100 has container Cont100 and grid control "grid100",
    - screen 110 has container Cont110 and grid control "grid110"
    - screen 120 has container Cont120 and grid control "grid120"
    and so on...
    Each one of the grid controls is initialized with own field catalog table, with own layout and variant structure definitions. My problem occurs when the user changes the display variant for some of the grid controls and save the layout variant using "default setting" checkbox. In this case next time the program is started all other grid controls behaves like they don't have their own variant definitions, but uses the default setting of the mentioned screen. This leads (usualy) to unsuable grid controls by default, because usualy different controls have no equal field-definition tables. I have the same behaviour even when there are more than 1 ALV grids on a single screen (for example - 2).
    For now I don't provide variant variables at selection screen, but it seems there is no way to provide such variables for each one of the grid-controls.
    Is anyone aware how to control this? Means no matter if there is default setting in use for some of the grid-controls, how to manipulate other grid-controls not to use this default setting?
    Many thanks in advance.
    Regards,
    Ivaylo Mutafchiev

    check this sample code which displays 4 grids in 4 different tabs and with 4 different handles
    PROGRAM  sapmzsdpp MESSAGE-ID z1.
    Table Declarations                                                   *
    TABLES:
      vbpa,                                " Sales Document: Partner
      kna1,                                " Customer Master
      vbap.                                " Sales Document: Item Data
    Tab Strip Declarations                                              *
    CONTROLS:
      tabstrip_sdpp TYPE TABSTRIP.         " Tabstrip
    Constants declarations                                               *
    CONSTANTS:
      c_rep_zm(2)   TYPE c VALUE 'ZM',     " Outside Sales Representative
      c_rep_ve(2)   TYPE c VALUE 'VE',     " Inside Sales Representative
      c_rep_zi(2)   TYPE c VALUE 'ZI',     " Sales Manager
      c_abgru_08(2) TYPE c VALUE '08',     " Reason for Rej: SO Not Closed
      c_stock_ind_e TYPE c VALUE 'E',      " Stock Idctr : Orders on hand
      c_gauge(5)    TYPE c VALUE 'GAUGE',  " Characteristic Name - GAUGE
      c_width(5)    TYPE c VALUE 'WIDTH',  " Characteristic Name - WIDTH
      c_gauge_metric(12)                   " Character Name - GAUGE_METRIC
                    TYPE c VALUE 'GAUGE_METRIC',
      c_width_metric(12)                   " Character Name - WIDTH_METRIC
                    TYPE c VALUE 'WIDTH_METRIC',
      c_eng_metric(14)                     " Charac Value - ENGLISH_METRIC
                    TYPE c VALUE 'ENGLISH_METRIC',
      c_coil(4)     TYPE c VALUE 'COIL',   " For Value COIL
      c_spec_bf(7)  TYPE c VALUE 'SPEC_BF'," Charac value SPEC_BF
      c_wadat_ist(8)                       " Actual Goods Movement Date
                    TYPE c VALUE '00000000',
      c_mcha(4)     TYPE c VALUE 'MCHA',   " Database Table 'MCHA'
      c_classtype_022(3)
                    TYPE c VALUE '022',    " Class Type : BATCH
      c_pipe(2)     TYPE c VALUE '06',     " Material Pricing Group: Pipes
      c_item_ctgry_ztam(4)
                    TYPE c VALUE 'ZTAM',   " Item Cat:Certificate Mnfctr
      c_lab_result(10)                     " Charac Value LAB_RESULT
                    TYPE n VALUE '0000001392',
      c_none_reqd(10)                      " For Value NONE REQD
                    TYPE c VALUE 'NONE REQD.',
      c_passed(6)   TYPE c VALUE 'PASSED', " For Value PASSED
      c_pending(12) TYPE c                 " For Value TEST PENDING
                    VALUE 'TEST PENDING',
      c_bundling(13)                       " For Value TEST BUNDLING
                    TYPE c VALUE 'TEST BUNDLING',
      c_normal(2)   TYPE c VALUE '01'.     " Priority: Normal
    Internal Table Declarations                                          *
    DATA :
    Internal table to hold common data for all reports
    BEGIN OF t_common_data OCCURS 0,
       kunnr        LIKE vbak-kunnr,       " Customer Number
       vbeln        LIKE vbap-vbeln,       " Sales Document Number
       posnr        LIKE vbap-posnr,       " Sales Document Item Number
       ihrez_e      LIKE vbkd-ihrez_e,     " Mill Order Number
       matnr        LIKE vbap-matnr,       " Material Number
       pstyv        LIKE vbap-pstyv,       " Sales Document Item Category
       kwmeng       LIKE vbap-kwmeng,      " Cumulative Order Quantity
       lprio        LIKE vbap-lprio,       " Delivery Priority
       werks        LIKE vbap-werks,       " Plant
       kondm        LIKE vbap-kondm,       " Material Pricing Group
       aedat        LIKE vbap-aedat,       " Date of Last Change
       cuobj        LIKE vbap-cuobj,       " Configuration
       saldata      LIKE vbap-zzcust_req_avail,
                                           " Required Availability Date
    END OF t_common_data,
    Internal table to hold Customer Number
      BEGIN OF t_cust_temp OCCURS 0,
        kunnr       LIKE vbak-kunnr,       " Customer Number
      END OF t_cust_temp,
    Internal table to hold stock details
      BEGIN OF t_stock OCCURS 0,
       vbeln        LIKE mska-vbeln,       " Sales Document Number
       posnr        LIKE mska-posnr,       " Sales Document Item Number
       matnr        LIKE mska-matnr,       " Material Number
       werks        LIKE mska-werks,       " Plant
       charg        LIKE mska-charg,       " Batch Number
       kalab        LIKE mska-kalab,       " Valuated Stock
       ersda        LIKE mska-ersda,
    END OF t_stock,
    Internal table to hold deliveries
    BEGIN OF t_delivery_data OCCURS 0,
      vbeln         LIKE lips-vbeln,       " Delivery Document Number
      vgbel         LIKE lips-vgbel,       " Document No of Ref Document
      vgpos         LIKE lips-vgpos,       " Item No of Ref Item
    END OF t_delivery_data,
    Internal table to hold released tons & released days
    BEGIN OF t_released_tons_days OCCURS 0,
      vbeln         LIKE likp-vbeln,       " Delivery Document Number
      btgew         LIKE likp-btgew,       " Total Weight
      bldat         LIKE likp-bldat,       " Document Date in Document
    END OF t_released_tons_days,
    Internal table to hold Pre-Production-Pending Orders (Report-1)
    BEGIN OF t_pre_prod_ord OCCURS 0,
       sortl1       LIKE zcustcode-sortl,  " Customer Search Term
       ihrez_e1     LIKE vbkd-ihrez_e,     " Mill Order Number
       salord1(17)  TYPE c,                " Sales Order Document & Item
       descri       TYPE char70,           " Specification of the Item
       speci        TYPE char30,           " Description of the Item
       days_entry   LIKE zlgcyinfo-days_since_entry,
                                           " Days Since Entry
       dept         LIKE zlgcyinfo-bklog,  " Department
       notes1       LIKE zcsimemo-text,    " CSI File Memo Text
    */ Request No. DV2K904687
       chng_date    LIKE vbap-aedat,       " Date of Last Change
    END OF t_pre_prod_ord,
    Internal table to hold Delinquent Orders (Report-2)
    BEGIN OF t_delinquent_ord OCCURS 0,
       sortl2       LIKE zcustcode-sortl,  " Customer Search Term
       ihrez_e2     LIKE vbkd-ihrez_e,     " Mill Order Number
       salord2(17)  TYPE c,                " Sales Order Document & Item
       descri       TYPE char70,           " Specification of the Item
       speci        TYPE char30,           " Description of the Item
       saldata      LIKE vbap-zzcust_req_avail,
       schdate      LIKE vbep-edatu,       " Schedule Line Date
       days_late    LIKE zlgcyinfo-dayslate,
                                           " Days Late
       unit         LIKE zlgcyinfo-unit,   " Status of Consolidation Units
       days_at_unit LIKE zlgcyinfo-daysatunit,
       notes2       LIKE zcsimemo-text,    " CSI File Memo Text
    END OF t_delinquent_ord,
    Internal table to hold Processed Material Orders (Report-3)
    BEGIN OF t_processed_ord OCCURS 0,
       sortl3       LIKE zcustcode-sortl,  " Customer Search Term
       ihrez_e3     LIKE vbkd-ihrez_e,     " Mill Order Number
       salord3(17)  TYPE c,                " Sales Order Document & Item
       descri       TYPE char70,           " Specification of the Item
       speci        TYPE char30,           " Description of the Item
       order_tons   LIKE vbap-kwmeng,      " Cumulative Order Quantity
       fin_tons     LIKE mska-kalab,       " Val.Stock With Unres Usage
       fin_days     TYPE i,                " Finished Days
       rel_tons     LIKE likp-btgew,       " Total Weight
       rel_days     TYPE i,                " No.of.Days Order is Released
       status(15)   TYPE c,                " Status Of Stock
       tb_tons      LIKE zlgcyinfo-tons,   " Tons
       notes3       LIKE zcsimemo-text,    " CSI File Memo Text
    END OF t_processed_ord,
    Internal table to hold Flagged Orders (Report-4)
    BEGIN OF t_flagged_ord OCCURS 0,
       sortl4       LIKE zcustcode-sortl,  " Customer Search Term
       ihrez_e4     LIKE vbkd-ihrez_e,     " Mill Order Number
       salord4(17)  TYPE c,                " Sales Order Document & Item
       descri       TYPE char70,           " Specification of the Item
       speci        TYPE char30,           " Description of the Item
       saldata      LIKE vbap-zzcust_req_avail,
       unit         LIKE zlgcyinfo-unit,   " Status of Consolidation Units
       tons         LIKE zlgcyinfo-tons,   " Tons
       priority     LIKE vbap-lprio,       " Delivery Priority
       notes4       LIKE zcsimemo-text,    " CSI File Memo Text
    END OF t_flagged_ord,
    Internal table to hold CSI memo file data
    BEGIN OF t_csi_memo_data OCCURS 0,
       vbeln        LIKE zcsimemo-vbeln,   " Sales Document Number
       posnr        LIKE zcsimemo-posnr,   " Sales Order line item
       text         LIKE zcsimemo-text,    " CSI File Memo Text
    END OF t_csi_memo_data,
    Internal table to hold Customer Codes
    BEGIN OF t_customer_code OCCURS 0,
       sortl        LIKE zcustcode-sortl,  " Sort Field
       kunnr        LIKE zcustcode-kunnr,  " Customer Number
    END OF t_customer_code,
    Internal table to hold schedule line dates
    BEGIN OF t_schedule_line_date OCCURS 0,
       vbeln        LIKE vbep-vbeln,       " Sales Document Number
       posnr        LIKE vbep-posnr,       " Sales Document Item Number
       edatu        LIKE vbep-edatu,       " Schedule line date
    END OF t_schedule_line_date,
    Internal table to hold Characteristic values
      t_configuration
                    TYPE TABLE OF conf_out
                    WITH HEADER LINE,
    Internal tables to hold legacy data
      t_lgcyinfo    TYPE TABLE OF zlgcyinfo
                    WITH HEADER LINE.
    Work variables declarations                                          *
    DATA:
      gv_parvw      LIKE kupav-parvw,      " Partner function
      gv_abgru      LIKE vbap-abgru,       " Reason to eject sales order
      gv_gauge      LIKE conf_out-atwtb,   " Charac Value Description
      gv_width      LIKE conf_out-atwtb,   " Charac Value Description
      gv_ok_code    LIKE sy-ucomm,         " Usercommand
      gv_okcode     LIKE sy-ucomm,         " User Command
      gv_number     LIKE sy-dynnr
                    VALUE '0101',          " Initial Sub Screen Number
      gv_vbeln      LIKE vbak-vbeln,       " Sales Order
      gv_posnr      LIKE vbup-posnr,       " Sales Item
    */ Request No. DV2K904687
      gv_del_prio   LIKE vbap-lprio,       " Delivery Priority
      gv_obj_key    LIKE inob-objek,       " Object Key
      gv_config     LIKE inob-cuobj,       " Configuration
      gv_lab_result LIKE ausp-atwrt,       " Lab Result Value
      gv_pass_stock LIKE mska-kalab,       " Finished Stock
      gv_fail_stock LIKE mska-kalab,       " Failed Stock
      gv_tp_tons    LIKE mska-kalab,       " Test Pending Tons
      gv_csi_stock  LIKE mbew-lbkum,       " CSI Stock On Hand
      gv_val_stock  LIKE mska-kalab,       " Valuated Stock
      gv_fin_tons   LIKE mska-kalab,       " Finished Tons
      gv_fin_days   TYPE i,                " Finished Days
      gv_rel_tons   LIKE likp-btgew,       " Released Tons
      gv_rel_days   TYPE i,                " Released Days
      gv_no_delivery                       " Number of Delivery Documents
                    TYPE i,
      gv_bund_tons  LIKE zlgcyinfo-tons,   " Bundling Tons
      gv_net_weight LIKE mara-ntgew,       " Net Weight
      gv_tb_tons    LIKE zlgcyinfo-tons,   " Test/Bundling Tons
      gv_date       LIKE mska-ersda,       " Date
      gv_tabix      LIKE sy-tabix,         " Table Index
      gv_flg        TYPE c,                " Flag Variable
      gv_exit       TYPE c.                " For Parameter Exit
    Constant declarations for ALV Grid                                   *
    CONSTANTS:
      c_cont_pre_prod_ord
                     TYPE scrfname VALUE 'CUST_PPP',
                                           " Custom Container for Report-1
      c_cont_delinquent_ord
                     TYPE scrfname VALUE 'CUST_DIP',
                                           " Custom Container for Report-2
      c_cont_processed_ord
                     TYPE scrfname VALUE 'CUST_PMS',
                                           " Custom Container for Report-3
      c_cont_flagged_ord
                     TYPE scrfname VALUE 'CUST_FLGORD',
                                           " Custom Container for Report-4
      c_handle1(3)   TYPE c VALUE 'G_1',   " Handle for PPP rpt Grid
      c_handle2(3)   TYPE c VALUE 'G_2',   " Handle for DIP rpt Grid
      c_handle3(3)   TYPE c VALUE 'G_3',   " Handle for PMS rpt Grid
      c_handle4(3)   TYPE c VALUE 'G_4',   " Handle for FLGORD rpt Grid
      c_true         TYPE c VALUE 'X',     " For value 'X'
      c_save         TYPE c VALUE 'A'.     " User-Defd & Global Variants
    Selection Screen                                                     *
    SELECTION-SCREEN BEGIN OF SCREEN 500 AS WINDOW.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-014.
    PARAMETERS :
      p_osr       RADIOBUTTON GROUP g1
                  DEFAULT 'X',             " Outside Sales Representative
      p_isr       RADIOBUTTON GROUP g1,    " Inside Sales Representative
      p_s_mgr     RADIOBUTTON GROUP g1.    " Sales Manager
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-005.
    SELECT-OPTIONS:
      s_pernr     FOR vbpa-pernr
                  OBLIGATORY,              " Employee Number
      s_kunnr     FOR kna1-kunnr,          " Customer Number
      s_sortl     FOR kna1-sortl,          " Customer Search Term
      s_kondm     FOR vbap-kondm.          " Material Pricing Group
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-006.
    PARAMETERS:
      p_open      RADIOBUTTON GROUP g2
                  DEFAULT 'X',             " Open Orders
      p_closed    RADIOBUTTON GROUP g2.    " Closed Orders
    SELECTION-SCREEN END OF BLOCK b3.
    SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-007.
    PARAMETERS:
      p_var1      LIKE disvariant-variant, " Variant For Report-1
      p_var2      LIKE disvariant-variant, " Variant For Report-2
      p_var3      LIKE disvariant-variant, " Variant For Report-3
      p_var4      LIKE disvariant-variant. " Varinat For Report-3
    SELECTION-SCREEN END OF BLOCK b4.
    SELECTION-SCREEN END OF SCREEN 500.
    */ Begin of Modification - Request No. DV2K904687
    Selection Screen for Changing Sales Order Priority
    SELECTION-SCREEN BEGIN OF SCREEN 1100 AS WINDOW.
    SELECTION-SCREEN BEGIN OF BLOCK b5 WITH FRAME TITLE text-044.
    PARAMETERS    p_sonum  LIKE vbap-vbeln." Sales Order Number
    SELECT-OPTIONS s_item  FOR  vbap-posnr." Sales Order Item
    PARAMETERS     p_delpr LIKE vbap-lprio." Delivery Priority
    SELECTION-SCREEN END OF BLOCK b5.
    SELECTION-SCREEN END OF SCREEN 1100.
    */ End of Modification - Request No. DV2K904687
    CLASS lcl_gv_event_receiveriver DEFINITION                           *
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    ALV Grid - Work Variables Declarations                               *
    DATA:
      gv_cont_pre_prod_ord   TYPE REF
                               TO cl_gui_custom_container,
                                           " Custom Cont For Report-1
      gv_cont_delinquent_ord TYPE REF
                               TO cl_gui_custom_container,
                                          " Custom Cont For Report-2
      gv_cont_processed_ord  TYPE REF
                               TO cl_gui_custom_container,
                                           " Custom Cont For Report-3
      gv_cont_flagged_ord    TYPE REF
                               TO cl_gui_custom_container,
                                           " Custom Cont For Report-4
      gv_grid_pre_prod_ord   TYPE REF
                               TO cl_gui_alv_grid,
                                           " Grid For Report-1
      gv_grid_delinquent_ord TYPE REF
                               TO cl_gui_alv_grid,
                                           " Grid For Report-2
      gv_grid_processed_ord  TYPE REF
                               TO cl_gui_alv_grid,
                                           " Grid For Report-3
      gv_grid_flagged_ord    TYPE REF
                               TO cl_gui_alv_grid,
                                           " Grid For Report-4
      gv_event_receiver      TYPE REF
                               TO lcl_event_receiver,
                                           " Object For Local Class
      gs_lay_pre_prod_ord    TYPE lvc_s_layo,
                                           " Work Area for Grid layout
      gs_lay_delinquent_ord  TYPE lvc_s_layo,
                                           " Work Area for Grid layout
      gs_lay_processed_ord   TYPE lvc_s_layo,
                                           " Work Area for Grid layout
      gs_lay_flagged_ord     TYPE lvc_s_layo,
                                           " Work Area for Grid Layout
      gs_var_pre_prod_ord    TYPE disvariant,
                                           " Layout Structure
      gs_var_delinquent_ord  TYPE disvariant,
                                           " Layout Structure
      gs_var_processed_ord   TYPE disvariant,
                                           " Layout Structure
      gs_var_flagged_ord     TYPE disvariant,
                                           " Layout Structure
      t_fcat_pre_prod_ord    TYPE lvc_t_fcat
                             WITH HEADER LINE,
                                           " Field Catalog For Report-1
      t_fcat_delinquent_ord  TYPE lvc_t_fcat
                             WITH HEADER LINE,
                                           " Field Catalog For Report-2
      t_fcat_processed_ord   TYPE lvc_t_fcat
                             WITH HEADER LINE,
                                           " Field Catalog For Report-3
      t_fcat_flagged_ord     TYPE lvc_t_fcat
                             WITH HEADER LINE,
                                           " Field Catalog For Report-4
      t_exclude              TYPE ui_functions,
                                           " Function Code Table
      gs_exclude             TYPE ui_func. " Function Code Structure
    CLASS lcl_gv_event_receiver DEFINITION                               *
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
          handle_hotspot
            FOR EVENT hotspot_click OF cl_gui_alv_grid
              IMPORTING e_row_id e_column_id es_row_no,
          handle_top_of_page
                          FOR EVENT print_top_of_page OF cl_gui_alv_grid,
    */ Begin of Modification - Request No. DV2K904687
        handle_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
                IMPORTING e_object e_interactive,
        handle_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
                IMPORTING e_ucomm.
    */ End of Modification - Request No. DV2K904687
    ENDCLASS.                              " LCL_EVENT_RECEIVER DEFINITION
    CLASS IMPLEMENTATION                                                 *
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_hotspot.
        CASE e_column_id-fieldname.
          WHEN 'SALORD1'.
            CLEAR t_pre_prod_ord.
            READ TABLE t_pre_prod_ord
                  INTO t_pre_prod_ord
                 INDEX e_row_id-index.
          Call VA03 To View Sales Order Line Item Details
            PERFORM call_va03 USING t_pre_prod_ord-salord1.
          WHEN 'SALORD2'.
            CLEAR t_delinquent_ord.
            READ TABLE t_delinquent_ord
                  INTO t_delinquent_ord
                 INDEX e_row_id-index.
          Call VA03 To View Sales Order Line Item Details
            PERFORM call_va03 USING t_delinquent_ord-salord2.
          WHEN 'SALORD3'.
            CLEAR t_processed_ord.
            READ TABLE t_processed_ord
                  INTO t_processed_ord
                 INDEX e_row_id-index.
          Call VA03 To View Sales Order Line Item Details
            PERFORM call_va03 USING t_processed_ord-salord3.
          WHEN 'SALORD4'.
            CLEAR t_flagged_ord.
            READ TABLE t_flagged_ord
                  INTO t_flagged_ord
                 INDEX e_row_id-index.
          Call VA03 To View Sales Order Line Item Details
            PERFORM call_va03 USING t_flagged_ord-salord4.
          WHEN 'SORTL1'.
            CLEAR t_pre_prod_ord.
            READ TABLE t_pre_prod_ord
                  INTO t_pre_prod_ord
                 INDEX e_row_id-index.
        Call ZSD11 for Customer Search Term
            PERFORM call_zsd11_cust_code USING t_pre_prod_ord-sortl1.
          WHEN 'SORTL2'.
            CLEAR t_delinquent_ord.
            READ TABLE t_delinquent_ord
                  INTO t_delinquent_ord
                 INDEX e_row_id-index.
          Call ZSD11 for Customer Search Term
            PERFORM call_zsd11_cust_code USING t_delinquent_ord-sortl2.
          WHEN 'SORTL3'.
            CLEAR t_processed_ord.
            READ TABLE t_processed_ord
                  INTO t_processed_ord
                 INDEX e_row_id-index.
          Call ZSD11 for Customer Search Term
            PERFORM call_zsd11_cust_code USING t_processed_ord-sortl3.
          WHEN 'SORTL4'.
            CLEAR t_flagged_ord.
            READ TABLE t_flagged_ord
                  INTO t_flagged_ord
                 INDEX e_row_id-index.
          Call ZSD11 for Customer Search Term
            PERFORM call_zsd11_cust_code USING t_flagged_ord-sortl4.
          WHEN 'IHREZ_E1'.
            CLEAR t_pre_prod_ord.
            READ TABLE t_pre_prod_ord
                  INTO t_pre_prod_ord
                 INDEX e_row_id-index.
          Call ZSD11 for Mill Order
            PERFORM call_zsd11_millorder USING t_pre_prod_ord-ihrez_e1.
          WHEN 'IHREZ_E2'.
            CLEAR t_delinquent_ord.
            READ TABLE t_delinquent_ord
                  INTO t_delinquent_ord
                 INDEX e_row_id-index.
          Call ZSD11 for Mill Order
            PERFORM call_zsd11_millorder USING t_delinquent_ord-ihrez_e2.
          WHEN 'IHREZ_E3'.
            CLEAR t_processed_ord.
            READ TABLE t_processed_ord
                  INTO t_processed_ord
                 INDEX e_row_id-index.
          Call ZSD11 for Mill Order
            PERFORM call_zsd11_millorder USING t_processed_ord-ihrez_e3.
          WHEN 'IHREZ_E4'.
            CLEAR t_flagged_ord.
            READ TABLE t_flagged_ord
                   INTO t_flagged_ord
                  INDEX e_row_id-index.
          Call ZSD11 for Mill Order
            PERFORM call_zsd11_millorder USING t_flagged_ord-ihrez_e4.
          WHEN 'NOTES1'.
            CLEAR t_pre_prod_ord.
            READ TABLE t_pre_prod_ord
                  INTO t_pre_prod_ord
                 INDEX e_row_id-index.
          Call zsd00087 program to edit CSI Memo Text
            PERFORM edit_notes USING t_pre_prod_ord-salord1.
          WHEN 'NOTES2'.
            CLEAR t_delinquent_ord.
            READ TABLE t_delinquent_ord
                  INTO t_delinquent_ord
                 INDEX e_row_id-index.
          Call zsd00087 program to edit CSI Memo Text
            PERFORM edit_notes USING t_delinquent_ord-salord2.
          WHEN 'NOTES3'.
            CLEAR t_processed_ord.
            READ TABLE t_processed_ord
                  INTO t_processed_ord
                 INDEX e_row_id-index.
          Call zsd00087 program to CSI Memo Text
            PERFORM edit_notes USING t_processed_ord-salord3.
          WHEN 'NOTES4'.
            CLEAR t_flagged_ord.
            READ TABLE t_flagged_ord
                  INTO t_flagged_ord
                 INDEX e_row_id-index.
          Call zsd00087 program to CSI Memo Text
            PERFORM edit_notes USING t_flagged_ord-salord4.
        ENDCASE.                           " CASE E_COLUMN_ID ...
      ENDMETHOD.                           " HANDLE_HOTSPOT
      METHOD handle_top_of_page.
        PERFORM write_report_header.
      ENDMETHOD.                           " METHOD HANDLE_TOP_OF_PAGE
    */ Begin of Modification - Request No. DV2K904687
      METHOD handle_toolbar.
        DATA: ls_toolbar  TYPE stb_button.
      append a separator to normal toolbar
        CLEAR ls_toolbar.
        MOVE 3 TO ls_toolbar-butn_type.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
      append a button for Change Delivery Priority
        MOVE 'CHNG_PRIO' TO ls_toolbar-function.
        MOVE 'Change SO Delivery Priority'(048)
             TO ls_toolbar-quickinfo.
        MOVE 'Change SO Priority'(049) TO ls_toolbar-text.
        MOVE 0 TO ls_toolbar-butn_type.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                           " handle_toolbar
      METHOD handle_user_command.
        DATA: t_sel_row  TYPE lvc_t_roid,
              gs_sel_row TYPE lvc_s_roid,
              gs_flagged_ord LIKE t_flagged_ord,
              lv_lines   TYPE i.
        CASE e_ucomm.
          WHEN 'CHNG_PRIO'.
            REFRESH t_sel_row.
            CLEAR e_ucomm.
            CALL METHOD gv_grid_flagged_ord->get_selected_rows
              IMPORTING
                et_row_no = t_sel_row.
            CLEAR: t_flagged_ord,
                   gv_vbeln,
                   gv_posnr,
                   gv_del_prio.
            DESCRIBE TABLE t_sel_row LINES lv_lines.
            IF lv_lines GT 1.
              MESSAGE i001 WITH 'Select only one row'(043).
            ELSEIF lv_lines EQ 1.
              READ TABLE t_sel_row INTO gs_sel_row INDEX 1.
              READ TABLE t_flagged_ord INTO gs_flagged_ord
                   INDEX gs_sel_row-row_id.
              IF sy-subrc EQ 0.
                SPLIT gs_flagged_ord-salord4 AT '-' INTO gv_vbeln gv_posnr.
                gv_del_prio = gs_flagged_ord-priority.
                CLEAR: s_item, s_item[].
                p_sonum    = gv_vbeln.
                p_delpr    = gv_del_prio.
                s_item-low = gv_posnr.
                APPEND s_item TO s_item.
                CLEAR  s_item.
              ENDIF.                       " IF sy-subrc EQ 0
            ENDIF.                         " IF lv_lines GT 1
            IF lv_lines LE 1.
              CALL SELECTION-SCREEN '1100' STARTING AT 30 2
                                           ENDING   AT 110 7.
              LEAVE TO SCREEN 100.
            ENDIF.
        ENDCASE.                           " CASE e_ucomm
      ENDMETHOD.                           " handle_user_command
    */ End of Modification - Request No. DV2K904687
    ENDCLASS.                              " LCL_EVENT_RECEIVER
    " IMPLEMENTATION
    Form  WRITE_REPORT_HEADER                                            *
    This subroutine displays Report Header which includes                *
    Report Name, Executed by, Execution date, Execution Time             *
    There are no parameters to be passed to this subroutine              *
    FORM write_report_header.
      DATA lv_rep_tit(72) TYPE c.
      FORMAT COLOR COL_KEY.
      MOVE sy-title TO lv_rep_tit.
      CONDENSE lv_rep_tit.
      SKIP 1.
      WRITE: /3  sy-repid,
              25 'California Steel Industries, Inc.'(040),
              75 'Page'(041),
              80(4) sy-pagno.
      WRITE: /3  sy-uzeit,
              25 lv_rep_tit,
              75 sy-datum.
      FORMAT RESET.
    ENDFORM.                               " WRITE_REPORT_HEADER
    At selection-output                                                  *
    AT SELECTION-SCREEN OUTPUT.
      CLEAR sy-ucomm.
      IF sy-dynnr EQ '0500'.
      Initialize layout variant for report-1
        CLEAR gs_var_pre_prod_ord.
        gs_var_pre_prod_ord-report = sy-cprog.
        gs_var_pre_prod_ord-handle = c_handle1.
        PERFORM initialize_layoutvariant CHANGING gs_var_pre_prod_ord.
        p_var1 = gs_var_pre_prod_ord-variant.
      Initialize layout variant for report-2
        CLEAR gs_var_delinquent_ord.
        gs_var_delinquent_ord-report = sy-cprog.
        gs_var_delinquent_ord-handle = c_handle2.
        PERFORM initialize_layoutvariant CHANGING gs_var_delinquent_ord.
        p_var2 = gs_var_delinquent_ord-variant.
      Initialize layout variant for report-3
        CLEAR gs_var_processed_ord.
        gs_var_processed_ord-report = sy-cprog.
        gs_var_processed_ord-handle = c_handle3.
        PERFORM initialize_layoutvariant CHANGING gs_var_processed_ord.
        p_var3 = gs_var_processed_ord-variant.
      Initialize layout variant for report-4
        CLEAR gs_var_flagged_ord.
        gs_var_flagged_ord-report = sy-cprog.
        gs_var_flagged_ord-handle = c_handle4.
        PERFORM initialize_layoutvariant CHANGING gs_var_flagged_ord.
        p_var4 = gs_var_flagged_ord-variant.
    */ Begin of Modification - Request No. DV2K904687
      ELSEIF sy-dynnr EQ '1100'.
        DATA t_exclude  TYPE TABLE OF sy-ucomm.
        SET PF-STATUS 'MENU_1100'.
      To use your own GUI status for a selection screen
        CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
          EXPORTING
            p_status  = 'MENU_1100'
          TABLES
            p_exclude = t_exclude.
      ENDIF.                               " IF sy-dynnr EQ '0500'
    */ End of Modification - Request No. DV2K904687
    At Selection Screen                                                  *
    AT SELECTION-SCREEN.
    */ Begin of Modification - Request No. DV2K904687
      CASE sy-dynnr.
        WHEN '1100'.
          IF sy-ucomm IS INITIAL.
            CLEAR sy-ucomm.
            LEAVE TO SCREEN 1100.
          ENDIF.                           " IF sy-ucomm IS INITIAL
          CASE sy-ucomm.
            WHEN 'SAVE'.
              CLEAR sy-ucomm.
            Change Delivery Priority using BAPI method
              PERFORM change_del_priority.
              CLEAR: sy-ucomm,
                     gv_vbeln,
                     gv_posnr,
                     gv_del_prio,
                     p_sonum,
                     s_item,
                     s_item[],
                     p_delpr.
              LEAVE TO SCREEN 0.
            WHEN 'CANCEL'.
              CLEAR: sy-ucomm,
                     gv_vbeln,
                     gv_posnr,
                     gv_del_prio,
                     p_sonum,
                     s_item,
                     s_item[],
                     p_delpr.
              LEAVE TO SCREEN 0.
          ENDCASE.                         " CASE sy-ucomm
        WHEN '0500'.
          IF sy-ucomm EQ 'CRET'.
            LEAVE TO SCREEN 100.
          ELSEIF sy-ucomm IS INITIAL.
            LEAVE TO SCREEN 500.
          ENDIF.                           " IF SY-UCOMM EQ 'CRET'
      ENDCASE.                             " CASE sy-dynnr
    */ End of Modification - Request No. DV2K904687
    Selection Screen: Validations                                        *
    AT SELECTION-SCREEN ON s_pernr.
    Validate Employee Number
      PERFORM validate_employee_number.
    AT SELECTION-SCREEN ON s_kunnr.
    Validate Customer Number
      IF NOT s_kunnr IS INITIAL.
        PERFORM validate_customer_number.
      ENDIF.                               " IF NOT S_KUNNR IS INITIAL
    AT SELECTION-SCREEN ON s_sortl.
    Validate Search Term
      IF NOT s_sortl IS INITIAL.
        PERFORM validate_search_term.
      ENDIF.                               " IF NOT S_SORTL IS INITIAL
    AT SELECTION-SCREEN ON s_kondm.
    Validate Product
      IF NOT s_kondm IS INITIAL.
        PERFORM validate_product.
      ENDIF.                               " IF NOT S_KONDM IS INITIAL
    Validate p_var1
    AT SELECTION-SCREEN ON p_var1.
      CLEAR gs_var_pre_prod_ord.
      gs_var_pre_prod_ord-report  = sy-cprog.
      gs_var_pre_prod_ord-handle  = c_handle1.
      gs_var_pre_prod_ord-variant = p_var1.
      IF p_var1 IS NOT INITIAL.
        PERFORM validate_variant CHANGING gs_var_pre_prod_ord.
      ENDIF.                               " IF P_VAR1 IS NOT INITIAL
    Validate p_var2
    AT SELECTION-SCREEN ON p_var2.
      CLEAR gs_var_delinquent_ord.
      gs_var_delinquent_ord-report  = sy-cprog.
      gs_var_delinquent_ord-handle  = c_handle2.
      gs_var_delinquent_ord-variant = p_var2.
      IF p_var2 IS NOT INITIAL.
        PERFORM validate_variant CHANGING gs_var_delinquent_ord.
      ENDIF.                               " IF P_VAR2 IS NOT INITIAL
    Validate p_var3
    AT SELECTION-SCREEN ON p_var3.
      CLEAR gs_var_processed_ord.
      gs_var_processed_ord-report  = sy-cprog.
      gs_var_processed_ord-handle  = c_handle3.
      gs_var_processed_ord-variant = p_var3.
      IF p_var3 IS NOT INITIAL.
        PERFORM validate_variant CHANGING gs_var_processed_ord.
      ENDIF.                               " IF P_VAR3 IS NOT INITIAL
    Validate p_var4
    AT SELECTION-SCREEN ON p_var4.
      CLEAR gs_var_flagged_ord.
      gs_var_flagged_ord-report  = sy-cprog.
      gs_var_flagged_ord-handle  = c_handle4.
      gs_var_flagged_ord-variant = p_var4.
      IF p_var4 IS NOT INITIAL.
        PERFORM validate_variant CHANGING gs_var_flagged_ord.
      ENDIF.                               " IF P_VAR4 IS NOT INITIAL
    Selection Screen: Value Request for ALV GRID Variants                *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var1.
      CLEAR gs_var_pre_prod_ord.
      gs_var_pre_prod_ord-report = sy-cprog.
      gs_var_pre_prod_ord-handle = c_handle1.
      PERFORM f4_variant CHANGING gs_var_pre_prod_ord
                                  gv_exit.
      IF gv_exit NE c_true.
        p_var1 = gs_var_pre_prod_ord-variant.
      ENDIF.                               " IF GV_EXIT NE c_true
    F4 help for variant p_var2
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var2.
      CLEAR:
        gs_var_delinquent_ord,
        gv_exit.
      gs_var_delinquent_ord-report = sy-cprog.
      gs_var_delinquent_ord-handle = c_handle2.
      PERFORM f4_variant CHANGING gs_var_delinquent_ord
                                  gv_exit.
      IF gv_exit NE c_true.
        p_var2 = gs_var_delinquent_ord-variant.
      ENDIF.                               " IF GV_EXIT NE c_true
    F4 help for variant p_var3
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var3.
      CLEAR:
        gs_var_processed_ord,
        gv_exit.
      gs_var_processed_ord-report = sy-cprog.
      gs_var_processed_ord-handle = c_handle3.
      PERFORM f4_variant CHANGING gs_var_processed_ord
                                  gv_exit.
      IF gv_exit NE c_true.
        p_var3 = gs_var_processed_ord-variant.
      ENDIF.                               " IF GV_EXIT NE c_true
    F4 help for variant p_var4
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var4.
      CLEAR:
        gs_var_flagged_ord,
        gv_exit.
      gs_var_flagged_ord-report = sy-cprog.
      gs_var_flagged_ord-handle = c_handle4.
      PERFORM f4_variant CHANGING gs_var_flagged_ord
                                  gv_exit.
      IF gv_exit NE c_true.
        p_var4 = gs_var_flagged_ord-variant.
      ENDIF.                               " IF GV_EXIT NE c_true
    Form  validate_employee_number                                       *
    This subroutine validates Employee Number                            *
    There are no parameters to need be passed to this subroutine         *
    FORM validate_employee_number.
      DATA lv_pernr LIKE vbpa-pernr.
      SELECT SINGLE pernr
        INTO lv_pernr
        FROM vbpa
       WHERE pernr IN s_pernr.
      IF sy-subrc NE 0.
        MESSAGE e001 WITH text-010.
      ENDIF.                               " IF SY-SUBRC NE 0
      CLEAR lv_pernr.
    ENDFORM.                               " VALIDATE_EMPLOYEE_NUMBER
    Form  validate_customer_number                                       *
    This subroutine validates Customer Number                            *
    There are no parameters need to be passed to this subroutine         *
    FORM validate_customer_number.
      SELECT SINGLE kunnr
        INTO t_common_data-kunnr
        FROM kna1
       WHERE kunnr IN s_kunnr.
      IF sy-subrc NE 0.
        MESSAGE e001 WITH text-011.
      ENDIF.                               " IF SY-SUBRC NE 0
      CLEAR t_common_data-kunnr.
    ENDFORM.                               " VALIDATE_CUSTOMER_NUMBER
    Form  validate_search_term                                           *
    This subroutine validates Search Term                                *
    There are no parameters need to be passed to this subroutine         *
    FORM validate_search_term.
      SELECT SINGLE sortl
        INTO t_customer_code-sortl
        FROM kna1
       WHERE sortl IN s_sortl.
      IF sy-subrc NE 0.
        MESSAGE e001 WITH text-012.
      ENDIF.                               " IF SY-SUBRC NE 0
      CLEAR t_customer_code-sortl.
    ENDFORM.                               " VALIDATE_SEARCH_TERM
    Form  validate_product                                               *
    This subroutine validates Product                                    *
    There are no parameters need to be passed to this subroutine         *
    FORM validate_product.
      SELECT SINGLE kondm
        INTO t_

  • About Variants in ALV grid

    Hi all,
    I am displaying 4grids on a TAB Strip in ALV
    i have created one variant for each grid(report)
    But when i run the prog and press on F4 help for variant parameter, i am getting variants of all the grids
    Is there any way to get only those variants related to a particular grid.
    thanks in advance

    Hi,
    Specify different variant handles for each of the four grids. Some thing like the following,
    <b>ls_variant-report = <your program name>.</b>
    ****Set following handler different for each grid ****reference
    ****something like 'GRD1', 'GRD2' and so on..
    <b>ls_variant-handle = <your grid handle 4 characters>.</b>
        CALL METHOD ref_grid->set_table_for_first_display
          EXPORTING
          I_BYPASSING_BUFFER            =
          I_BUFFER_ACTIVE               =
          I_CONSISTENCY_CHECK           =
          I_STRUCTURE_NAME              =
    <b>        is_variant                    = ls_variant</b>
            i_save                        = 'A'
          I_DEFAULT                     = 'X'
            is_layout                     = ls_layout
          IS_PRINT                      =
          IT_SPECIAL_GROUPS             =
          it_toolbar_excluding          =
          IT_HYPERLINK                  =
          IT_ALV_GRAPHICS               =
          IT_EXCEPT_QINFO               =
          CHANGING
            it_outtab                     = lt_data
            it_fieldcatalog               = lt_fcat
          IT_SORT                       =
          IT_FILTER                     =
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
    Hope this helps..
    Sri
    Message was edited by: Srikanth Pinnamaneni

  • ALV Grid Dialog Program Variant Problem

    Hi Gurus-
    Please help!!! I got the following problem-
    The ALV dialog screen will have fields with display options as well as a number of fields as input options (editable). Based on user inputs in the input fields and other displayed fields, the user selects "Process"/F8 and it calls the BAPI_MATERIAL_EDIT functions to update material.
    The problem is, I want to use variants in the input fields (Maybe REUSE_ALV_VARIANT_F4) when I select a variant it loops through the selected rows and fills out the input fields with the values stored in the variant. I want to use sample ALV grid program such as BCALV*.
    The question is, can I use variants in ALV grid dialog program and if yes, how do I define variants to loop through and fill out the values in the input/editable fields on the ALV grid?
    Any help will be greatly appreciated! Rep points for sure!
    Thanks!!!

    hi james ,
    look at this link u will get an idea .
    http://www.sapfans.com/forums/viewtopic.php?f=13&t=229912
    http://sgstocks.tripod.com/alvgrid_control.htm
    thanks,
    Gaurav.
    Edited by: gaurav.singh on Apr 20, 2010 7:53 AM

  • ALV Grid to hold sub headings

    Hi,
    Can any one tell me  about the possibility to display sub headings for an ALV grid control i.e to have a group of columns under one column similar to the feature in excel?
    Regards,
    Sujatha

    Hi Sujatha, also check this code.
    REPORT ZALV5_OBJECTS.
    TABLES : EKKO.
    TYPE-POOLS : SLIS.
    TYPES : BEGIN OF TY_EKKO,
    EBELN TYPE EKPO-EBELN,
    EBELP TYPE EKPO-EBELP,
    STATU TYPE EKPO-STATU,
    AEDAT TYPE EKPO-AEDAT,
    MATNR TYPE EKPO-MATNR,
    MENGE TYPE EKPO-MENGE,
    MEINS TYPE EKPO-MEINS,
    NETPR TYPE EKPO-NETPR,
    PEINH TYPE EKPO-PEINH,
    END OF TY_EKKO.
    DATA: IT_EKKO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,
    IT_EKPO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,
    IT_EMPTYTAB TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,
    WA_EKKO TYPE TY_EKKO,
    WA_EKPO TYPE TY_EKKO.
    DATA: OK_CODE LIKE SY-UCOMM, "OK-Code
    SAVE_OK LIKE SY-UCOMM.
    *ALV data declarations
    DATA: FIELDCATALOG TYPE LVC_T_FCAT WITH HEADER LINE.
    DATA: GD_FIELDCAT TYPE LVC_T_FCAT,
    GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV,
    GD_LAYOUT TYPE SLIS_LAYOUT_ALV.
    *ALVtree data declarations
    CLASS CL_GUI_COLUMN_TREE DEFINITION LOAD.
    CLASS CL_GUI_CFW DEFINITION LOAD.
    DATA: GD_TREE TYPE REF TO CL_GUI_ALV_TREE,
    GD_HIERARCHY_HEADER TYPE TREEV_HHDR,
    GD_REPORT_TITLE TYPE SLIS_T_LISTHEADER,
    GD_LOGO TYPE SDYDO_VALUE,
    GD_VARIANT TYPE DISVARIANT.
    *Create container for alv-tree
    DATA: GD_TREE_CONTAINER_NAME(30) TYPE C,
    GD_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    *Includes
    *INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules
    *INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules
    *INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)
    *Start-of-selection.
    START-OF-SELECTION.
    ALVtree setup data
    PERFORM DATA_RETRIEVAL.
    PERFORM BUILD_FIELDCATALOG.
    PERFORM BUILD_LAYOUT.
    PERFORM BUILD_HIERARCHY_HEADER CHANGING GD_HIERARCHY_HEADER.
    PERFORM BUILD_REPORT_TITLE USING GD_REPORT_TITLE GD_LOGO.
    PERFORM BUILD_VARIANT.
    Display ALVtree report
    CALL SCREEN 100.
    *& Form data_retrieval
    text
    --> p1 text
    <-- p2 text
    FORM DATA_RETRIEVAL .
    SELECT EBELN
    UP TO 10 ROWS
    FROM EKKO
    INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.
    LOOP AT IT_EKKO INTO WA_EKKO.
    SELECT EBELN EBELP STATU AEDAT MATNR MENGE MEINS NETPR PEINH
    FROM EKPO
    APPENDING TABLE IT_EKPO
    WHERE EBELN EQ WA_EKKO-EBELN.
    ENDLOOP.
    ENDFORM. " data_retrieval
    *& Form build_fieldcatalog
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_FIELDCATALOG .
    Please not there are a number of differences between the structure of
    ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
    For example the field seltext_m is replace by scrtext_m in ALVtree.
    FIELDCATALOG-FIELDNAME = 'EBELN'. "Field name in itab
    FIELDCATALOG-SCRTEXT_M = 'Purchase Order'. "Column text
    FIELDCATALOG-COL_POS = 0. "Column position
    FIELDCATALOG-OUTPUTLEN = 15. "Column width
    FIELDCATALOG-EMPHASIZE = 'X'. "Emphasize (X or SPACE)
    FIELDCATALOG-KEY = 'X'. "Key Field? (X or SPACE)
    fieldcatalog-do_sum = 'X'. "Sum Column?
    fieldcatalog-no_zero = 'X'. "Don't display if zero
    APPEND FIELDCATALOG TO GD_FIELDCAT.
    CLEAR FIELDCATALOG.
    FIELDCATALOG-FIELDNAME = 'EBELP'.
    FIELDCATALOG-SCRTEXT_M = 'PO Iten'.
    FIELDCATALOG-OUTPUTLEN = 15.
    FIELDCATALOG-COL_POS = 1.
    APPEND FIELDCATALOG TO GD_FIELDCAT..
    CLEAR FIELDCATALOG.
    FIELDCATALOG-FIELDNAME = 'STATU'.
    FIELDCATALOG-SCRTEXT_M = 'Status'.
    FIELDCATALOG-OUTPUTLEN = 15.
    FIELDCATALOG-COL_POS = 2.
    APPEND FIELDCATALOG TO GD_FIELDCAT..
    CLEAR FIELDCATALOG.
    FIELDCATALOG-FIELDNAME = 'AEDAT'.
    FIELDCATALOG-SCRTEXT_M = 'Item change date'.
    FIELDCATALOG-OUTPUTLEN = 15.
    FIELDCATALOG-COL_POS = 3.
    APPEND FIELDCATALOG TO GD_FIELDCAT..
    CLEAR FIELDCATALOG.
    FIELDCATALOG-FIELDNAME = 'MATNR'.
    FIELDCATALOG-SCRTEXT_M = 'Material Number'.
    FIELDCATALOG-OUTPUTLEN = 15.
    FIELDCATALOG-COL_POS = 4.
    APPEND FIELDCATALOG TO GD_FIELDCAT..
    CLEAR FIELDCATALOG.
    FIELDCATALOG-FIELDNAME = 'MENGE'.
    FIELDCATALOG-SCRTEXT_M = 'PO quantity'.
    FIELDCATALOG-OUTPUTLEN = 15.
    FIELDCATALOG-COL_POS = 5.
    APPEND FIELDCATALOG TO GD_FIELDCAT..
    CLEAR FIELDCATALOG.
    FIELDCATALOG-FIELDNAME = 'MEINS'.
    FIELDCATALOG-SCRTEXT_M = 'Order Unit'.
    FIELDCATALOG-OUTPUTLEN = 15.
    FIELDCATALOG-COL_POS = 6.
    APPEND FIELDCATALOG TO GD_FIELDCAT..
    CLEAR FIELDCATALOG.
    FIELDCATALOG-FIELDNAME = 'NETPR'.
    FIELDCATALOG-SCRTEXT_M = 'Net Price'.
    FIELDCATALOG-OUTPUTLEN = 15.
    FIELDCATALOG-COL_POS = 7.
    FIELDCATALOG-DATATYPE = 'CURR'.
    APPEND FIELDCATALOG TO GD_FIELDCAT..
    CLEAR FIELDCATALOG.
    FIELDCATALOG-FIELDNAME = 'PEINH'.
    FIELDCATALOG-SCRTEXT_M = 'Price Unit'.
    FIELDCATALOG-OUTPUTLEN = 15.
    FIELDCATALOG-COL_POS = 8.
    APPEND FIELDCATALOG TO GD_FIELDCAT..
    CLEAR FIELDCATALOG.
    ENDFORM. " build_fieldcatalog
    *& Form build_layout
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_LAYOUT .
    GD_LAYOUT-NO_INPUT = 'X'.
    GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).
    gd_layout-totals_only = 'X'.
    gd_layout-f2code = 'DISP'. "Sets fcode for when double
    "click(press f2)
    gd_layout-zebra = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text = 'helllllo'
    ENDFORM. " build_layout
    *& Form build_hierarchy_header
    text
    <--P_GD_HIERARCHY_HEADER text
    FORM BUILD_HIERARCHY_HEADER CHANGING
    P_HIERARCHY_HEADER TYPE TREEV_HHDR.
    P_HIERARCHY_HEADER-HEADING = 'Hierarchy Header'(013).
    P_HIERARCHY_HEADER-TOOLTIP = 'This is the Hierarchy Header !'(014).
    P_HIERARCHY_HEADER-WIDTH = 30.
    P_HIERARCHY_HEADER-WIDTH_PIX = ''.
    ENDFORM. " build_hierarchy_header
    *& Form build_report_title
    text
    -->P_GD_REPORT_TITLE text
    -->P_GD_LOGO text
    FORM BUILD_REPORT_TITLE USING PT_REPORT_TITLE TYPE SLIS_T_LISTHEADER
    P_GD_LOGO TYPE SDYDO_VALUE.
    DATA: LS_LINE TYPE SLIS_LISTHEADER,
    LD_DATE(10) TYPE C.
    List Heading Line(TYPE H)
    CLEAR LS_LINE.
    LS_LINE-TYP = 'H'.
    ls_line-key "Not Used For This Type(H)
    LS_LINE-INFO = 'PO ALVTree Display'.
    APPEND LS_LINE TO PT_REPORT_TITLE.
    Status Line(TYPE S)
    LD_DATE(2) = SY-DATUM+6(2).
    LD_DATE+2(1) = '/'.
    LD_DATE3(2) = SY-DATUM4(2).
    LD_DATE+5(1) = '/'.
    LD_DATE+6(4) = SY-DATUM(4).
    LS_LINE-TYP = 'S'.
    LS_LINE-KEY = 'Date'.
    LS_LINE-INFO = LD_DATE.
    APPEND LS_LINE TO PT_REPORT_TITLE.
    Action Line(TYPE A)
    CLEAR LS_LINE.
    LS_LINE-TYP = 'A'.
    CONCATENATE 'Report: ' SY-REPID INTO LS_LINE-INFO SEPARATED BY SPACE.
    APPEND LS_LINE TO PT_REPORT_TITLE.
    ENDFORM. " build_report_title
    *& Form build_variant
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_VARIANT .
    Set repid for storing variants
    GD_VARIANT-REPORT = SY-REPID.
    ENDFORM. " build_variant
    cheers,
    Hema.

  • How to use ALV Grid?

    Hi,
    I am totally new to ALV Grids. Could you give a full example of creating a ALV Grid with 2 columns, thinking there is a internal table itab with itab-col1 & itab-col2. Please start from initialising variables and onwards.
    Thanks,
    Kishan

    Hi,
    Simple example of how to implement an ALV grid
    Note that this example uses table ZSFLIGHT. The table is equivalent to the table SFLIGHT.
    Steps:
    1.        Create an executable program (Report)
    2.        Create a screen (100) and place a custom container named ALV_CONTAINER on the screen
    3.        Create a Pushbutton. Give it the text Exit and the functioncode EXIT
    REPORT sapmz_hf_alv_grid .
    TABLES: zsflight.
    G L O B A L   I N T E R N  A L   T A B L E S
    DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
    G L O B A L   D A T A
    DATA: ok_code LIKE sy-ucomm,
    g_wa_sflight LIKE sflight.
    Declare reference variables to the ALV grid and the container
    DATA:
    go_grid             TYPE REF TO cl_gui_alv_grid,
    go_custom_container TYPE REF TO cl_gui_custom_container.
    S T A R T - O F - S E L E C T I O N.
    START-OF-SELECTION.
    SET SCREEN '100'.
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE user_command_0100 INPUT.
    CASE ok_code.
    WHEN 'EXIT'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
    Create objects
    IF go_custom_container IS INITIAL.
    CREATE OBJECT go_custom_container
    EXPORTING container_name = 'ALV_CONTAINER'.
    CREATE OBJECT go_grid
    EXPORTING
      i_parent = go_custom_container.
    PERFORM load_data_into_grid.
    ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Form  load_data_into_grid
    FORM load_data_into_grid.
    Read data from table SFLIGHT
    SELECT *
    FROM zsflight
    INTO TABLE gi_sflight.
    Load data into the grid and display them
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING i_structure_name = 'SFLIGHT'
    CHANGING  it_outtab        = gi_sflight.
    ENDFORM.                    " load_data_into_grid
    Allow the user to save and reuse the layout
    A button can be shown on the grid toolbar, allowing the user to save and reuse a layout. The button looks like this: 
    See also example in SAP standard program BCALV_GRID_09.
    To do this use the parameters IS_VARIANT and I_SAVE of the set_table_for_first_display method. Note that the IS_VARIANT
    parameter must have the structure DISVARIANT.
    The I_SAVE "Options for saving layouts" parameter can have the following values:
    ·        U Only user specific layouts can be saved
    ·        X Only global layouts can be saved
    ·        A Both user specific and global layouts can be saved
    ·        Space Layouts can not be saved
    Add the following code to the example:
    FORM load_data_into_grid.
    DATA:
      For parameter IS_VARIANT
    l_layout TYPE disvariant.
    Code..........    
    Load data into the grid and display them
    l_layout-report = sy-repid.
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING i_structure_name = 'SFLIGHT'
         is_variant       = l_layout
         i_save           = 'A'
    CHANGING  it_outtab        = gi_
    Integrate user defined functions in the grid toolbar
    Possibilities:
    ·        Replace existing functions in the toolbar or context men with user defined functions
    ·        Add new functions to the toolbar or context menu
    Note that the whole toolbar can be removed using the IT_TOOLBAR_EXCLUDING parameter of the set_table_for_first_display
    method.
    See also example in SAP standard program BCALV_GRID_05
    1) To get access to the icons insert the following statement in the top of the program:
    TYPE-POOLS: icon.
    2) To allow the declaration of o_event_receiver before the lcl_event_receiver class is defined, declare it as deferred in the start of
    the program
    To allow the declaration of o_event_receiver before the lcl_event_receiver class is defined, declare it as deferred in the
    start of the program
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    3) Declare reference to the event handler class
    DATA:
    o_event_receiver TYPE REF TO lcl_event_receiver.
    4) Class for event receiver. This class adds the new button to the toolbar and handles the event when the button is pushed
    CLASS lcl_event_receiver DEFINITION.
    PUBLIC SECTION.
    METHODS:
    handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
    IMPORTING
    e_object e_interactive,
    handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
    IMPORTING e_ucomm.
    ENDCLASS.
          CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
    METHOD handle_toolbar.
    Event handler method for event toolbar.
    CONSTANTS:
    Constants for button type
    c_button_normal           TYPE i VALUE 0,
    c_menu_and_default_button TYPE i VALUE 1,
    c_menu                    TYPE i VALUE 2,
    c_separator               TYPE i VALUE 3,
    c_radio_button            TYPE i VALUE 4,
    c_checkbox                TYPE i VALUE 5,
    c_menu_entry              TYPE i VALUE 6.
    DATA:
    ls_toolbar  TYPE stb_button.
      Append seperator to the normal toolbar
    CLEAR ls_toolbar.
    MOVE c_separator TO ls_toolbar-butn_type..
    APPEND ls_toolbar TO e_object->mt_toolbar.
      Append a new button that to the toolbar. Use E_OBJECT of
      event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
      This class has one attribute MT_TOOLBAR which is of table type
      TTB_BUTTON. The structure is STB_BUTTON
    CLEAR ls_toolbar.
    MOVE 'CHANGE'        TO ls_toolbar-function.
    MOVE  icon_change    TO ls_toolbar-icon.
    MOVE 'Change flight' TO ls_toolbar-quickinfo.
    MOVE 'Change'        TO ls_toolbar-text.
    MOVE ' '             TO ls_toolbar-disabled.
    APPEND ls_toolbar    TO e_object->mt_toolbar.
    ENDMETHOD.
    METHOD handle_user_command.
      Handle own functions defined in the toolbar
    CASE e_ucomm.
    WHEN 'CHANGE'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMETHOD.
    ENDCLASS.
    5) In the PBO module, crate object for event handler and set handler
    CREATE OBJECT o_event_receiver.
    SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
    SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
    6) In the PBO module after the CALL METHOD go_grid->set_table_for_first_display, raise event
    toolbar to show the modified toolbar
    CALL METHOD go_grid->set_toolbar_interactive.
    Set focus to the grid
    After CALL METHOD go_grid->set_table_for_first_display insert the following statement:
    CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
    Set the title of the grid
    Fill the grid_title field of structure lvc_s_layo.
    Note that the structure lvc_s_layo can be used for to customize the grid appearance in many ways.
    DATA:
    ALV control: Layout structure
    gs_layout TYPE lvc_s_layo.
    Set grid title
    gs_layout-grid_title = 'Flights'.
    CALL METHOD go_grid->set_table_for_first_display
       EXPORTING i_structure_name = 'SFLIGHT'
                               is_layout               = gs_layout
       CHANGING   it_outtab               = gi_sflight.
    Customize the appearence of the grid
    The structure lvc_s_layo contains fields for setting graphical properties, displaying exceptions, calculating totals and enabling specific
    interaction options.
    Fill the apporpiate fields of structure lvc_s_layo and insert it as a parameter in the CALL METHOD
    go_grid->set_table_for_first_display. See the example under Set the title of the grid.
    If you want to change apperance after list output, use the methods get_frontend_layout and set_frontend_layout.
    Examples of fields in structure lvc_s_layo:
    GRID_TITLE Setting the title of the grid
    SEL_MODE. Selection mode, determines how rows can be selected. Can have the following values:
    ·        A Multiple columns, multiple rows with selection buttons.
    ·        B Simple selection, listbox, Single row/column
    ·        C Multiple rows without buttons
    ·        D Multiple rows with buttons and select all ICON
    Setting and getting selected rows (Columns) and read line contents
    You can read which rows of the grid that has been selected, and dynamic select rows of the grid using methods get_selected_rows
    and set_selected_rows. There are similar methods for columns.
    Note that the grid table always has the rows in the same sequence as displayed in the grid, thus you can use the index of the selected
    row(s) to read the information in the rows from the table. In the examples below the grid table is named gi_sflight.
    Data declaration:
    DATA:
    Internal table for indexes of selected rows
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    Example 1: Reading index of selected row(s) and using it to read the grid table
    CALL METHOD go_grid->get_selected_rows
    IMPORTING
    et_index_rows = gi_index_rows.
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines = 0.
    CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
    EXPORTING
         textline1 = 'You must choose a valid line'.
    EXIT.
    ENDIF.
    LOOP AT gi_index_rows INTO g_selected_row.
    READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
    ENDIF.
    ENDLOOP.
    Example 2: Set selected row(s).
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines > 0.
    CALL METHOD go_grid->set_selected_rows
    exporting
    it_index_rows = gi_index_rows.
    ENDIF.
    Make an Exception field ( = Traffic lights)
    There can be defined a column in the grid for display of traffic lights. This field is of type Char 1, and can contain the following values:
    ·        1 Red
    ·        2 Yellow
    ·        3 Green
    The name of the traffic light field is supplied inh the gs_layout-excp_fname used by method set_table_for_first_display.
    Example
    TYPES: BEGIN OF st_sflight.
    INCLUDE STRUCTURE zsflight.
    TYPES:  traffic_light TYPE c.
    TYPES: END OF st_sflight.
    TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
    DATA: gi_sflight TYPE tt_sflight.
      Set the exception field of the table
    LOOP AT gi_sflight INTO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    g_wa_sflight-traffic_light = '1'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
        g_wa_sflight-paymentsum < 1000000.
    g_wa_sflight-traffic_light = '2'.
    ELSE.
    g_wa_sflight-traffic_light = '3'.
    ENDIF.
    MODIFY gi_sflight FROM g_wa_sflight.
    ENDLOOP.
      Name of the exception field (Traffic light field)
    gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
      Grid setup for first display
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING i_structure_name = 'SFLIGHT'
                         is_layout               = gs_layout
    CHANGING  it_outtab                 = gi_sflight.
    Color a line
    The steps for coloring a line i the grid is much the same as making a traffic light.
    To color a line the structure of the  table must include a  Char 4 field  for color properties
    TYPES: BEGIN OF st_sflight.
    INCLUDE STRUCTURE zsflight.
          Field for line color
    types:  line_color(4) type c.
    TYPES: END OF st_sflight.
    TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
    DATA: gi_sflight TYPE tt_sflight.
    Loop trough the table to set the color properties of each line. The color properties field is
    Char 4 and the characters is set as follows:
    Char 1 = C = This is a color property
    Char 2 = 6 = Color code (1 - 7)
    Char 3 = Intensified on/of = 1 = on
    Char 4 = Inverse display = 0 = of
    LOOP AT gi_sflight INTO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    g_wa_sflight-line_color    = 'C610'.
    ENDIF.
    MODIFY gi_sflight FROM g_wa_sflight.
    ENDLOOP.
    Name of the color field
    gs_layout-info_fname = 'LINE_COLOR'.
    Grid setup for first display
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING i_structure_name = 'SFLIGHT'
                        is_layout                = gs_layout
    CHANGING  it_outtab                 = gi_sflight.
    Refresh grid display
    Use the grid method REFRESH_TABLE_DISPLAY
    Example:
    CALL METHOD go_grid->refresh_table_display.
    Complete code for the ALV grid example
    This example shows and ALV grid with flights. After selecting a line a change button can be pushed to display a change screen. After
    the changes have been saved, the ALV grid screen is displayed again, and the grid is updated with the changes.
    The example shows:
    ·        How to setup the ALV grid
    ·        How to ste focus to the grid
    ·        How to set the title of the grid
    ·        How to allow a user to save and reuse a grid layout (Variant)
    ·        How to customize the ALV grid toolbar
    ·        Refresh the grid
    ·        Set and get row selection and read line contents
    ·        Make and exception field (Traffic light)
    ·        Coloring a line
    Steps:
    ·        Create screen 100 with the ALV grid. Remember to include an exit button
    ·        Add a change button to the ALV grid toolbar
    ·        Create screen 200 the Change screen
    The screens: 
    The code:
    REPORT sapmz_hf_alv_grid .
    Type pool for icons - used in the toolbar
    TYPE-POOLS: icon.
    TABLES: zsflight.
    To allow the declaration of o_event_receiver before the
    lcl_event_receiver class is defined, decale it as deferred in the
    start of the program
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    G L O B A L   I N T E R N  A L   T A B L E S
    *DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
    To include a traffic light and/or color a line the structure of the
    table must include fields for the traffic light and/or the color
    TYPES: BEGIN OF st_sflight.
      INCLUDE STRUCTURE zsflight.
          Field for traffic light
    TYPES:  traffic_light TYPE c.
          Field for line color
    types:  line_color(4) type c.
    TYPES: END OF st_sflight.
    TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
    DATA: gi_sflight TYPE tt_sflight.
    G L O B A L   D A T A
    DATA: ok_code         LIKE sy-ucomm,
        Work area for internal table
    g_wa_sflight    TYPE st_sflight,
        ALV control: Layout structure
    gs_layout       TYPE lvc_s_layo.
    Declare reference variables to the ALV grid and the container
    DATA:
    go_grid             TYPE REF TO cl_gui_alv_grid,
    go_custom_container TYPE REF TO cl_gui_custom_container,
    o_event_receiver    TYPE REF TO lcl_event_receiver.
    DATA:
    Work area for screen 200
    g_screen200 LIKE zsflight.
    Data for storing information about selected rows in the grid
    DATA:
    Internal table
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    C L A S S E S
    CLASS lcl_event_receiver DEFINITION.
    PUBLIC SECTION.
    METHODS:
    handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
    IMPORTING
       e_object e_interactive,
    handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
    IMPORTING e_ucomm.
    ENDCLASS.
          CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
    METHOD handle_toolbar.
    Event handler method for event toolbar.
    CONSTANTS:
    Constants for button type
    c_button_normal           TYPE i VALUE 0,
    c_menu_and_default_button TYPE i VALUE 1,
    c_menu                    TYPE i VALUE 2,
    c_separator               TYPE i VALUE 3,
    c_radio_button            TYPE i VALUE 4,
    c_checkbox                TYPE i VALUE 5,
    c_menu_entry              TYPE i VALUE 6.
    DATA:
      ls_toolbar  TYPE stb_button.
      Append seperator to the normal toolbar
    CLEAR ls_toolbar.
    MOVE c_separator TO ls_toolbar-butn_type..
    APPEND ls_toolbar TO e_object->mt_toolbar.
      Append a new button that to the toolbar. Use E_OBJECT of
      event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
      This class has one attribute MT_TOOLBAR which is of table type
      TTB_BUTTON. The structure is STB_BUTTON
    CLEAR ls_toolbar.
    MOVE 'CHANGE'        TO ls_toolbar-function.
    MOVE  icon_change    TO ls_toolbar-icon.
    MOVE 'Change flight' TO ls_toolbar-quickinfo.
    MOVE 'Change'        TO ls_toolbar-text.
    MOVE ' '             TO ls_toolbar-disabled.
    APPEND ls_toolbar    TO e_object->mt_toolbar.
    ENDMETHOD.
    METHOD handle_user_command.
      Handle own functions defined in the toolbar
    CASE e_ucomm.
    WHEN 'CHANGE'.
      PERFORM change_flight.
           LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMETHOD.
    ENDCLASS.
    S T A R T - O F - S E L E C T I O N.
    START-OF-SELECTION.
    SET SCREEN '100'.
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE user_command_0100 INPUT.
    CASE ok_code.
    WHEN 'EXIT'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
    DATA:
      For parameter IS_VARIANT that is sued to set up options for storing
      the grid layout as a variant in method set_table_for_first_display
    l_layout TYPE disvariant,
      Utillity field
    l_lines TYPE i.
    After returning from screen 200 the line that was selected before
    going to screen 200, should be selected again. The table gi_index_rows
    was the output table from the GET_SELECTED_ROWS method in form
    CHANGE_FLIGHT
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines > 0.
    CALL METHOD go_grid->set_selected_rows
      EXPORTING
        it_index_rows = gi_index_rows.
    CALL METHOD cl_gui_cfw=>flush.
    REFRESH gi_index_rows.
    ENDIF.
    Read data and create objects
    IF go_custom_container IS INITIAL.
      Read data from datbase table
    PERFORM get_data.
      Create objects for container and ALV grid
    CREATE OBJECT go_custom_container
    EXPORTING container_name = 'ALV_CONTAINER'.
    CREATE OBJECT go_grid
    EXPORTING
      i_parent = go_custom_container.
      Create object for event_receiver class
      and set handlers
    CREATE OBJECT o_event_receiver.
    SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
    SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
      Layout (Variant) for ALV grid
    l_layout-report = sy-repid. "Layout fo report
    Setup the grid layout using a variable of structure lvc_s_layo
      Set grid title
    gs_layout-grid_title = 'Flights'.
      Selection mode - Single row without buttons
      (This is the default  mode
    gs_layout-sel_mode = 'B'.
      Name of the exception field (Traffic light field) and the color
      field + set the exception and color field of the table
    gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
    gs_layout-info_fname = 'LINE_COLOR'.
    LOOP AT gi_sflight INTO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
          Value of traffic light field
      g_wa_sflight-traffic_light = '1'.
          Value of color field:
          C = Color, 6=Color 1=Intesified on, 0: Inverse display off
      g_wa_sflight-line_color    = 'C610'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
           g_wa_sflight-paymentsum < 1000000.
      g_wa_sflight-traffic_light = '2'.
    ELSE.
      g_wa_sflight-traffic_light = '3'.
    ENDIF.
    MODIFY gi_sflight FROM g_wa_sflight.
    ENDLOOP.
      Grid setup for first display
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING i_structure_name = 'SFLIGHT'
              is_variant       = l_layout
              i_save           = 'A'
              is_layout        = gs_layout
    CHANGING  it_outtab        = gi_sflight.
    *-- End of grid setup -
      Raise event toolbar to show the modified toolbar
    CALL METHOD go_grid->set_toolbar_interactive.
      Set focus to the grid. This is not necessary in this
      example as there is only one control on the screen
    CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
    ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
    MODULE user_command_0200 INPUT.
    CASE ok_code.
    WHEN 'EXIT200'.
    LEAVE TO SCREEN 100.
    WHEN'SAVE'.
    PERFORM save_changes.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0200  INPUT
    *&      Form  get_data
    FORM get_data.
    Read data from table SFLIGHT
    SELECT *
    FROM zsflight
    INTO TABLE gi_sflight.
    ENDFORM.                    " load_data_into_grid
    *&      Form  change_flight
    Reads the contents of the selected row in the grid, ans transfers
    the data to screen 200, where it can be changed and saved.
    FORM change_flight.
    DATA:l_lines TYPE i.
    REFRESH gi_index_rows.
    CLEAR   g_selected_row.
    Read index of selected rows
    CALL METHOD go_grid->get_selected_rows
    IMPORTING
    et_index_rows = gi_index_rows.
    Check if any row are selected at all. If not
    table  gi_index_rows will be empty
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines = 0.
    CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
       EXPORTING
            textline1 = 'You must choose a line'.
    EXIT.
    ENDIF.
    Read indexes of selected rows. In this example only one
    row can be selected as we are using gs_layout-sel_mode = 'B',
    so it is only ncessary to read the first entry in
    table gi_index_rows
    LOOP AT gi_index_rows INTO g_selected_row.
    IF sy-tabix = 1.
    READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
    ENDIF.
    ENDLOOP.
    Transfer data from the selected row to screenm 200 and show
    screen 200
    CLEAR g_screen200.
    MOVE-CORRESPONDING g_wa_sflight TO g_screen200.
    LEAVE TO SCREEN '200'.
    ENDFORM.                    " change_flight
    *&      Form  save_changes
    Changes made in screen 200 are written to the datbase table
    zsflight, and to the grid table gi_sflight, and the grid is
    updated with method refresh_table_display to display the changes
    FORM save_changes.
    DATA: l_traffic_light TYPE c.
    Update traffic light field
    Update database table
    MODIFY zsflight FROM g_screen200.
    Update grid table , traffic light field and color field.
    Note that it is necessary to use structure g_wa_sflight
    for the update, as the screen structure does not have a
    traffic light field
    MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    g_wa_sflight-traffic_light = '1'.
      C = Color, 6=Color 1=Intesified on, 0: Inverse display off
    g_wa_sflight-line_color    = 'C610'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
       g_wa_sflight-paymentsum < 1000000.
    g_wa_sflight-traffic_light = '2'.
    clear g_wa_sflight-line_color.
    ELSE.
    g_wa_sflight-traffic_light = '3'.
    clear g_wa_sflight-line_color.
    ENDIF.
    MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.
    Refresh grid
    CALL METHOD go_grid->refresh_table_display.
    CALL METHOD cl_gui_cfw=>flush.
    LEAVE TO SCREEN '100'.
    ENDFORM.                    " save_changes
    rgds,
    latheesh

  • First try with ALV Grid and Abap Objects

    Hi,
    this is my first try to write a simple report which just reads a textfile and display it in an ALV Grid. As a basis, I used some examples from SDN, but it did not work as expected
    I would like just to use a docking container. I do not need a separate area for the ALV Grid. The report gives no syntax errors, but it just display the report title, nothing else. SAP R/3 Release is 4.7. Below is the source code of the report. Any idea what is missing?
    *& Report  Z_PLAN_TEXT_UPLOAD                                          *
    REPORT z_plan_text_upload.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_dynnr TYPE sy-dynnr,
      gf_repid TYPE sy-repid.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)           TYPE c,
        kostenstelle(20)    TYPE c,
        datenart1(10)       TYPE c,
        planjahr(10)        TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)      TYPE c,
        datenart2(10)       TYPE c,
        planungposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)       TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)      TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Local Class Definition
    * Local Class Implementation
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    SKIP.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SKIP.
    PARAMETERS:
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn.
    SELECTION-SCREEN END OF BLOCK b1.
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
      gf_dynnr = sy-dynnr.
      gf_repid = sy-repid.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 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.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog
        CHANGING gt_fieldcat.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
    *      PARENT                      =
            repid                       = gf_repid
            dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *      EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
    *      RATIO                       =
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 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.
      ENDIF."go_docking_container IS INITIAL
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid IS INITIAL.
        CREATE OBJECT go_alv_grid
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid is initial
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Kostenstelle' .
      ls_fcat-seltext = 'Kostenstelle' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog

    I have added some more functionality to my report. The good thing is, the report works as it should.
    BUT, I'm not really sure, whether this is a good (correct) design. The report works the following way:
    1. Read planning data form text file into internal table
    2. Display the internal table
    3. Convert the data and display the converted result
    4. Post the converted data to the system
    5. Display log with messages
    The main thing is, I would like to know, do i really need two dynros, to display the two different internal tables or is it possible just to use one ALV-Grid? I was not able to find another solution. Any comment or help to the report is appreciated.
    *& Report  Z_PLAN_TEXT_UPLOAD_TEST                                     *
    REPORT z_plan_text_upload_test.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_okcode TYPE ui_func,
      gf_balloghndl TYPE balloghndl.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid_0100 TYPE REF TO cl_gui_alv_grid,
      go_alv_grid_0200 TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)            TYPE c,
        kostenstelle(20)     TYPE c,
        datenart1(10)        TYPE c,
        planjahr(10)         TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)       TYPE c,
        datenart2(10)        TYPE c,
        planungsposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)        TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)       TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Bapi Strukturen
    DATA:
      gs_headerinfo TYPE bapiplnhdr,
      gt_indexstructure TYPE TABLE OF bapiacpstru,
      gs_indexstructure LIKE LINE OF gt_indexstructure,
      gt_coobject TYPE TABLE OF bapipcpobj,
      gs_coobject LIKE LINE OF gt_coobject,
      gt_pervalue TYPE TABLE OF bapipcpval,
      gs_pervalue LIKE LINE OF gt_pervalue,
      gt_return TYPE TABLE OF bapiret2,
      gs_return LIKE LINE OF gt_return,
      gt_control TYPE TABLE OF bapipcpctrl,
      gt_totvalue TYPE TABLE OF bapipcptot.
    TYPES:
      BEGIN OF gy_bapi_input,
        version      TYPE versn,
    *    perio       TYPE co_perio,
        fisc_year    TYPE gjahr,
        coobject(10) TYPE c,
        cost_elem    TYPE kstar,
        wkgbtr01     TYPE wkgxxx,
        wkgbtr02     TYPE wkgxxx,
        wkgbtr03     TYPE wkgxxx,
        wkgbtr04     TYPE wkgxxx,
        wkgbtr05     TYPE wkgxxx,
        wkgbtr06     TYPE wkgxxx,
        wkgbtr07     TYPE wkgxxx,
        wkgbtr08     TYPE wkgxxx,
        wkgbtr09     TYPE wkgxxx,
        wkgbtr10     TYPE wkgxxx,
        wkgbtr11     TYPE wkgxxx,
        wkgbtr12     TYPE wkgxxx,
      END OF gy_bapi_input.
    DATA:
      gt_bapi_input TYPE TABLE OF gy_bapi_input,
      gs_bapi_input LIKE LINE OF gt_bapi_input.
    * Anwendungs-Log
    DATA: gs_balsmsg TYPE bal_s_msg.
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SELECTION-SCREEN SKIP.
    PARAMETERS:
      gp_kokrs  LIKE coep-kokrs,
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn,
      gp_test AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b1.
    * Local Class Definition
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar_0100 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0100 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm,
        handle_toolbar_0200 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0200 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    * Local Class Implementation
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD handle_toolbar_0100.
        PERFORM handle_toolbar_0100
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0100.
        PERFORM handle_user_command_0100
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
      METHOD handle_toolbar_0200.
        PERFORM handle_toolbar_0200
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0200.
        PERFORM handle_user_command_0200
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      PERFORM create_log.
      gs_return-type = 'I'.
      IF gp_test = 'X'.
        gs_return-message = text-010.
      ELSE.
        gs_return-message = text-020.
      ENDIF.
      PERFORM add_log_message_free_text
        USING
           gs_return-type
           gs_return-message.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
        gs_balsmsg-msgty = sy-msgty.
        gs_balsmsg-msgid = sy-msgid.
        gs_balsmsg-msgno = sy-msgno.
        gs_balsmsg-msgv1 = sy-msgv1.
        gs_balsmsg-msgv2 = sy-msgv2.
        gs_balsmsg-msgv3 = sy-msgv3.
        gs_balsmsg-msgv4 = sy-msgv4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDIF.
      CALL SCREEN '0100'.
    *&      Module  status_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 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.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999  "full-screen size !!!
          EXCEPTIONS
            cntl_error = 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.
      ENDIF."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog_input
        CHANGING gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0100 IS INITIAL.
        CREATE OBJECT go_alv_grid_0100
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid_0100 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0100 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0100.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0100->handle_toolbar_0100
        FOR go_alv_grid_0100.
      SET HANDLER go_event_handler_0100->handle_user_command_0100
        FOR go_alv_grid_0100.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0100->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0100->set_toolbar_interactive.
    ENDMODULE.                 " status_0100  OUTPUT
    *&      Module  status_0200  OUTPUT
    *       text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 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.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999
          EXCEPTIONS
            cntl_error = 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.
      ENDIF."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0200'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog---------------------------------------*
      PERFORM build_fieldcatalog_bapi_input
        CHANGING
          gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0200 IS INITIAL.
        CREATE OBJECT go_alv_grid_0200
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
           i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid_0200 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0200 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0200.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0200->handle_toolbar_0200
        FOR go_alv_grid_0200.
      SET HANDLER go_event_handler_0200->handle_user_command_0200
        FOR go_alv_grid_0200.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0200->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_bapi_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0200->set_toolbar_interactive.
      CALL METHOD go_alv_grid_0200->refresh_table_display
    *  EXPORTING
    *    IS_STABLE      =
    *    I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 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.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = go_alv_grid_0200.
    ENDMODULE.                 " status_0200  OUTPUT
    *&      Module  user_command_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0100  INPUT
    *&      Module  user_command_0200  INPUT
    *       text
    MODULE user_command_0200 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0200  INPUT
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog
    *&      Form  handle_toolbar_0100
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0100
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'KONV'.
      ls_toolbar-quickinfo  = 'Konvertieren'.
      ls_toolbar-text       = 'Konvertieren'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0100
    *&      Form  handle_user_command_0100
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0100
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'KONV'.
          PERFORM convert_data.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0100
    *&      Form  exit_program
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM exit_program.
      CALL METHOD go_alv_grid_0100->free.
      IF NOT go_alv_grid_0200 IS INITIAL.
        CALL METHOD go_alv_grid_0200->free.
      ENDIF.
      CALL METHOD go_docking_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc NE 0.
    * add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel = sy-repid
            txt2  = sy-subrc
            txt1  = 'Error in Flush'(500).
      ENDIF.
      LEAVE PROGRAM.
    ENDFORM.                    " exit_program
    *&      Form  handle_toolbar_0200
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0200
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'POST'.
      ls_toolbar-quickinfo  = 'Buchen'.
      ls_toolbar-text       = 'Buchen'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0200
    *&      Form  handle_user_command_0200
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0200
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'POST'.
          PERFORM post.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0200
    *&      Form  convert_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM convert_data.
      DATA: lf_perio(3) TYPE n.
      LOOP AT gt_text_input INTO gs_text_input.
        TRANSLATE gs_text_input-planbetrag USING '. '.
        TRANSLATE gs_text_input-planbetrag USING ',.'.
        CONDENSE gs_text_input-planbetrag.
        gs_bapi_input-version   = gp_versn.
        gs_bapi_input-fisc_year = gp_gjahr.
        gs_bapi_input-coobject  = gs_text_input-kostenstelle.
        gs_bapi_input-cost_elem = gs_text_input-kostenart.
        lf_perio = gs_text_input-planperiode.
        CASE lf_perio.
          WHEN '001'.
            gs_bapi_input-wkgbtr01 = gs_text_input-planbetrag.
          WHEN '002'.
            gs_bapi_input-wkgbtr02 = gs_text_input-planbetrag.
          WHEN '003'.
            gs_bapi_input-wkgbtr03 = gs_text_input-planbetrag.
          WHEN '004'.
            gs_bapi_input-wkgbtr04 = gs_text_input-planbetrag.
          WHEN '005'.
            gs_bapi_input-wkgbtr05 = gs_text_input-planbetrag.
          WHEN '006'.
            gs_bapi_input-wkgbtr06 = gs_text_input-planbetrag.
          WHEN '007'.
            gs_bapi_input-wkgbtr07 = gs_text_input-planbetrag.
          WHEN '008'.
            gs_bapi_input-wkgbtr08 = gs_text_input-planbetrag.
          WHEN '009'.
            gs_bapi_input-wkgbtr09 = gs_text_input-planbetrag.
          WHEN '010'.
            gs_bapi_input-wkgbtr10 = gs_text_input-planbetrag.
          WHEN '011'.
            gs_bapi_input-wkgbtr11 = gs_text_input-planbetrag.
          WHEN '012'.
            gs_bapi_input-wkgbtr12 = gs_text_input-planbetrag.
        ENDCASE.
        COLLECT gs_bapi_input INTO gt_bapi_input.
        CLEAR gs_bapi_input.
      ENDLOOP. "at gt_text_input
      CALL SCREEN 0200.
    ENDFORM.                    " convert_data
    *&      Form  build_fieldcatalog_bapi_input
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_bapi_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'VERSION' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'FISC_YEAR' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COOBJECT' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COST_ELEM' .
      ls_fcat-ref_table = 'BAPIPCPVAL' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR01'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR02'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR03'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR04'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR05'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR06'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR07'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR08'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR09'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR10'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR11'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR12'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    " build_fieldcatalog_bapi_input
    *&      Form  post
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM post.
      DATA:
        lf_index(6) TYPE n,
        lf_kostl    LIKE csks-kostl,
        lf_aufnr    LIKE aufk-aufnr,
        lf_kstar    LIKE cska-kstar.
      DATA:
        lt_csks TYPE TABLE OF csks.
      break c5085345.
    * Header
      gs_headerinfo-co_area       = gp_kokrs.
      gs_headerinfo-fisc_year     = gp_gjahr.
      gs_headerinfo-period_from   = '001'.
      gs_headerinfo-period_to     = '012'.
      gs_headerinfo-version       = gp_versn.
      gs_headerinfo-plan_currtype = 'C'.
      LOOP AT gt_bapi_input INTO gs_bapi_input.
    *   Fill index structure
        CLEAR gs_indexstructure.
        lf_index = sy-tabix.
        gs_indexstructure-object_index = lf_index.
        gs_indexstructure-value_index  = lf_index.
        gs_indexstructure-attrib_index = '000000'.
        INSERT gs_indexstructure INTO TABLE gt_indexstructure.
    *   Fill coobject
        CLEAR gs_coobject.
        gs_coobject-object_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-coobject
          IMPORTING
            output = lf_kostl.
        SELECT * FROM csks INTO TABLE lt_csks
          WHERE
            kokrs = gp_kokrs AND
            kostl = lf_kostl.
        IF sy-subrc = 0.
          gs_coobject-costcenter = lf_kostl.
        ELSE.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = gs_bapi_input-coobject
            IMPORTING
              output = lf_aufnr.
          CALL FUNCTION 'K_ORDER_READ'
            EXPORTING
              aufnr     = lf_aufnr
            EXCEPTIONS
              not_found = 1.
          IF NOT sy-subrc = 0.
            gs_return-type = 'E'.
            gs_return-message+0(10)  = 'CO-Objekt '.
            gs_return-message+10(10) = gs_bapi_input-coobject.
            gs_return-message+20(20)  = ' existiert nicht.'.
            CONDENSE gs_return-message.
            PERFORM add_log_message_free_text
              USING
                gs_return-type
                gs_return-message.
            EXIT.
          ENDIF. "IF NOT sy-subrc = 0
          gs_coobject-orderid = lf_aufnr.
        ENDIF. "sy-subrc = 0
        INSERT gs_coobject INTO TABLE gt_coobject.
    *   Period value
        gs_pervalue-value_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-cost_elem
          IMPORTING
            output = lf_kstar.
        gs_pervalue-cost_elem = lf_kstar.
        gs_pervalue-fix_val_per01 = gs_bapi_input-wkgbtr01.
        gs_pervalue-fix_val_per02 = gs_bapi_input-wkgbtr02.
        gs_pervalue-fix_val_per03 = gs_bapi_input-wkgbtr03.
        gs_pervalue-fix_val_per04 = gs_bapi_input-wkgbtr04.
        gs_pervalue-fix_val_per05 = gs_bapi_input-wkgbtr05.
        gs_pervalue-fix_val_per06 = gs_bapi_input-wkgbtr06.
        gs_pervalue-fix_val_per07 = gs_bapi_input-wkgbtr07.
        gs_pervalue-fix_val_per08 = gs_bapi_input-wkgbtr08.
        gs_pervalue-fix_val_per09 = gs_bapi_input-wkgbtr09.
        gs_pervalue-fix_val_per10 = gs_bapi_input-wkgbtr10.
        gs_pervalue-fix_val_per11 = gs_bapi_input-wkgbtr11.
        gs_pervalue-fix_val_per12 = gs_bapi_input-wkgbtr12.
        INSERT gs_pervalue INTO TABLE gt_pervalue.
      ENDLOOP. "at gt_bapi_input
    * Buchungsbaustein
      CALL FUNCTION 'BAPI_PRIM_COST_CHECK_AND_POST'
        EXPORTING
          header_info         = gs_headerinfo
          testrun             = gp_test
    *   DELTA               = ' '
        TABLES
          idx_structure       = gt_indexstructure
          object              = gt_coobject
          per_value           = gt_pervalue
          tot_value           = gt_totvalue
          contrl              = gt_control
          return              = gt_return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    *   EXPORTING
    *     WAIT          =
    *   IMPORTING
    *     RETURN        =
      LOOP AT gt_return INTO gs_return.
        gs_balsmsg-msgty = gs_return-type.
        gs_balsmsg-msgid = gs_return-id.
        gs_balsmsg-msgno = gs_return-number.
        gs_balsmsg-msgv1 = gs_return-message_v1.
        gs_balsmsg-msgv2 = gs_return-message_v2.
        gs_balsmsg-msgv3 = gs_return-message_v3.
        gs_balsmsg-msgv4 = gs_return-message_v4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDLOOP. "AT gt_return
      PERFORM show_log.
    ENDFORM.                    " post
    *&      Form  create_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_log .
      DATA: ls_balslog TYPE bal_s_log.
    * Einige Verwaltungsdaten
      ls_balslog-extnumber = 'ZPLAN010'.
      ls_balslog-aluser    = sy-uname.
      ls_balslog-alprog    = sy-repid.
    * Create
      CALL FUNCTION 'BAL_LOG_CREATE'
        EXPORTING
          i_s_log                 = ls_balslog
    *    IMPORTING
    *      e_log_handle            = gf_balloghndl
        EXCEPTIONS
          log_header_inconsistent = 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.                    " create_log
    *&      Form  add_log_message
    *       text
    *      -->P_GS_BALSMSG  text
    FORM add_log_message
      USING
        ps_balsmsg TYPE bal_s_msg.
      break c5085345.
      CALL FUNCTION 'BAL_LOG_MSG_ADD'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_s_msg                   = ps_balsmsg
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 3
         OTHERS                    = 4.
      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.                    " add_log_messa
    *&      Form  add_log_message_free_text
    *       text
    *      -->P_GS_RETURN_TYPE  text
    *      -->P_GS_RETURN_MESSAGE  text
    FORM add_log_message_free_text
      USING
        ps_type
        ps_message.
      CALL FUNCTION 'BAL_LOG_MSG_ADD_FREE_TEXT'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_msgty                   = ps_type
    *       I_PROBCLASS               = '4'
          i_text                    = ps_message
    *       I_S_CONTEXT               =
    *       I_S_PARAMS                =
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 3
         OTHERS                    = 4.
      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.                    " add_log_message_free_text
    *&      Form  show_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM show_log .
      DATA:
        l_s_display_profile TYPE bal_s_prof.
    * get display profile
      CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
        IMPORTING
          e_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    * use grid for display if wanted
      l_s_display_profile-use_grid = 'X'.
    * set report to allow saving of variants
      l_s_display_profile-disvariant-report = sy-repid.
    * when you use also other ALV lists in your report,
    * please specify a handle to distinguish between the display
    * variants of these different lists, e.g:
      l_s_display_profile-disvariant-handle = 'LOG'.
    * call display function module
    * We do not specify any filter (like I_S_LOG_FILTER, ...,
    * I_T_MSG_HANDLE) since we want to display all logs available
      CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
        EXPORTING
          i_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • Selection using check box in std ALV grid!

    Hi all,
    I have written a custom report to show the O/p in ALV grid.
    This is my code:
    TABLES :zpo_loi.
    TYPE-POOLS : slis.
    TYPE-POOLS: icon.
    TABLES : sscrfields.
    DATA : ls_composer TYPE ssfcompop,
               ls_control TYPE ssfctrlop.
    DATA : wa_return TYPE TABLE OF bapiret2  ,
            wa_address TYPE bapiaddr3.
    DATA : wa_crmd_orderadm_h TYPE zpo_loi,
           it_po TYPE TABLE OF crmd_orderadm_h,
           wa_po TYPE bbp_pds_header.
    DATA : it_tab TYPE TABLE OF zpo_loi.
    DATA :  it_data TYPE TABLE OF crmd_orderadm_h,
            wa_data TYPE bbp_pds_header,
            et_data TYPE bbps_sf_po_output.
    DATA : w_formname TYPE tdsfname ,
           w_sfname TYPE rs38l_fnam.
    DATA :it_po_no TYPE TABLE OF select_be_obj_id,
          wa_it_po_no  LIKE LINE OF it_po_no.
    DATA :r_itab TYPE ddshretval OCCURS 0.
    DATA : it_output LIKE TABLE OF zloi,
           wa_output TYPE zloi.
    DATA : w_answer TYPE c.
    DATA : g_repid LIKE sy-repid,
          g_title TYPE lvc_title,
          g_set_pf_stat TYPE slis_formname VALUE 'SET_PF_STATUS',
          g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
          g_layout TYPE slis_layout_alv,
          g_print_alv TYPE slis_print_alv,
          g_variant LIKE disvariant,
          c_char_a(1) VALUE 'A',
          c_char_x(1) VALUE 'X',
          itab_alv_sort TYPE slis_t_sortinfo_alv,
          itab_alv_fcat TYPE slis_t_fieldcat_alv.
    *       Internal tables          Begin with IT_                       *
    DATA : it_fcat TYPE slis_t_fieldcat_alv,                           "---ALV
           it_disp TYPE TABLE OF zloi.
    *       Work Area for Internal tables      Begin with WA_             *
    DATA : wa_fcat TYPE slis_fieldcat_alv ,              "---ALV
           wa_layout           TYPE lvc_s_layo,               "---ALV
           wa_it_disp LIKE LINE OF it_disp.
    DATA : it_sf_po TYPE TABLE OF crmd_orderadm_h,
           wa_sf_po TYPE bbp_pds_header.
    *SELECTION-SCREEN:
    *  BEGIN OF SCREEN 500 AS WINDOW TITLE title,
    *  END OF SCREEN 500.
    *DATA : functxt TYPE smp_dyntxt.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS sel_po FOR zpo_loi-zobject_id.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    PARAMETERS : pr_loi RADIOBUTTON GROUP grp1 USER-COMMAND ucom,
                 pr_fondo RADIOBUTTON GROUP grp1.
    SELECTION-SCREEN END OF BLOCK b2.
    *       At selection-screen output                                    *
    AT SELECTION-SCREEN OUTPUT.
      IF pr_fondo = 'X'.
        REFRESH sel_po.
        LOOP AT SCREEN.
          IF screen-name = text-003 OR screen-name = text-004.
            screen-input = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSEIF pr_loi = 'X'.
        LOOP AT SCREEN.
          IF screen-name = text-003 OR screen-name = text-004.
            screen-input = '1'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    *       At selection-screen on radiobutton                            *
    AT SELECTION-SCREEN ON RADIOBUTTON GROUP grp1.
      IF pr_fondo  = 'X'.
        REFRESH sel_po.
        LOOP AT SCREEN.
          IF screen-name = text-003 OR screen-name = text-004.
            screen-input = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSEIF pr_loi = 'X'.
        LOOP AT SCREEN.
          IF screen-name = text-003 OR screen-name = text-004.
            screen-input = '1'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_po-low.
      PERFORM populate_table.
      PERFORM f4_help.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_po-high.
      PERFORM populate_table.
      PERFORM f4_help.
    *       At selection-screen                                           *
    AT SELECTION-SCREEN.
    *---CHECKING THE INPUT >>>
      IF sy-ucomm = 'ONLI'.
        PERFORM f002-check_input.
        PERFORM f001-check.
      ENDIF.
    *&      Form  POPULATE_TABLE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM populate_table .
      SELECT zobject_id
               description
      FROM zpo_loi
      INTO CORRESPONDING FIELDS OF TABLE it_tab.
      SORT it_tab BY zobject_id ASCENDING.
    ENDFORM.                    " POPULATE_TABLE
    *&      Form  F4_HELP
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f4_help .
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          ddic_structure = ' '
          retfield       = 'ZOBJECT_ID'
          dynpprog       = sy-repid
          dynpnr         = sy-dynnr
          dynprofield    = 'A'
          value_org      = 'S'
        TABLES
          value_tab      = it_tab
          return_tab     = r_itab.
    ENDFORM.                                                    " F4_HELP
    *&      Form  F001-CHECK
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f001-check .
      IF pr_fondo = 'X'.
        PERFORM display_expiring_fondos.
      ELSEIF pr_loi = 'X'.
        PERFORM fetch_po_det.
        PERFORM build_fcat.
        PERFORM alv_display.
      ENDIF.
    ENDFORM.                    " F001-CHECK
    *&      Form  F002-CHECK_INPUT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f002-check_input .
      IF pr_loi = 'X'.
        REFRESH it_po.
        IF sel_po-low IS NOT INITIAL.
          SELECT object_id
          FROM crmd_orderadm_h
          INTO CORRESPONDING FIELDS OF TABLE it_po
          WHERE object_type = 'BUS2201'
          AND object_id = sel_po-low.
          IF sy-subrc NE 0.
            IF sel_po-high IS NOT INITIAL.
              SELECT object_id
              FROM crmd_orderadm_h
              INTO CORRESPONDING FIELDS OF TABLE it_po
              WHERE object_type = 'BUS2201'
              AND  object_id = sel_po-high.
              IF sy-subrc NE 0.
                MESSAGE e009(zsrm).
              ENDIF.
            ENDIF.
            MESSAGE e007(zsrm).
          ENDIF.
        ELSE.
          MESSAGE e010(zsrm).
        ENDIF.
        IF sel_po-high IS NOT INITIAL.
          SELECT object_id
          FROM crmd_orderadm_h
          INTO CORRESPONDING FIELDS OF TABLE it_po
          WHERE object_type = 'BUS2201'
          AND  object_id = sel_po-high.
          IF sy-subrc NE 0.
            MESSAGE e008(zsrm).
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    " F002-CHECK_INPUT
    *&      Form  FETCH_PO_DET
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fetch_po_det .
      REFRESH it_po.
      it_po_no[] = sel_po[].
      DATA : w_count TYPE i,
             w_lines TYPE c,
             wa_header TYPE bbp_pds_po_header_d.
      REFRESH : it_po,it_output.
      IF sel_po-high IS NOT INITIAL.
        SELECT object_id
               description
               posting_date
               created_by
        FROM crmd_orderadm_h
        INTO CORRESPONDING FIELDS OF TABLE it_po
        WHERE object_type = 'BUS2201'
        AND object_id BETWEEN sel_po-low AND sel_po-high.
      ELSE.
        SELECT object_id
               description
               posting_date
               created_by
        FROM crmd_orderadm_h
        INTO CORRESPONDING FIELDS OF TABLE it_po
        WHERE object_type = 'BUS2201'
        AND object_id = sel_po-low.
      ENDIF.
      w_lines = sy-dbcnt.
      w_count = 1.
      DO.
        IF w_count LE w_lines.
          READ TABLE it_po INTO wa_po INDEX w_count.
          MOVE wa_po-object_id TO wa_output-zzpono.
          MOVE wa_po-description TO wa_output-zzpodesc.
          MOVE wa_po-posting_date TO wa_output-zzpodate.
          MOVE wa_po-created_by TO wa_output-zzpocreator.
          CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
            EXPORTING
              i_object_id = wa_output-zzpono
            IMPORTING
              e_header    = wa_header.
          CALL FUNCTION 'BAPI_USER_GET_DETAIL'
            EXPORTING
              username = wa_output-zzpocreator
            IMPORTING
              address  = wa_address
            TABLES
              return   = wa_return.
          CLEAR wa_output-zzpocreator.
          CONCATENATE wa_address-firstname '   '  wa_address-lastname INTO wa_output-zzpocreator .
          MOVE wa_header-total_value TO wa_output-zzpoval.
          MOVE wa_header-currency TO wa_output-zzpocur.
          APPEND wa_output TO it_output.
          w_count = w_count + 1.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.                    " FETCH_PO_DET
    *&      Form  BUILD_FCAT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fcat .
      g_repid = sy-repid.
      g_title = 'Print LOI details'.
      g_print_alv-no_print_listinfos = 'X'.
      g_variant-report = sy-repid.
      g_variant-variant = sy-title.
      CLEAR g_layout.
      g_layout-f2code = ' '.
      wa_layout-zebra       = 'X'.
      g_layout-flexible_key = 'X'.
      g_layout-colwidth_optimize = 'X'.
      g_layout-detail_initial_lines = 'X'.
      g_layout-box_fieldname = 'ZZCHECK'.
      REFRESH it_fcat.
    *Po no
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPONO' .
      wa_fcat-tabname = 'IT_DISP'.
      wa_fcat-seltext_m  = 'Purchase Order'.
    *wa_fcat-seltext_s = 'Purchase Order.
      wa_fcat-icon = 'X'.
      wa_fcat-col_pos = '2'.
      wa_fcat-outputlen = 10.
      APPEND wa_fcat TO it_fcat.
    *Description
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPODESC' .
      wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'Description'.
      wa_fcat-seltext_m = 'Description'.
    *wa_fcat-seltext_s = 'Description'.
      wa_fcat-col_pos = '3'.
      wa_fcat-outputlen = 10.
      APPEND wa_fcat TO it_fcat.
    *Posting date
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPODATE' .
      wa_fcat-tabname = 'IT_DISP'.
      wa_fcat-seltext_l = 'Posting Date'.
      wa_fcat-seltext_m = 'Posting Date'.
    *wa_fcat-seltext_s = 'Posting Date'.
      wa_fcat-col_pos = '4'.
      wa_fcat-outputlen = 8.
      APPEND wa_fcat TO it_fcat.
    *value
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPOVAL' .
      wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'PO value'.
      wa_fcat-seltext_m = 'PO value'.
    *wa_fcat-seltext_s = 'PO value'.
      wa_fcat-col_pos = '5'.
      wa_fcat-outputlen = 15.
      wa_fcat-no_zero = 'X'.
      APPEND wa_fcat TO it_fcat.
    *Currency
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPOCUR' .
      wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'PO Currency'.
      wa_fcat-seltext_m = 'PO Currency'.
    *wa_fcat-seltext_s = 'PO Currency'.
      wa_fcat-col_pos = '6'.
      wa_fcat-outputlen = 5.
      APPEND wa_fcat TO it_fcat.
    *Creator
      CLEAR wa_fcat.
      wa_fcat-fieldname = 'ZZPOCREATOR' .
      wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'Buyer'.
      wa_fcat-seltext_m = 'Buyer'.
    *wa_fcat-seltext_s = 'Buyer'.
      wa_fcat-col_pos = '7'.
      wa_fcat-outputlen = 12.
      APPEND wa_fcat TO it_fcat.
    ENDFORM.                    " BUILD_FCAT
    *&      Form  ALV_DISPLAY
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM alv_display .
      SORT it_output BY zzpono.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = g_repid
          i_callback_pf_status_set = g_set_pf_stat
          i_callback_user_command  = g_user_command
          i_grid_title             = g_title
          is_layout                = g_layout
          it_fieldcat              = it_fcat[]
          is_variant               = g_variant
          is_print                 = g_print_alv
        TABLES
          t_outtab                 = it_output[]
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
      ENDIF.
    ENDFORM.                    " ALV_DISPLAY
    *&      Form  user_command
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.                             "#EC CALLED
      DATA: gd_repid LIKE sy-repid, "Exists
      ref_grid TYPE REF TO cl_gui_alv_grid.
      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.
      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data .
      ENDIF.
      rs_selfield-refresh = 'X'.
      CASE r_ucomm.
        WHEN 'PRINTLOI'.
          PERFORM call_sf.
        WHEN 'BACK'.
          CALL SELECTION-SCREEN 1000.
        WHEN 'CANCEL'.
          CALL SELECTION-SCREEN 1000.
        WHEN 'EXIT'.
          CALL SELECTION-SCREEN 1000.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  set_pf_status
    *       text
    *      -->RT_EXTAB   text
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZALV' EXCLUDING rt_extab.
      SET TITLEBAR 'ZALV'.
    ENDFORM.                    "set_pf_status
    *&      Form  CALL_SF
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM call_sf .
      REFRESH it_sf_po.
      LOOP AT it_output INTO wa_output WHERE zzcheck = 'X'.
        wa_sf_po-object_id = wa_output-zzpono.
        APPEND wa_sf_po TO it_sf_po.
      ENDLOOP.
      w_formname = 'ZSR_EBP_DOCU_LETTEROFINTENT1'.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = w_formname
        IMPORTING
          fm_name            = w_sfname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
      ENDIF.
      ls_composer-tdnewid = 'X'.
      ls_control-no_dialog = 'X'.
      LOOP AT it_sf_po INTO wa_sf_po.
        CALL FUNCTION w_sfname
          EXPORTING
            control_parameters = ls_control
            output_options     = ls_composer
            wa_object          = wa_sf_po
          EXCEPTIONS
            formatting_error   = 1
            internal_error     = 2
            send_error         = 3
            user_canceled      = 4
            OTHERS             = 5.
        IF sy-subrc <> 0.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " CALL_SF
    *&      Form  DISPLAY_EXPIRING_FONDOS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_expiring_fondos .
      SET PF-STATUS 'ZLOI'.
      SET TITLEBAR 'ZLOI'.
      TYPES : BEGIN OF ty_output1,
                guid TYPE bbp_guid,
                object_id TYPE crmt_object_id_db,
                description TYPE crmt_process_description,
                posting_date TYPE crmt_posting_date,
                zzfondo_dat TYPE zfondo_dat,
                created_by TYPE crmt_created_by,
               END OF ty_output1.
      DATA : it_output1 TYPE TABLE OF ty_output1,
             wa_output1 TYPE ty_output1,
              w_lines,
              w_count,
              it_fondo TYPE TABLE OF zsr_fondo,
              it_temp_fondo TYPE TABLE OF zsr_fondo,
              wa_temp_fondo TYPE zsr_fondo,
              wa_fondo TYPE zsr_fondo,
              w_diff TYPE p,
              wa_header1  TYPE bbp_pds_po_header_d.
      CONSTANTS : c_otype(8) VALUE 'BUS2201'.
      REFRESH : it_output1,it_temp_fondo,it_fondo.
      SELECT b~zzfondo_dat
             a~guid
             a~object_id
             a~description
             a~posting_date
             a~created_by
      INTO CORRESPONDING FIELDS OF TABLE it_output1
      FROM bbp_pdhsc AS b
      LEFT OUTER JOIN crmd_orderadm_h AS a ON b~guid = a~guid
      AND a~object_type = c_otype.
      LOOP AT it_output1 INTO wa_output1.
        CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
          EXPORTING
            date1            = sy-datum
            date2            = wa_output1-zzfondo_dat
          IMPORTING
            datediff         = w_diff
          EXCEPTIONS
            invalid_datetime = 1
            OTHERS           = 2.
        IF sy-subrc <> 0.
        ENDIF.
        IF w_diff <= '7'.
          wa_temp_fondo-zzpono = wa_output1-object_id.
          APPEND wa_temp_fondo TO it_temp_fondo.
        ENDIF.
      ENDLOOP.
    *select the final entries for PO whose FONDO is expiring
      DESCRIBE TABLE it_temp_fondo LINES w_lines.
      w_count = 1.
      DO.
        IF w_count LE w_lines.
          READ TABLE it_temp_fondo INTO wa_temp_fondo INDEX w_count.
          IF sy-subrc = 0.
            CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
              EXPORTING
                i_object_id = wa_temp_fondo-zzpono
              IMPORTING
                e_header    = wa_header1.
            wa_fondo-zzpono = wa_temp_fondo-zzpono.
            wa_fondo-zzpodesc = wa_header1-description.
            wa_fondo-zzpodate =  wa_header1-posting_date.
            wa_fondo-zzexpdate = wa_header1-zzfondo_dat.
            wa_fondo-zzpoval = wa_header1-total_value.
            wa_fondo-zzpocur = wa_header1-currency.
            wa_fondo-zzpocreator = wa_header1-created_by.
            CLEAR : wa_address.
            REFRESH wa_return.
            CALL FUNCTION 'BAPI_USER_GET_DETAIL'
              EXPORTING
                username = wa_header1-created_by
              IMPORTING
                address  = wa_address
              TABLES
                return   = wa_return.
            CLEAR wa_fondo-zzpocreator.
            CONCATENATE wa_address-firstname '   '  wa_address-lastname INTO wa_fondo-zzpocreator .
            w_count = w_count + 1.
            APPEND wa_fondo TO it_fondo.
          ENDIF.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_structure_name = 'ZSR_FONDO'
          i_grid_title     = 'EXPIRING FONDOS'
        TABLES
          t_outtab         = it_fondo[]
        EXCEPTIONS
          program_error    = 1
          OTHERS           = 2.
      IF sy-subrc <> 0.
      ENDIF.
    ENDFORM.                    " DISPLAY_EXPIRING_FONDOS
    Now in my ALV grid o/p i can see the check box but if i select one row and then try to select another the first one gets deselected.
    Can anybody tell me what is missing?

    Hi,
    Try like changing  this
    insted of
    g_layout-f2code = ' '.
    use this
    g_layout-f2code = 'DISP'. " Sets fcode for when double
    and
    g_layout-f2code = '&ETA'. " it will display POPUP screen
    Best Regards
    Ranga
    Edited by: Ranga Swamy on Nov 1, 2008 11:07 PM
    Edited by: Ranga Swamy on Nov 1, 2008 11:17 PM

  • Check box in ALV grid gets unselected for new selection

    Hi all,
    This is my code :
    TYPE-POOLS : slis.
    Variable
    DATA: g_repid LIKE sy-repid,
          g_title TYPE lvc_title,
          g_set_pf_stat TYPE slis_formname VALUE 'SET_PF_STATUS',
          g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
          g_layout TYPE slis_layout_alv,
          g_print_alv TYPE slis_print_alv,
          g_variant LIKE disvariant,
          c_char_a(1) VALUE 'A',
          c_char_x(1) VALUE 'X',
          itab_alv_sort TYPE slis_t_sortinfo_alv,
          itab_alv_fcat TYPE slis_t_fieldcat_alv,
          fm_name type rs38l_fnam," Function Module Name
    *      l_sfctrlparams LIKE ssfctrlop, " Form Print Parameter
    *      l_sfoutopt LIKE ssfcompop,
          pri_params LIKE pri_params,
          c_x type c .
    *       Internal tables          Begin with IT_                       *
    DATA : it_fcat TYPE SLIS_T_FIELDCAT_ALV,                           "---ALV
           it_disp type table of ZLOI.
    *       Work Area for Internal tables      Begin with WA_             *
    data : wa_fcat TYPE slis_fieldcat_alv ,              "---ALV
           wa_layout           TYPE lvc_s_layo,               "---ALV
           wa_it_disp like line of it_disp.
    *       Objects                                                       *
    DATA : cref TYPE REF TO cl_gui_custom_container,          "---ALV
           gref TYPE REF TO cl_gui_alv_grid.                  "---ALV
    *        Start-of-selection
    Start-of-selection.
      perform fetch_po_det.
      perform build_fcat.
      perform alv_display.
    *&      Form  FETCH_PO_DET
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM FETCH_PO_DET .
      data : it_po type table of crmd_orderadm_h,
               wa_po like line of it_po,
               wa_header type BBP_PDS_PO_HEADER_D.
      select  guid
              object_id
              DESCRIPTION
              POSTING_DATE
              CREATED_BY
      from crmd_orderadm_h
      into corresponding fields of table it_po
      where object_type = 'BUS2201'.
      loop at it_po into wa_po.
        move wa_po-object_id to wa_it_disp-ZZPONO.
        move wa_po-DESCRIPTION to wa_it_disp-ZZPODESC.
        move wa_po-posting_date to wa_it_disp-ZZPODATE.
        move wa_po-created_by to wa_it_disp-ZZPOCREATOR.
        CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
          EXPORTING
            I_OBJECT_ID = wa_it_disp-zzpono
          IMPORTING
            E_HEADER    = wa_header.
        move wa_header-total_value to wa_it_disp-ZZPOVAL.
        move wa_header-currency to wa_it_disp-ZZPOCUR.
        append wa_it_disp to it_disp.
      endloop.
    *  write : wa_it_disp-zzpono.
    ENDFORM.                    " FETCH_PO_DET
    *&      Form  BUILD_FCAT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM BUILD_FCAT .
      g_repid = sy-repid.
      g_title = 'LOI details'.
      g_print_alv-no_print_listinfos = 'X'.
      g_variant-report = sy-repid.
      g_variant-variant = sy-title.
      CLEAR g_layout.
      g_layout-f2code = ' '.
      wa_layout-zebra       = 'X'.
      g_layout-flexible_key = 'X'.
      g_layout-colwidth_optimize = 'X'.
      g_layout-detail_initial_lines = 'X'.
      g_layout-box_fieldname = 'ZZCHECK'.
    *g_layout-box_tabname = 'ITAB_REPORT'.
    *Check box
      wa_fcat-fieldname = 'ZZCHECK'.
      wa_fcat-checkbox = 'X'.
      wa_fcat-outputlen = '1'.
      wa_fcat-col_pos = '1'.
      wa_fcat-edit = '1'.
      wa_fcat-seltext_m = 'No'.
      append wa_fcat to it_fcat.
    *Po no
      clear wa_fcat.
      wa_fcat-fieldname = 'ZZPONO' .
    wa_fcat-tabname = 'IT_DISP'.
    *  wa_fcat-seltext = 'Purchase Order'.
      wa_fcat-seltext_m  = 'Purchase Order'.
    *wa_fcat-seltext_s = 'Purchase Order.
    wa_fcat-icon = 'X'.
      wa_fcat-col_pos = '2'.
      wa_fcat-outputlen = 10.
      append wa_fcat to it_fcat.
    *Desc
      wa_fcat-fieldname = 'ZZPODESC' .
    wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'Description'.
      wa_fcat-seltext_m = 'Description'.
    *wa_fcat-seltext_s = 'Description'.
      wa_fcat-col_pos = '3'.
      wa_fcat-outputlen = 10.
      append wa_fcat to it_fcat.
    *Postign date
      wa_fcat-fieldname = 'ZZPODATE' .
    wa_fcat-tabname = 'IT_DISP'.
    wa_fcat-seltext_l = 'Posting Date'.
      wa_fcat-seltext_m = 'Posting Date'.
    *wa_fcat-seltext_s = 'Posting Date'.
      wa_fcat-col_pos = '4'.
      wa_fcat-outputlen = 8.
      append wa_fcat to it_fcat.
    *value
      wa_fcat-fieldname = 'ZZPOVAL' .
    wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'PO value'.
      wa_fcat-seltext_m = 'PO value'.
    *wa_fcat-seltext_s = 'PO value'.
      wa_fcat-col_pos = '5'.
      wa_fcat-outputlen = 15.
      append wa_fcat to it_fcat.
    *Currency
      wa_fcat-fieldname = 'ZZPOCUR' .
    wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'PO Currency'.
      wa_fcat-seltext_m = 'PO Currency'.
    *wa_fcat-seltext_s = 'PO Currency'.
      wa_fcat-col_pos = '6'.
      wa_fcat-outputlen = 5.
      append wa_fcat to it_fcat.
    *Creator
      wa_fcat-fieldname = 'ZZPOCREATOR' .
    wa_fcat-tabname = 'IT_DISP'.
    *wa_fcat-seltext_l = 'Buyer'.
      wa_fcat-seltext_m = 'Buyer'.
    *wa_fcat-seltext_s = 'Buyer'.
      wa_fcat-col_pos = '7'.
      wa_fcat-outputlen = 12.
      append wa_fcat to it_fcat.
    ENDFORM.                    " BUILD_FCAT
    *&      Form  ALV_DISPLAY
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM ALV_DISPLAY .
      sort it_disp by ZZPONO.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                = g_repid
         I_CALLBACK_PF_STATUS_SET          = g_set_pf_stat
         I_CALLBACK_USER_COMMAND           = g_user_command
    *   I_CALLBACK_TOP_OF_PAGE            = ' '
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
          I_GRID_TITLE                      = g_title
    *   I_GRID_SETTINGS                   =
          IS_LAYOUT                         = g_layout
          IT_FIELDCAT                       = it_fcat[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
          IS_VARIANT                        = g_variant
    *   IT_EVENTS                         =
    *   IT_EVENT_EXIT                     =
          IS_PRINT                          = g_print_alv
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = it_disp[]
       EXCEPTIONS
         PROGRAM_ERROR                     = 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.                    " ALV_DISPLAY
    *&      Form  user_command
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.                             "#EC CALLED
      CASE R_UCOMM.
        WHEN 'PRINT'.
          READ TABLE IT_disp INTO WA_IT_DISP WITH KEY ZZCHECK = 'X'.
          IF SY-SUBRC EQ 0.
            loop at it_DISP INTO WA_IT_DISP.
              CALL FUNCTION 'POPUP_TO_CONFIRM'
                EXPORTING
                  TEXT_QUESTION = 'Print the LOI details?'
                  TEXT_BUTTON_1 = 'Yes'
                  TEXT_BUTTON_2 = 'No'.
    *      IMPORTING
    *        ANSWER        = w_answer.
              IF SY-SUBRC  0.
              ENDIF.
    *          PERFORM CALL_SF.
            endloop.
          ENDIF.
        WHEN 'BACK'.
          LEAVE PROGRAM.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'CANCEL'.
          LEAVE PROGRAM.
      ENDCASE.
      rs_selfield-refresh = 'X'.
    ENDFORM.                    "user_command
    *&      Form  set_pf_status
    *       text
    *      -->RT_EXTAB   text
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZSTANDARD' EXCLUDING rt_extab.
      SET TITLEBAR sy-tcode.
    ENDFORM.                    "set_pf_status
    Now in my ALV grid o/p i can  see the check box  but if i select one row and then try to slect another the first one gets deselected.
    Can anybody tell me what is missing?

    Hi,
    if you need just a check box for each line, try to get rid of this line from your layout.
    g_layout-box_fieldname = 'ZZCHECK'.
    SAP uses this field to store info about selected lines. Hence you click on the second check box, you select different line and the first line is erased. You can select more line by holding SHIFT + CTRL
    Cheers

  • Double click on list field in ALV grid control

    Hello all,
    I developed a report with a ALV grid control. I would like to move some functionality from marking a line and pressing a button in the status line to double clicking a specific field in the output list and execute a command there (i.e. double click on PO number and go to PO display TAC then). Can anybody provide some example coding for that?
    Thanks so much for your help!
    Torsten

    Here is your sample program.  Copy this code into a z program.  Create the screen 100 with a container in it and name it "ALV_CONTAINER".  Create the gui-status with "BACK".
    report zrich_0001.
    tables: ekko.
    data: begin of i_alv occurs 0,
          ebeln type ekko-ebeln,
          end of i_alv.
    *       CLASS cl_event_receiver DEFINITION      Handles Double Click
    class cl_event_receiver definition.
      public section.
        methods handle_double_click
          for event double_click of cl_gui_alv_grid
          importing e_row e_column.
      private section.
    endclass.
    *       CLASS CL_EVENT_RECEIVER IMPLEMENTATION    Handles Double Click
    class cl_event_receiver implementation.
      method handle_double_click.
        perform drill_down using e_row-index.
      endmethod.
    endclass.
    data: alv_container  type ref to cl_gui_custom_container.
    data: event_receiver type ref to cl_event_receiver.
    data: alv_grid       type ref to cl_gui_alv_grid.
    data: layout    type lvc_s_layo.
    data: fieldcat  type lvc_t_fcat.
    selection-screen begin of block b1 with frame title text-001 .
    select-options: s_ebeln for ekko-ebeln.
    selection-screen end of block b1.
    start-of-selection.
      perform get_data.
      call screen 100.
    *      Module  status_0100  OUTPUT
    module status_0100 output.
      set pf-status '0100'.
      set titlebar '0100'.
      data: variant type  disvariant.
      variant-report = sy-repid.
      variant-username = sy-uname.
    * Create Controls
      create object alv_container
             exporting
                   container_name    = 'ALV_CONTAINER'.
      create object alv_grid
             exporting
                   i_parent          =  alv_container.
    *  Create Event Receiver
      create object event_receiver.
    *  Populate Field Catalog
      perform get_fieldcatalog.
      call method alv_grid->set_table_for_first_display
          exporting
               is_layout              = layout
               is_variant             = variant
               i_save                 = 'U'
               i_structure_name       = 'I_ALV'
          changing
               it_outtab       = i_alv[]
               it_fieldcatalog = fieldcat[].
    *   handler for ALV grid
      set handler event_receiver->handle_double_click for alv_grid.
    endmodule.
    *      Module  USER_COMMAND_0100  INPUT
    module user_command_0100 input.
      case sy-ucomm.
        when 'BACK' or 'CANC'.
          if not alv_container is initial.
            call method alv_container->free.
            clear: alv_container.
            free : alv_container.
          endif.
          if sy-subrc = 0.
            set screen 0.
            leave screen.
          else.
            leave program.
          endif.
        when 'EXIT'.
          if not alv_container is initial.
            call method alv_container->free.
            clear: alv_container.
            free : alv_container.
          endif.
          leave program.
      endcase.
    endmodule.
    * FORM GET_DATA
    form get_data.
      select * into corresponding fields of table i_alv
                from ekko
                     where ebeln in s_ebeln.
      sort i_alv ascending by ebeln.
    endform.
    *      Form  Get_Fieldcatalog - Set Up Columns/Headers
    form get_fieldcatalog.
      data: ls_fcat type lvc_s_fcat.
      refresh: fieldcat.
      clear: ls_fcat.
      ls_fcat-reptext    = 'PO Number'.
      ls_fcat-coltext    = 'PO Number'.
      ls_fcat-fieldname  = 'EBELN'.
      ls_fcat-ref_table  = 'I_ALV'.
      ls_fcat-outputlen  = '12'.
      ls_fcat-col_pos    = 1.
      append ls_fcat to fieldcat.
    endform.
    * DRILL_DOWN
    form drill_down using index.
      read table i_alv index index.
      if sy-subrc = 0.
        set parameter id 'BES' field i_alv-ebeln.
        call transaction 'ME23' and skip first screen.
        if not alv_container is initial.
          call method alv_container->free.
          clear: alv_container.
          free : alv_container.
        endif.
      endif.
    endform.
    Regards,
    Rich Heilman

  • ALV GRID Report is not showing all records which is in internal table

    hi all,
    have one doubt. please clarify me. ALV Report is working fine since long tiem. But suddenly this report is showing few records only for the given input.   Example:   it_main table have 50 records, but output is showing only 10 records only. (we have not made any modifications in this report).
    temporarily i have given excel output file from it_main table. excel file is showing all records.
    here it_main have all the records. but output is showing few records only. it is not showing any error. i have tested with REUSE_ALV_LIST_DISPLAY function also. but it also showing same results(few records only.)
    please give me some idea.
    FORM display_alv_report.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_buffer_active          = 'X'
          i_callback_program       = sy-repid
          is_layout                = wa_layout
          it_fieldcat              = it_fcat
          it_events                = it_events
          i_save                   = 'A'
          is_variant               = wa_variant
        TABLES
          t_outtab                 = it_main
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE text-204 " 'Error in Display the list'
        TYPE 'I'.
        LEAVE TO LIST-PROCESSING.
      ENDIF.
    ENDFORM.            .                    "DISPLAY_ALV_REPORT
    Best Regards,
    Srinivas

    hi
    Please study this program and give me suggestions.
    ALV Declaration
    DATA : it_events TYPE slis_t_event,               "ALV event
               it_fcat   TYPE slis_t_fieldcat_alv,        "Field catalog
               it_list_top_of_page TYPE slis_t_listheader,
               c_tabname  TYPE slis_tabname   VALUE 'IT_MAIN'.
    DATA : wa_layout  TYPE slis_layout_alv,
                wa_event   TYPE slis_alv_event,
               wa_fcat    TYPE slis_fieldcat_alv,
               wa_variant TYPE disvariant.
    START-OF-SELECTION.
      PERFORM material_pass.
      PERFORM data_retrieval.
    END-OF-SELECTION.
      PERFORM sub_display_report.
    FORM sub_display_report .
      DATA status(1).
      IF r1 = 'X'.
        PERFORM build_fieldcatalog USING :
          '1'  'ERDAT'     'S.O DATE'             '' '10'  'X',
          '2'  'VBELN'     'SALE ORDER'           '' '10'  'X',
          '3'  'POSNR'     'SALE ITEM'            '' '6'   '',
          '4'  'BSTKD'     'CUSTOMER PO'          '' '35'  '',
          '5'  'BEZEI'     'REASON FOR REJECTION' '' '40'  '',
          '6'  'PLNUM'     'PLANNED ORDER'        '' '10'  '',
          '7'  'AUFNR'     'PROD.ORDER.'          '' '12'  '',
          '8'  'MATNR'     'MATERIAL NUMBER'      '' '18'  '',
          '9'  'MAKTX'     'MATERIAL DESCRIPTION' '' '40'  '',
          '10' 'WERKS'     'PLANT'                '' '4'   '',
          '11' 'KWMENG'    'SALE ORDER QTY'       '' '15'  '',
          '12' 'VRKME'     'UNIT'                 '' '4'   '',
          '13' 'GAMNG'     'PROD.ORDER QTY'       '' '13'  '',
          '14' 'IGMNG'     'CONFIRMED ORDER QTY'  '' '13'  '',
          '15' 'GMEIN'     'UNIT'                 '' '4'   '',
          '16' 'MENGE'     'G.R QUANTITY'         '' '13'  '',
          '17' 'SOBAL'     'S.O BALANCE'          '' '13'  '',
          '18' 'PRDBAL'    'PROD.BALANCE'         '' '13'  '',
          '19' 'GSM'       'GSM'                  '' '4'   '',
          '20' 'SIZE1'     'SIZE1'                '' '10'  '',
          '21' 'SIZE2'     'SIZE2'                '' '10'  ''.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename              = pathname
            filetype              = ftype
            append                = 'X'
            write_field_separator = 'X'
          TABLES
            data_tab              = it_mains
          EXCEPTIONS
            file_write_error      = 1.
        IF sy-subrc = 0.
          status = 'S'.
        ELSE.
          status = 'E'.
        ENDIF.
      ELSEIF r2 = 'X' OR r3 = 'X'.
        PERFORM build_fieldcatalog USING :
          '1'  'ERDAT'     'S.O DATE'             '' '10'  'X',
          '2'  'VBELN'     'SALE ORDER'           '' '10'  'X',
          '3'  'POSNR'     'SALE ITEM'            '' '6'   '',
          '4'  'BSTKD'     'CUSTOMER PO'          '' '35'  '',
          '5'  'BEZEI'     'REASON FOR REJECTION' '' '40'  '',
          '6'  'PLNUM'     'PLANNED ORDER'        '' '10'  '',
          '7'  'AUFNR'     'PROD.ORDER.'          '' '12'  '',
          '8'  'MATNR'     'MATERIAL NUMBER'      '' '18'  '',
          '9'  'MAKTX'     'MATERIAL DESCRIPTION' '' '40'  '',
          '10' 'WERKS'     'PLANT'                '' '4'   '',
          '11' 'KWMENG'    'SALE ORDER QTY'       '' '15'  '',
          '12' 'VRKME'     'UNIT'                 '' '4'   '',
          '13' 'GAMNG'     'PROD.ORDER QTY'       '' '13'  '',
          '14' 'IGMNG'     'CONFIRMED ORDER QTY'  '' '13'  '',
          '15' 'GMEIN'     'UNIT'                 '' '4'   '',
          '16' 'MENGE'     'G.R QUANTITY'         '' '13'  '',
          '17' 'SOBAL'     'S.O BALANCE'          '' '13'  '',
          '18' 'PRDBAL'    'PROD.BALANCE'         '' '13'  '',
          '19' 'GSM'       'GSM'                  '' '4'   '',
          '20' 'SIZE1'     'SIZE1'                '' '10'  '',
          '21' 'CUT1'      'CUT1'                 '' '11'  '',
          '22' 'SIZE2'     'SIZE2'                '' '10'  '',
          '23' 'CUT2'      'CUT2'                 '' '11'  '',
          '24' 'SIZE3'     'SIZE3'                '' '10'  '',
          '25' 'CUT3'      'CUT3'                 '' '11'  '',
          '26' 'SIZE4'     'SIZE4'                '' '10'  '',
          '27' 'CUT4'      'CUT4'                 '' '11'  '',
          '28' 'SIZE5'     'SIZE5'                '' '10'  '',
          '29' 'CUT5'      'CUT5'                 '' '11'  '',
          '30' 'SIZE6'     'SIZE6'                '' '10'  '',
          '31' 'CUT6'      'CUT6'                 '' '11'  ''.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename              = pathname
            filetype              = ftype
            append                = 'X'
            write_field_separator = 'X'
          TABLES
            data_tab              = it_mainall
          EXCEPTIONS
            file_write_error      = 1.
        IF sy-subrc = 0.
          status = 'S'.
        ELSE.
          status = 'E'.
        ENDIF.
      ENDIF.
      PERFORM build_layout.
      PERFORM build_events.
      PERFORM sub_comment_build USING it_list_top_of_page.
      PERFORM sub_set_variant.
      PERFORM display_alv_report.
      IF status = 'S'.
        MESSAGE 'Excel Output file Downloaded to Given Path' TYPE 'I'.
      ELSE.
        MESSAGE 'Download Not Possible' TYPE 'I'.
      ENDIF.
    ENDFORM.                    " SUB_DISPLAY_REPORT
    FORM BUILD_FIELDCATALOG
    FORM build_fieldcatalog USING  p_col_pos
                                   p_fieldname
                                   p_text
                                   p_datatype
                                   p_outputlen
                                   p_col_freez.
      wa_fcat-row_pos        = '1'.
      wa_fcat-col_pos        = p_col_pos.
      wa_fcat-fieldname      = p_fieldname.
      wa_fcat-tabname        = c_tabname.
      wa_fcat-reptext_ddic   = p_text.
      wa_fcat-datatype       = p_datatype.
      wa_fcat-ddic_outputlen = p_outputlen.
      wa_fcat-key            = p_col_freez.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    FORM build_layout.
      CLEAR: wa_layout.
      wa_layout-window_titlebar   = 'LIST OF GSM WISE OPEN SALE ORDERS'.
      wa_layout-colwidth_optimize = 'X'.
      wa_layout-totals_text       = 'CUMULATIVE'.
    ENDFORM.                    "BUILD_LAYOUT
    *&      Form  BUILD_EVENTS
    FORM build_events.
      CLEAR wa_event.
      REFRESH it_events.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_events
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc = 0.
        READ TABLE it_events INTO wa_event
             WITH KEY name = 'TOP_OF_PAGE'.
        IF sy-subrc EQ 0.
          wa_event-form = 'TOP_OF_PAGE'.
          APPEND wa_event TO it_events.
          CLEAR wa_event.
        ENDIF.
      ENDIF.
    ENDFORM.                    "BUILD_EVENTS
         -->P_IT_LIST_TOP_OF_PAGE  text
    FORM sub_comment_build  USING it_top_of_page TYPE slis_t_listheader.
      DATA ls_line TYPE slis_listheader.
      CLEAR ls_line.
      ls_line-typ = 'H'.
      ls_line-info = str1.
      APPEND ls_line TO it_top_of_page.
      CLEAR ls_line.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
         it_list_commentary = t_header[].
    ENDFORM.                    " SUB_COMMENT_BUILD
    *&      Form  SUB_SET_VARIANT
          text
    -->  p1        text
    <--  p2        text
    FORM sub_set_variant .
      CLEAR wa_variant.
      wa_variant-report = sy-repid.
      wa_variant-username = sy-uname.
    wa_variant-variant = c_variant.
    wa_variant-variant = p_layout.
    ENDFORM.                    " SUB_SET_VARIANT
    *&      Form  DISPLAY_ALV_REPORT
    *Display Report Using ALV GRID
    FORM display_alv_report.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_buffer_active          = 'X'
          i_callback_program       = sy-repid
         i_callback_pf_status_set = c_pf_status
         i_callback_user_command  = c_user_command
          is_layout                = wa_layout
          it_fieldcat              = it_fcat
         it_sort                  = it_sort[]
          it_events                = it_events
          i_save                   = 'A'
          is_variant               = wa_variant
        TABLES
          t_outtab                 = it_main
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE text-204 " 'Error in Display the list'
        TYPE 'I'.
        LEAVE TO LIST-PROCESSING.
      ENDIF.
    ENDFORM.            .                    "DISPLAY_ALV_REPORT
    *ALV Report Header
    FORM top_of_page.
      DATA : t_header TYPE slis_t_listheader WITH HEADER LINE,
             wa_header TYPE slis_listheader,
             t_line LIKE wa_header-info,
             ld_lines TYPE i,
             ld_linesc(10) TYPE c.
      wa_header-typ  = 'H'.
    T_HEADER-INFO = 'LIST OF GSM WISE OPEN SALE ORDERS'.
      wa_header-info = str1.
      APPEND wa_header TO t_header.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = t_header[].
    ENDFORM.                    "TOP_OF_PAGE
    here it_main internal table having all data. but output is showing few records only.
    pl. give some idea.
    Thanks & Regards
    Srinivas.

Maybe you are looking for