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_

Similar Messages

  • GL Account analysis report with ALV Grid control

    Hi Everyone,
    I am looking for a GL Account analysis report with ALV Grid Control.
    Can I get sample code for this report.
    Thank you
    Prasad

    Hi Rob,
    Actually, I am searching for a Report which gives GL account analysis.
    If anybody can throw more light on this ...it would be great.
    Which Tables and fields i should refer for this report.
    Thanks

  • Problem with alv grid control editable

    Hello all. I ask your help with this question because I did not find the answer in the forum. Sorry for my pour english.
    I have an alv grid control (OO) with the standards buttons 'insert a line', 'delete a line', 'copy a line'.
    My problem is I want to catch the event of these buttons, because after I register the events mc_evt_enter y mc_evt_modifies, when I push the button to insert a new line the alv grid show the new line and then get a dump with error: Field symbol has not yet been assigned.
    My problem is that no event is launched when I push the button. I tried to catch the event before command but it does not happen.
    It is like these standard buttons works apart and it is not possible to find out what they are doing.
    I have read the manual easy reference for alv grid control, and I created the class lcl_event_handler exactly equal.
    I have tried to debug the code in order to find the error but I can find out where it has been done.
    Thank you in advance. If anybody needs to see my code I will send you or post you.

    David,
    What you need to do for that is to enable the editing field by field. You will have to add a field STYLE type LVC_T_STYL to the DATA table. This nested internal table will hold the information for each field of the row, whether the column is editable or not. So, if you have 5 columns, then the nested internal table will have 5 rows for each row of the main internal table.
    Once this is done, you will have to append a blank row to the table, making all the fields editable and REFRESH the display.
    Regards,
    Ravi
    Note: Please mark the answers as helpful if they help.

  • Problem in handling double click in the second alv grid control

    Hi all,
    I have a screen. In the screen , I have 2 custom container and each custom container has 1 alv grid control.
    I need to handle double click event for both of alv grid controls in my screen.
    I defined 2 local event handler class for each alv grid and defined 2 handle_double_click event.
    In the first Alv grid double click works fine , everything is ok, world is peaceful.
    But in the second alvgrid, the row parameters (E_ROW, E_COLUMN, ES_ROW_NO) comes initial so i cannot handle it.
    All i need is to call a different transaction (displaying the equipment-IE03) when user double-click on a field in the second alv grid control. I tried to use hotspot_click event too but it does'nt give the row id either.
    I read some posts in the forms ([Double click event of alv grid control|Double click event of alv grid control]).
    I tried everything but nothing works.
    Please help. Your answers will be appreciated.

    Hello Eagle
    I am not sure where the problem lies in your case but sample report ZUS_SDN_THREE_ALV_GRIDS_01 shows that you can always find out the current cell after the double-click event (in any case you have the current cell already as IMPORTING parameters of the event):
    *& Report  ZUS_SDN_THREE_ALV_GRIDS_01
    *& Flow logic of screen '0100' (no screen elements, ok-code => GD_OKCODE):
    **    PROCESS BEFORE OUTPUT.
    **      MODULE STATUS_0100.
    **    PROCESS AFTER INPUT.
    **      MODULE USER_COMMAND_0100.
    *& Thread: problem in handling double click in the second alv grid control
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1172052"></a>
    REPORT  zus_sdn_three_alv_grids_01.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syst-repid,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_splitter      TYPE REF TO cl_gui_splitter_container,
      go_splitter_2    TYPE REF TO cl_gui_splitter_container,
      go_cell_top      TYPE REF TO cl_gui_container,
      go_cell_bottom   TYPE REF TO cl_gui_container,
      go_cell_left     TYPE REF TO cl_gui_container,
      go_cell_right    TYPE REF TO cl_gui_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid,
      go_grid3         TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_outtab        TYPE STANDARD TABLE OF vbak,
      gt_outtab_2      TYPE STANDARD TABLE OF vbap,
      gt_outtab_3      TYPE STANDARD TABLE OF vbep.
    **PARAMETERS:
    **  p_bukrs          TYPE bukrs  DEFAULT '1000'.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          ms_row      TYPE lvc_s_row,
          ms_col      TYPE lvc_s_col.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_double_click.
    *   define local data
        DATA:
          ls_outtab      TYPE vbak,
          ls_outtab_2    TYPE vbap,
          ls_outtab_3    TYPE vbep.
        "   Initialize class data
        CLEAR: ms_row,
               ms_col.
        CASE sender.
          WHEN go_grid1.
            ms_row = e_row.
            ms_col = e_column.
    *       Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code
              EXPORTING
                new_code = 'GET_ITEMS'
    *          IMPORTING
    *            rc       =
          WHEN go_grid2.
            ms_row = e_row.
            ms_col = e_column.
    *       Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code
              EXPORTING
                new_code = 'GET_SCHEDULE_LINES'
    *          IMPORTING
    *            rc       =
          WHEN go_grid3.
    **        READ TABLE gt_vbap INTO ls_vbap INDEX e_row-index.
    **        CHECK ( ls_vbap-matnr IS NOT INITIAL ).
    **        SET PARAMETER ID 'MAT' FIELD ls_vbap-matnr.
    **        CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
          WHEN OTHERS.
            RETURN.
        ENDCASE.
      ENDMETHOD.                    "handle_double_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT        * FROM  vbak INTO TABLE gt_outtab UP TO 100 ROWS.
      PERFORM init_controls.
    * Display data
      CALL METHOD go_grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAK'
        CHANGING
          it_outtab        = gt_outtab
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      REFRESH: gt_outtab_2.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAP'
        CHANGING
          it_outtab        = gt_outtab_2    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      REFRESH: gt_outtab_3.
      CALL METHOD go_grid3->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBEP'
        CHANGING
          it_outtab        = gt_outtab_3    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * NOTE: dynpro does not contain any elements
      CALL SCREEN '0100'.
    * Flow logic of dynpro:
    *PROCESS BEFORE OUTPUT.
    *  MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    *  MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "ORDERS"
    *  SET TITLEBAR 'xxx'.
    * Refresh display of detail ALV list
      CALL METHOD go_grid2->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Refresh display of detail ALV list
      CALL METHOD go_grid3->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        " Double-click on first or second ALV grid
        WHEN 'GET_ITEMS'  OR
             'GET_SCHEDULE_LINES'.
          PERFORM get_details.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create splitter container
      CREATE OBJECT go_splitter
        EXPORTING
          parent            = go_docking
          rows              = 1
          columns           = 2
    *      NO_AUTODEF_PROGID_DYNNR =
    *      NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Get cell container
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_left.
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 2
        RECEIVING
          container = go_cell_right.
    * Create 2nd splitter container
      CREATE OBJECT go_splitter_2
        EXPORTING
          parent            = go_cell_left
          rows              = 2
          columns           = 1
    *      NO_AUTODEF_PROGID_DYNNR =
    *      NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Get cell container
      CALL METHOD go_splitter_2->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_top.
      CALL METHOD go_splitter_2->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = go_cell_bottom.
    * Create ALV grids
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent = go_cell_top
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid2
        EXPORTING
          i_parent = go_cell_bottom
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid3
        EXPORTING
          i_parent = go_cell_right
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Set event handler
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid2.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid3.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  GET_DETAILS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_details .
    * define local data
      DATA: ls_row      TYPE lvc_s_row,
            ls_col      TYPE lvc_s_col.
      data: ls_outtab   type vbak,
            ls_outtab_2 type vbap,
            ls_outtab_3 type vbep.
      BREAK-POINT.
      CASE gd_okcode.
        WHEN 'GET_ITEMS'.
          CALL METHOD go_grid1->get_current_cell
            IMPORTING
    *          e_row     =
    *          e_value   =
    *          e_col     =
              es_row_id = ls_row
              es_col_id = ls_col
    *          es_row_no =
          read TABLE gt_outtab into ls_outtab index ls_row-index.
          refresh: gt_outtab_2,
                   gt_outtab_3.
          SELECT        * FROM  vbap into TABLE gt_outtab_2
                 WHERE  vbeln  = ls_outtab-vbeln.
        WHEN 'GET_SCHEDULE_LINES'.
          CALL METHOD go_grid2->get_current_cell
            IMPORTING
    *          e_row     =
    *          e_value   =
    *          e_col     =
              es_row_id = ls_row
              es_col_id = ls_col
    *          es_row_no =
          READ TABLE gt_outtab_2 into ls_outtab_2 index ls_row-index.
          refresh: gt_outtab_3.
          SELECT        * FROM  vbep into TABLE gt_outtab_3
                 WHERE  vbeln  = ls_outtab_2-vbeln
                 AND    posnr  = ls_outtab_2-posnr.
        WHEN OTHERS.
          RETURN.
      ENDCASE.
      IF ( lcl_eventhandler=>ms_row = ls_row  AND
           lcl_eventhandler=>ms_col = ls_col ).
        MESSAGE 'Current cell identical'  TYPE 'I'.
      ELSE.
        MESSAGE 'Current cell NOT identical'  TYPE 'I'.
      ENDIF.
    ENDFORM.                    " GET_DETAILS
    Regards
      Uwe

  • ALV GRID Control Problem

    I am using ALV Grid Control ABAP Objects concept.
    I am facing problem in it , if i click on any record it will display me the output , but when i click on any other report it is still
    displaying me the 1st record output.
    for eq. i clicked on 000002121 it will display me internal table related to this document but when i click on
    000002122 it is showing IT of previous document only. 
    How to refresh the display in gui with new record

    Hi
    Check your double click method implementation. How you are retrieving the value of the selected item.
    sample code for hotspot click
    CALL METHOD grid1->get_current_cell
        IMPORTING
          e_row     = w_row
          e_value   = w_value
          e_col     = w_col

  • How to print multiple ALV Grids with only one print dialog?

    Hi,
    I have a report that has multiple ALV grids in splitter containers. The users want to be able to print those ALVs by pushing only one print button. I got it to work (parameter IS_PRINT and method SET_FRONTEND_PRINT before calling SET_TABLE_FOR_FIRST_DISPLAY) but I can't find a way to avoid that the printer dialog pops up for every grid I print.
    I tried to use the function module approach with REUSE_ALV_LIST_DISPLAY but have the same issue. Any thoughts?
    Thanks,
    Guenther

    Hi Peluka,
    Well, that's exactly what I am doing. Putting one central button in the app is not the problem; the issue is that the print dialog (to select the printer) pops up for every  individual ALV grid. E.g. if I place 4 ALV grids on my screen and trigger their print from a central button, I am getting 4 print dialogs.
    Cheers,
    Guenther

  • Multiple ALV GRID reports on a single page

    hi all
    I have an  urgent requirement where I need to show 2-3 alv grids on a single page. Please let me know if it is possible to do so. If yes how. Sample code would be very helpful.
    thanks in advance.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 16, 2008 1:45 PM

    HI,
    Create multiple custom containers and call the method   CALL METHOD sap_grid->set_table_for_first_display multiple times.
    This will display multiple ALV grids on a single page.
    Code Below:
    MODULE create_objects OUTPUT.
      CREATE OBJECT g_custom_container
         EXPORTING
       PARENT                      =
           container_name              = 'CUST_CRTL'
       STYLE                       =
       LIFETIME                    = lifetime_default
       REPID                       =
       DYNNR                       =
       NO_AUTODEF_PROGID_DYNNR     =
      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 e143(z1).
      ENDIF.
    *Create object for sap grid
      CREATE OBJECT sap_grid
        EXPORTING
         I_SHELLSTYLE      = 0
         I_LIFETIME        =
           i_parent          = g_custom_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 e144(z1).
      ENDIF.
      CREATE OBJECT g_custom_container1
         EXPORTING
       PARENT                      =
           container_name              = 'CUST_CRTL1'
       STYLE                       =
       LIFETIME                    = lifetime_default
       REPID                       =
       DYNNR                       =
       NO_AUTODEF_PROGID_DYNNR     =
      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 e143(z1).
      ENDIF.
    *Create object for sap grid
      CREATE OBJECT sap_grid1
        EXPORTING
         I_SHELLSTYLE      = 0
         I_LIFETIME        =
           i_parent          = g_custom_container1
         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 e144(z1).
      ENDIF.
      CREATE OBJECT g_custom_container2
         EXPORTING
       PARENT                      =
           container_name              = 'CUST_CRTL2'
       STYLE                       =
       LIFETIME                    = lifetime_default
       REPID                       =
       DYNNR                       =
       NO_AUTODEF_PROGID_DYNNR     =
      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 e143(z1).
      ENDIF.
    *Create object for sap grid
      CREATE OBJECT sap_grid2
        EXPORTING
         I_SHELLSTYLE      = 0
         I_LIFETIME        =
           i_parent          = g_custom_container2
         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 e144(z1).
      ENDIF.
    ENDMODULE.                 " create_objects  OUTPUT
    *&      Module  fill_fcat  OUTPUT
          text
    MODULE fill_fcat OUTPUT.
      CONSTANTS : lc_x TYPE c VALUE 'X',
                  lc_a TYPE c VALUE 'D'.
    *Prepare field catalog for all Summary Report
      wa_field-fieldname = 'BUKRS'.
      wa_field-tabname = 'T_BSID_BSAD'.
      wa_field-outputlen = '12'.
      wa_field-col_pos = '1'.
      wa_field-coltext = text-002. "'Company Code'.
      APPEND wa_field TO fcat.
    CLEAR wa_field.
    wa_field-fieldname = 'CURR'.
    wa_field-tabname = 'T_BSID_BSAD'.
    wa_field-outputlen = '10'.
    wa_field-col_pos = '2'.
    wa_field-coltext = text-022."'Currency'.
    APPEND wa_field TO fcat.
      CLEAR wa_field.
      wa_field-fieldname = 'KUNNR'.
      wa_field-tabname = 'T_BSID_BSAD'.
      wa_field-outputlen = '10'.
      wa_field-col_pos = '3'.
      wa_field-coltext = text-005."'Customer Number'.
      APPEND wa_field TO fcat.
      CLEAR wa_field.
      wa_field-fieldname = 'NAME1'.
      wa_field-tabname = 'T_BSID_BSAD'.
    wa_field-outputlen = '13'.
      wa_field-col_pos = '4'.
      wa_field-coltext = text-007."'Customer Name'.
      APPEND wa_field TO fcat.
      CLEAR wa_field.
      wa_field-fieldname = 'KLIMK'.
      wa_field-tabname = 'T_BSID_BSAD'.
      wa_field-outputlen = '12'.
      wa_field-col_pos = '5'.
      wa_field-coltext = text-008. " 'Credit Limit'.
      APPEND wa_field TO fcat.
      CLEAR wa_field.
      wa_field-fieldname = 'DMBTR'.
      wa_field-tabname = 'T_BSID_BSAD'.
    wa_field-outputlen = '16'.
      wa_field-col_pos = '6'.
      wa_field-coltext = text-009. "'Current Balance Calculated'.
      APPEND wa_field TO fcat.
      CLEAR wa_field.
      CLEAR wa_field.
      wa_field-fieldname = 'BLNC'.
      wa_field-tabname = 'T_BSID_BSAD'.
      wa_field-outputlen = '23'.
      wa_field-col_pos = '7'.
      wa_field-coltext = g_bal_date. "'Balance b/f @ (Date taken from Z table) '.
      wa_field-fix_column = 'X'.
      APPEND wa_field TO fcat.
      CLEAR wa_field.
    CLEAR wa_field.
    wa_field-fieldname = 'DATE'.
    wa_field-tabname = 'T_BSID_BSAD'.
    wa_field-outputlen = '8'.
    wa_field-col_pos = '7'.
    wa_field-coltext = text-021. "'Balance b/f Date @ Z Table balance'.
    APPEND wa_field TO fcat.
    CLEAR wa_field.
      CLEAR wa_field.
      wa_field-fieldname = 'INVOICES'.
      wa_field-tabname = 'T_BSID_BSAD'.
    wa_field-outputlen = '13'.
      wa_field-col_pos = '8'.
      wa_field-coltext = text-012. "'Invoices'.
      APPEND wa_field TO fcat.
      CLEAR wa_field.
      CLEAR wa_field.
      wa_field-fieldname = 'PAYMENTS'.
      wa_field-tabname = 'T_BSID_BSAD'.
    wa_field-outputlen = '13'.
      wa_field-col_pos = '9'.
      wa_field-coltext = text-013. "'Payments'.
      APPEND wa_field TO fcat.
      CLEAR wa_field.
      CLEAR wa_field.
      wa_field-fieldname = 'DMBTR'.
      wa_field-tabname = 'T_BSID_BSAD'.
      wa_field-outputlen = '23'.
      wa_field-col_pos = '10'.
      wa_field-coltext = g_bal_date1. "'Balance c/f @ (Date of Lodgement from selection screen)'.
      APPEND wa_field TO fcat.
      CLEAR wa_field.
      CLEAR wa_field.
      wa_field-fieldname = 'CHECK'.
      wa_field-tabname = 'T_BSID_BSAD'.
    wa_field-outputlen = '13'.
      wa_field-col_pos = '11'.
      wa_field-coltext = text-020. "'CHECK'.
      APPEND wa_field TO fcat.
      CLEAR wa_field.
      CLEAR g_layout.
      g_layout-zebra = lc_x.
    g_layout-sel_mode = lc_a.
    *Prepare field catalog for all Invoice Extract
      wa_field1-fieldname = 'BUKRS'.
      wa_field1-tabname = 'T_INVOICE'.
      wa_field1-outputlen = '12'.
      wa_field1-col_pos = '1'.
      wa_field1-coltext = text-002. "'Company Code'.
      APPEND wa_field1 TO fcat1.
      CLEAR wa_field1.
      wa_field1-fieldname = 'KUNNR'.
      wa_field1-tabname = 'T_INVOICE'.
      wa_field1-outputlen = '13'.
      wa_field1-col_pos = '2'.
      wa_field1-coltext = text-005."'Customer Number'.
      APPEND wa_field1 TO fcat1.
      CLEAR wa_field1.
      wa_field1-fieldname = 'NAME1'.
      wa_field1-tabname = 'T_INVOICE'.
      wa_field1-outputlen = '13'.
      wa_field1-col_pos = '3'.
      wa_field1-coltext = text-007."'Customer Name'.
      APPEND wa_field1 TO fcat1.
      CLEAR wa_field1.
      wa_field1-fieldname = 'GJAHR'.
      wa_field1-tabname = 'T_INVOICE'.
      wa_field1-outputlen = '7'.
      wa_field1-col_pos = '4'.
      wa_field1-coltext = text-015. " 'Fiscal Year'.
      APPEND wa_field1 TO fcat1.
      CLEAR wa_field1.
      wa_field1-fieldname = 'BELNR'.
      wa_field1-tabname = 'T_INVOICE'.
    wa_field1-outputlen = '10'.
      wa_field1-col_pos = '5'.
      wa_field1-coltext = text-016. "'Invoice Number'.
      APPEND wa_field1 TO fcat1.
      CLEAR wa_field1.
      CLEAR wa_field1.
      wa_field1-fieldname = 'CURR'.
      wa_field1-tabname = 'T_INVOICE'.
      wa_field1-outputlen = '8'.
      wa_field1-col_pos = '6'.
      wa_field1-coltext = text-022."'Currency'.
      APPEND wa_field1 TO fcat1.
      CLEAR wa_field1.
      wa_field1-fieldname = 'DMBTR'.
      wa_field1-tabname = 'T_INVOICE'.
      wa_field1-outputlen = '13'.
      wa_field1-col_pos = '7'.
      wa_field1-coltext = text-017. "'Invoice Amount '.
      APPEND wa_field1 TO fcat1.
      CLEAR wa_field1.
      CLEAR wa_field1.
      wa_field1-fieldname = 'BLDAT'.
      wa_field1-tabname = 'T_INVOICE'.
      wa_field1-outputlen = '12'.
      wa_field1-col_pos = '8'.
      wa_field1-coltext = text-018. "'Date of Shipment'.
      APPEND wa_field1 TO fcat1.
      CLEAR wa_field1.
      CLEAR wa_field1.
      wa_field1-fieldname = 'DUEDT'.
      wa_field1-tabname = 'T_INVOICE'.
      wa_field1-outputlen = '13'.
      wa_field1-col_pos = '9'.
      wa_field1-coltext = text-019. "'Due Date Calculated'.
      APPEND wa_field1 TO fcat1.
      CLEAR wa_field1.
      CLEAR g_layout1.
      g_layout1-zebra = lc_x.
    g_layout-sel_mode = lc_a.
    *Prepare field catalog for all Payment Extract
      CLEAR wa_field2.
      wa_field2-fieldname = 'BUKRS'.
      wa_field2-tabname = 'T_PAYMENT'.
      wa_field2-outputlen = '12'.
      wa_field2-col_pos = '1'.
      wa_field2-coltext = text-002. "'Company Code'.
      APPEND wa_field2 TO fcat2.
      CLEAR wa_field2.
      CLEAR wa_field2.
      wa_field2-fieldname = 'KUNNR'.
      wa_field2-tabname = 'T_PAYMENT'.
    wa_field2-outputlen = '13'.
      wa_field2-col_pos = '2'.
      wa_field2-coltext = text-005. "'Customer Number'.
      APPEND wa_field2 TO fcat2.
      CLEAR wa_field2.
      CLEAR wa_field2.
      wa_field2-fieldname = 'NAME1'.
      wa_field2-tabname = 'T_PAYMENT'.
      wa_field2-outputlen = '13'.
      wa_field2-col_pos = '3'.
      wa_field2-coltext = text-007. "'Customer Name'.
      APPEND wa_field2 TO fcat2.
      CLEAR wa_field2.
      CLEAR wa_field2.
      wa_field2-fieldname = 'GJAHR'.
      wa_field2-tabname = 'T_PAYMENT'.
      wa_field2-outputlen = '11'.
      wa_field2-col_pos = '4'.
      wa_field2-coltext = text-015. "'Fiscal Year'.
      APPEND wa_field2 TO fcat2.
      CLEAR wa_field2.
      CLEAR wa_field2.
      wa_field2-fieldname = 'BELNR'.
      wa_field2-tabname = 'T_PAYMENT'.
      wa_field2-outputlen = '13'.
      wa_field2-col_pos = '5'.
      wa_field2-coltext = text-016. "'Invoice Number'.
      APPEND wa_field2 TO fcat2.
      CLEAR wa_field2.
      CLEAR wa_field2.
      wa_field2-fieldname = 'CURR'.
      wa_field2-tabname = 'T_PAYMENT'.
      wa_field2-outputlen = '11'.
      wa_field2-col_pos = '6'.
      wa_field2-coltext = text-022."'Currency'.
      APPEND wa_field2 TO fcat2.
      CLEAR wa_field2.
      wa_field2-fieldname = 'DMBTR'.
      wa_field2-tabname = 'T_PAYMENT'.
      wa_field2-outputlen = '13'.
      wa_field2-col_pos = '7'.
      wa_field2-coltext = text-017. "'Invoice Amount'.
      APPEND wa_field2 TO fcat2.
      CLEAR wa_field2.
      CLEAR g_layout2.
      g_layout2-zebra = lc_x.
    g_layout-sel_mode = lc_a.
    ENDMODULE.                 " fill_fcat  OUTPUT
    *&      Module  display_data  OUTPUT
          text
    MODULE display_data OUTPUT.
      g_layout3-variant = g_save.
      CALL METHOD sap_grid->set_table_for_first_display
         EXPORTING
          I_BUFFER_ACTIVE               =
          I_BYPASSING_BUFFER            =
          I_CONSISTENCY_CHECK           =
            i_structure_name              = 'gt_display'
            is_variant                    =  g_layout3
            i_save                        =  'A'
            i_default                     =  'X'
             is_layout                     = g_layout
          IS_PRINT                      =
          IT_SPECIAL_GROUPS             =
          IT_TOOLBAR_EXCLUDING          =
          IT_HYPERLINK                  =
          IT_ALV_GRAPHICS               =
          IT_EXCEPT_QINFO               =
         CHANGING
            it_outtab                     = t_bsid_bsad
            it_fieldcatalog               = fcat
          IT_SORT                       =
          IT_FILTER                     =
         EXCEPTIONS
           invalid_parameter_combination = 1
           program_error                 = 2
           too_many_lines                = 3
           OTHERS                        = 4 .
      IF sy-subrc <> 0.
        MESSAGE e145(z1).
      ENDIF.
      g_layout4-variant = g_save1.
      CALL METHOD sap_grid1->set_table_for_first_display
           EXPORTING
          I_BUFFER_ACTIVE               =
          I_BYPASSING_BUFFER            =
          I_CONSISTENCY_CHECK           =
            i_structure_name              = 'gt_display1'
            is_variant                    = g_layout4
            i_save                        = 'A'
            i_default                     = 'X'
            is_layout                     = g_layout1
          IS_PRINT                      =
          IT_SPECIAL_GROUPS             =
          IT_TOOLBAR_EXCLUDING          =
          IT_HYPERLINK                  =
          IT_ALV_GRAPHICS               =
          IT_EXCEPT_QINFO               =
           CHANGING
              it_outtab                     = t_invoice
              it_fieldcatalog               = fcat1
          IT_SORT                       =
          IT_FILTER                     =
           EXCEPTIONS
             invalid_parameter_combination = 1
             program_error                 = 2
             too_many_lines                = 3
             OTHERS                        = 4 .
      IF sy-subrc <> 0.
        MESSAGE e145(z1).
      ENDIF.
      g_layout5-variant = g_save2.
      CALL METHOD sap_grid2->set_table_for_first_display
         EXPORTING
          I_BUFFER_ACTIVE               =
          I_BYPASSING_BUFFER            =
          I_CONSISTENCY_CHECK           =
            i_structure_name              = 'gt_display2'
            is_variant                    =  g_layout5
            i_save                        =  'A'
            i_default                     = 'X'
            is_layout                     = g_layout2
          IS_PRINT                      =
          IT_SPECIAL_GROUPS             =
          IT_TOOLBAR_EXCLUDING          =
          IT_HYPERLINK                  =
          IT_ALV_GRAPHICS               =
          IT_EXCEPT_QINFO               =
         CHANGING
            it_outtab                     = t_payment
            it_fieldcatalog               = fcat2
          IT_SORT                       =
          IT_FILTER                     =
         EXCEPTIONS
           invalid_parameter_combination = 1
           program_error                 = 2
           too_many_lines                = 3
           OTHERS                        = 4 .
      IF sy-subrc <> 0.
        MESSAGE e145(z1).
      ENDIF.
    ENDMODULE.                 " display_data  OUTPUT
    *&      Module  exit  INPUT
          text
    MODULE exit INPUT.
      CALL METHOD g_custom_container->free.
      CLEAR t_bsid_bsad[].
      CALL METHOD g_custom_container1->free.
      CLEAR t_invoice[].
      CALL METHOD g_custom_container2->free.
      CLEAR t_payment[].
      LEAVE PROGRAM.
    ENDMODULE.                 " exit  INPUT
    *&      Module  user_command_1100  INPUT
          text
    MODULE user_command_1100 INPUT.
      MOVE g_ok_code TO g_saveok_code.
      CLEAR g_ok_code.
      CASE g_saveok_code.
    *on BACK leave program
        WHEN 'BACK'.
          CALL METHOD g_custom_container->free.
          CALL METHOD g_custom_container1->free.
          CALL METHOD g_custom_container2->free.
          CLEAR: g_custom_container,
                 g_custom_container1,
                 g_custom_container2.
         LEAVE PROGRAM.
         SET SCREEN 1000.
         CALL TRANSACTION 'Z5172'.
         CALL SELECTION-SCREEN 1000.
          set screen 0.
          leave screen.
    *on CANCEL leave program
        WHEN 'EXIT'.
          CALL METHOD g_custom_container->free.
          CALL METHOD g_custom_container1->free.
          CALL METHOD g_custom_container2->free.
          LEAVE PROGRAM.
    *on CANCEL leave program
        WHEN 'CANCEL'.
          CALL METHOD g_custom_container->free.
          CALL METHOD g_custom_container1->free.
          CALL METHOD g_custom_container2->free.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " user_command_1100  INPUT

  • ALV Editable Grid Control F4 help problem

    HI Experts,
    am facing some funny and critical problem in ALV Editable GRID,that is i used OOPS concept for ALV GRID Control output,
    in fieldcatalog i given for fields as
      wafieldcatlog-f4availabl = 'X'.
      wafieldcatlog-ref_table  = 'table'.
      wafieldcatlog-ref_field  = 'field'.
    and for seven fields i given like this .
    but in that editable if i use F4 help for the field and get that data and later save means that data is not considering and giving error message.
    So can any one please help if u confused pls reply fo any clarifications, pls help me out in this situation.
    THX

    wafieldcatlog-f4availabl = 'X'.
    wafieldcatlog-ref_table = 'table'. "should be in caps
    wafieldcatlog-ref_field = 'field'. "should be in caps.
    what error you are getting while saving..?

  • Max no of records that can be dispalyed using ALV GRID CONTROLS

    Hi ,
    Can any one please tell me the maximum no of records that are allowed to be displayed using the ALV grid controls.
    As I am getting dump for more records and I need to control the report based on the max no of records that can be actually diplayed using contols.
    Thanks,
    Kavya.

    Dear Kavya.
    If you are getting Dump because you have too many records it means that there is something wrong with the program design.
    ALV is not meant to display more than few thousands of records.
    There is no point is displaying more than few thousands because it will over-flow the users and it will do no good for them.
    If the problem is with the Internal-tables that you're using to manipulate the data, you can think of using an intermidiate DB table that will hold summarized data of the DB data and can be filled via a periodic job. This have the benfit of speeding up the ALV program too.
    thanx
    ayal.

  • 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

  • Field symbol has not yet been defined-ALV Grid Display in Report

    Hi all,
              Iam calling a Function module for ALV grid display in Report programming. Its throwing the Error message Field Symbol has not yet defined. Can any one suggest what i have to do regarding it?

    Hi,
    <li> This is problem with fieldcatalog.
    <li> Check field names or table name in small letters in quotes while building fieldcatalog internal table
    <li> Check the fieldcatalog internal table , whether it has same fields as in data table which is shown using GRID_DISPLAY function module.
    Thanks
    Venkat.O

  • Multiple ALV Grids on the same window.

    Hi,
    Can someone tell me if it's possible to display multiple ALV grids on the same window.If so how is it done.Please note that I am talking about Grid Display and not List Display.
    Regards,
    Swathi Balakrishnan

    Hi,
    This can be done even i have done a report.
    Its very simple create three containers as below.
    Just repeat three times if u need to create three containers.
    See this sample code using custom container.
    START-OF-SELECTION.
    Begin of process logic
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS01'.
      SET TITLEBAR 'SALESTTL'.
    A L V    G R I D
      IF o_grid_container IS INITIAL.
        CREATE OBJECT o_grid_container
          EXPORTING
            container_name = '<b>CCONTAINER1</b>'.
        CREATE OBJECT o_grid
          EXPORTING
            i_appl_events = 'X'
            i_parent = o_grid_container.
    <b>FOR first A L V    G R I D</b>
        PERFORM set_grid_field_catalog
                    CHANGING i_grid_fcat.
        PERFORM modify_grid_fcat_predisplay
                    CHANGING i_grid_fcat.
        PERFORM set_grid_layout_set
                    CHANGING struct_grid_lset.
        PERFORM sort_outtable CHANGING i_sort_fcat.
    PERFORM populate_grid_data  TABLES i_grid_outs i_grid_outs_pro.
        SORT i_grid_outs BY year month.
        CALL METHOD o_grid->set_table_for_first_display
          EXPORTING
            i_bypassing_buffer    =  space
            is_variant            =  ws_f_grid_disvar
            i_save                =  ws_c_grid_save
            is_layout             =  struct_grid_lset
          CHANGING
            it_outtab             =  i_grid_outs[]
            it_fieldcatalog       =  i_grid_fcat[]
            it_sort               =  i_sort_fcat.      " Period
      ENDIF.
      IF o_grid1_container IS INITIAL.
        CREATE OBJECT o_grid1_container
          EXPORTING
            container_name = '<b>CCONTAINER2</b>'.
        CREATE OBJECT o_grid1
          EXPORTING
            i_appl_events = 'X'
            i_parent = o_grid1_container.
    *<b> FOR SECOND ALV GRID</b>
        PERFORM set_grid1_field_catalog
                    CHANGING i_grid1_fcat.
        PERFORM modify_grid1_fcat_predisplay
                    CHANGING i_grid1_fcat.
        PERFORM set_grid1_layout_set
                    CHANGING struct_grid1_lset.
        PERFORM sort_outtable1 CHANGING i_sort_fcat1.
    PERFORM populate_grid1_data  TABLES i_grid1_outs i_grid1_outs_pro.
        SORT i_grid1_outs BY year month.
        CALL METHOD o_grid1->set_table_for_first_display
          EXPORTING
            i_bypassing_buffer    =  space
            is_variant            =  ws_f_grid_disvar
            i_save                =  ws_c_grid_save
            is_layout             =  struct_grid1_lset
          CHANGING
            it_outtab             =  i_grid1_outs[]
            it_fieldcatalog       =  i_grid1_fcat[]
            it_sort               =  i_sort_fcat1.      " Period
      ENDIF.
      IF o_grid2_container IS INITIAL.
        CREATE OBJECT o_grid2_container
          EXPORTING
            container_name = '<b>CCONTAINER3</b>'.
        CREATE OBJECT o_grid2
          EXPORTING
            i_appl_events = 'X'
            i_parent = o_grid2_container.
    <b>FOR THIRD ALV GRID</b>
        PERFORM set_grid2_field_catalog
                    CHANGING i_grid2_fcat.
        PERFORM modify_grid2_fcat_predisplay
                    CHANGING i_grid2_fcat.
        PERFORM set_grid2_layout_set
                    CHANGING struct_grid2_lset.
    PERFORM populate_grid2_data  TABLES i_grid2_outs i_grid2_outs_pro.
        SORT i_grid2_outs BY year month.
        PERFORM sort_outtable2 CHANGING i_sort_fcat2.
        CALL METHOD o_grid2->set_table_for_first_display
          EXPORTING
            i_bypassing_buffer    =  space
            is_variant            =  ws_f_grid_disvar
            i_save                =  ws_c_grid_save
            is_layout             =  struct_grid2_lset
          CHANGING
            it_outtab             =  i_grid2_outs[]
            it_fieldcatalog       =  i_grid2_fcat[]
            it_sort               =  i_sort_fcat2.      " Period
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
    As the events are registered as application events, control is first
    passed to the program's PAI. The call 'cl_gui_cfw=>dispatch' will
    forward control to ABAP object event handling and the appropriate
    event handler will be called (if present). This allows the user to
    selectively process events.
      DATA: i_return_code TYPE i .
      CALL METHOD cl_gui_cfw=>dispatch
          IMPORTING return_code = i_return_code.
      save_ok = ok_code.
      CASE save_ok.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
      ENDCASE.
      CLEAR save_ok.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  EXIT_PROGRAM
          text
    FORM exit_program.
      CALL METHOD o_grid_container->free.
      CALL METHOD o_grid1_container->free.
      CALL METHOD o_grid2_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc NE 0.
        Error in FLush
      ENDIF.
      LEAVE TO SCREEN 0.
    ENDFORM.                  " EXIT_PROGRAM
    If u want get more idea revert back to me.
    Thanks & Regards,
    Judith.

  • Doubt in ALV Grid Control

    Hi Everyone,
    I am working on ALV Grid Control, where i am facing a problem with adding new buttons and writing the new code for the button, for placing the (display) button i used the method <b>handle_tool_bar</b>, But i want to know how to write the code for this particular button (display).
    Kindly give me the solution for this

    http://www.abap4.it/download/ALV.pdf
    Add the handle so we get user command control (ie Refresh)
    perform add_handle using 'USER_COMMAND' 'PAI_USER_COMMAND'.
    Colour and hotspot the project id column
    w_fieldcat-fieldname = 'PROJECT_ID'.
    w_fieldcat-emphasize = 'C400'.
    w_fieldcat-hotspot = 'X'.
    append w_fieldcat to t_fieldcat.
    Iconify and set the length of the icon column
    clear w_fieldcat.
    w_fieldcat-fieldname = 'ZEXCEPTION'.
    w_fieldcat-icon = 'X'.
    w_fieldcat-outputlen = g_light_length.
    append w_fieldcat to t_fieldcat.
    Intensify every other line, improves readability
    t_layout-zebra = 'X'.
    Set up an exit on the refresh event, so it gets passed back to us
    wa_event_exit-ucomm = '&REFRESH'. " Refresh
    wa_event_exit-after = 'X'.
    append wa_event_exit to t_event_exit.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = 'ZGER_PROJECT_ID' " **CHANGE** !
    i_callback_pf_status_set = 'SET_PF_STATUS'
    i_structure_name = 'ZPROJECT_DATA'
    i_grid_title = 'Project list'
    it_event_exit = t_event_exit
    i_default = 'X'
    it_fieldcat = t_fieldcat
    is_layout = t_layout
    i_save = 'A'
    it_events = t_events
    tables
    t_outtab = t_main
    exceptions
    program_error = 1
    others = 2.

  • Event for the List Box in ALV Grid Control

    Hello,
    I have the below urgent requirment.
    I have an ALV Grid Control built using ABAP Objects. In the grid, I have few fields and one of these fields is a List Box. Depending on the values selected, I need to enable or disable some fields. So, is there any event for the List box in ALV Grid Control.
    For ex: I have 2 Fields, Designation and Commission. The designation field is a List Box field having 'Software Engineer' and 'Manager' as values. When I select 'Software Engineer', the commission field should be disabled. When I select 'Manager', the comission field should be enabled.
    Early reply is hightly appreciated.
    Priya

    REPORT  ZTEST1234    MESSAGE-ID ZZ                           .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_VALID TYPE C,
          V_FLAG,
          V_DATA_CHANGE,
          V_ROW TYPE LVC_S_ROW,
          V_COLUMN TYPE LVC_S_COL,
          V_ROW_NUM TYPE LVC_S_ROID.
    DATA: OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,
          G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
          GS_LAYOUT TYPE LVC_S_LAYO.
    DATA:BEGIN OF  ITAB OCCURS 0,
         VBELN LIKE LIKP-VBELN,
         POSNR LIKE LIPS-POSNR,
         COMISN(10),
         CELLCOLOR TYPE LVC_T_SCOL, "required for color
         DROP(20),
        <b> HANDLE_STYLE TYPE LVC_T_STYL,</b>
         END OF ITAB.
    *       CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                          IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    <b>**Handler to Check the Data Change
        HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
                             OF CL_GUI_ALV_GRID
                             IMPORTING ER_DATA_CHANGED
                                       E_ONF4
                                       E_ONF4_BEFORE
                                       E_ONF4_AFTER,</b>
    **Double Click Handler
        HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                         IMPORTING E_ROW E_COLUMN ES_ROW_NO.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK .
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW_ID.
        V_COLUMN = E_COLUMN_ID.
        V_ROW_NUM = ES_ROW_NO.
        MESSAGE I000 WITH V_ROW 'clicked'.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  HANDLE_DOUBLE_CLICK.
      ENDMETHOD.                    "handle_double_click
    <b>**Handle Data Change
      METHOD HANDLE_DATA_CHANGED.
        DATA: X_CHANGE TYPE LVC_S_MODI,
                X_FINAL TYPE ITAB,
                L_FLAG,
                LS_OUTTAB LIKE LINE OF ITAB.
        DATA: LS_EDIT TYPE LVC_S_STYL,
              LT_EDIT TYPE LVC_T_STYL.
        LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
          IF X_CHANGE-FIELDNAME = 'DROP' AND X_CHANGE-VALUE = 'S/W ENGINEER'.
            LS_EDIT-FIELDNAME = 'COMISN'.
            LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
            LS_EDIT-STYLE2 = SPACE.
            LS_EDIT-STYLE3 = SPACE.
            LS_EDIT-STYLE4 = SPACE.
            LS_EDIT-MAXLEN = 8.
            INSERT LS_EDIT INTO TABLE LT_EDIT.
            INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
            MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB  TRANSPORTING
                                              HANDLE_STYLE .
          else.
            LS_EDIT-FIELDNAME = 'COMISN'.
            LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
            LS_EDIT-STYLE2 = SPACE.
            LS_EDIT-STYLE3 = SPACE.
            LS_EDIT-STYLE4 = SPACE.
            LS_EDIT-MAXLEN = 8.
            INSERT LS_EDIT INTO TABLE LT_EDIT.
            INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
            MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB  TRANSPORTING
                                              HANDLE_STYLE .
          ENDIF.
        ENDLOOP.
        CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
          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.
      ENDMETHOD.                    "HANDLE_DATA_CHANGED</b>
    ENDCLASS.                    "LCL_EVENT_HANDLER IMPLEMENTATION
    *&             Global Definitions
    DATA:      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
                G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    *- Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
          X_FIELDCAT TYPE LVC_S_FCAT,
          LS_VARI  TYPE DISVARIANT.
    *                START-OF_SELECTION
    START-OF-SELECTION.
      SELECT VBELN
             POSNR
             FROM LIPS
             UP TO 20 ROWS
             INTO CORRESPONDING FIELDS OF TABLE ITAB.
    END-OF-SELECTION.
      IF NOT ITAB[] IS INITIAL.
        CALL SCREEN 100.
      ELSE.
        MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
      ENDIF.
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    FORM CREATE_AND_INIT_ALV .
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
      CREATE OBJECT G_CUSTOM_CONTAINER
             EXPORTING CONTAINER_NAME = G_CONTAINER1.
      CREATE OBJECT G_GRID
             EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
    * Set a titlebar for the grid control
      CLEAR GS_LAYOUT.
      GS_LAYOUT-GRID_TITLE = TEXT-003.
       <b>GS_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.</b>
      GS_LAYOUT-ZEBRA = SPACE.
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-NO_ROWMARK = 'X'.
      GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
    <b>  CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.</b>
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
      SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
    <b>  SET HANDLER G_HANDLER->HANDLE_DATA_CHANGED FOR G_GRID.</b>
      DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
      DATA: L_INDEX TYPE SY-TABIX.
      "Here i am changing the color of line 1,5,10...
      "so you can change the color of font conditionally
      LOOP AT ITAB.
        L_INDEX = SY-TABIX.
        IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
          LS_CELLCOLOR-FNAME = 'VBELN'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
          LS_CELLCOLOR-FNAME = 'POSNR'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
        ENDIF.
      ENDLOOP.
    * setting focus for created grid control
      CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
        EXPORTING
          CONTROL = G_GRID.
    * Build fieldcat and set editable for date and reason code
    * edit enabled. Assign a handle for the dropdown listbox.
      PERFORM BUILD_FIELDCAT.
      PERFORM  SET_DRDN_TABLE.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
      LS_VARI-REPORT      = SY-REPID.
      LS_VARI-HANDLE      = SPACE.
      LS_VARI-LOG_GROUP   = SPACE.
      LS_VARI-USERNAME    = SPACE.
      LS_VARI-VARIANT     = SPACE.
      LS_VARI-TEXT        = SPACE.
      LS_VARI-DEPENDVARS  = SPACE.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
    **Calling the Method for ALV output
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          IS_VARIANT           = LS_VARI
          IS_LAYOUT            = GS_LAYOUT
          I_SAVE               = 'A'
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
    * Set editable cells to ready for input initially
      CALL METHOD G_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA LS_EXCLUDE TYPE UI_FUNC.
      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.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_fieldcat
    *       Fieldcatalog
    FORM BUILD_FIELDCAT .
      DATA: L_POS TYPE I.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-NO_ZERO    = 'X'.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Item'(025).
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
      X_FIELDCAT-FIELDNAME = 'DROP'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      X_FIELDCAT-EDIT = 'X'.
      X_FIELDCAT-DRDN_HNDL = '1'.
      X_FIELDCAT-DRDN_ALIAS = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Comissn'(025).
      X_FIELDCAT-FIELDNAME = 'COMISN'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-EDIT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " build_fieldcat
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
        PERFORM CREATE_AND_INIT_ALV.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  SET_DRDN_TABLE
    *       text
    FORM SET_DRDN_TABLE.
      DATA:LT_DRAL TYPE LVC_T_DRAL,
            LS_DRAL TYPE LVC_S_DRAL.
      LS_DRAL-HANDLE = '1'.
      LS_DRAL-VALUE =  'S/W Engineer'.
      LS_DRAL-INT_VALUE =  'S/W Engineer'.
      APPEND LS_DRAL TO LT_DRAL.
      LS_DRAL-HANDLE = '1'.
      LS_DRAL-VALUE =  'Manager'.
      LS_DRAL-INT_VALUE =  'Manager'.
      APPEND LS_DRAL TO LT_DRAL.
    **Setting the Drop down table for Reason Code
      CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
        EXPORTING
          IT_DROP_DOWN_ALIAS = LT_DRAL.
    ENDFORM.                               " set_drdn_table
    Regards
    vijay

  • F4 help in ALV Grid Control (using classes)

    Hi All,
        I have created a report using ALV Grid control (using classes). I need to provide F4 help for some of the fields in the Grid control.  I couldn't understand the standard demo program BCALV_GRID_F4_HELP. So Can anyone please provide me sample code for the same.
    Regards
    Jaker.

    hi check this..programs also
    BCALV_GRID_EDIT_DELTA
    BCALV_TEST_GRID_F4_HELP
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/how%2bto%2bimplement%2bf4%2bsearch%2bhelp%2bin%2boo%2balv%2bgrid
    Struggling with f4 handling in ALV grid - Minisap 46D
    regards,
    venkat

Maybe you are looking for