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

Similar Messages

  • List box in alv grid control  through slis and reuse_alv grid_display metho

    hello,
    i want to display list box in one column of alv by slis method.can u suggest me how to do it?
    neon

    Hi,
    plz check below code :
    TYPE-POOLS : slis.
    *data declarations for ALV container,ALV grid, Fieldcatalogues & layout
    DATA: g_grid  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          gt_fieldcat TYPE lvc_t_fcat,
          gs_layout TYPE lvc_s_layo.
    *INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
    DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
          wa_outtab TYPE t517a.
    *initialisation event
    INITIALIZATION.
    *Start of selection event
    START-OF-SELECTION.
    *Call to ALV
      CALL SCREEN 600.
    *On this statement double click  it takes you to the screen painter SE51.
    *Create a Custom container and name it CCONT and OK code as OK_CODE.
    *Save check and Activate the screen painter.
    *Now a normal screen with number 600 is created which holds the ALV grid.
    PBO of the actual screen , Here we can give a title and customized menus
    Here we also call the subroutine for ALV output.
          MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
    set pf-status 'xxx'.
    set titlebar 'MAIN100'.
    Subroutine to display the output in alv
      PERFORM alv_output.
    ENDMODULE.                    "pbo OUTPUT
    PAI module of the screen created. In case we use an interactive ALV or
    *for additional functionalities we can create OK codes and
    based on the user command we can do the coding.
          MODULE PAI INPUT                                              *
    MODULE pai INPUT.
    ENDMODULE.                    "pai INPUT
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat.
      DATA ls_fcat TYPE lvc_s_fcat.
    *Build the field catalogue
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'T517A'
        CHANGING
          ct_fieldcat      = gt_fieldcat.
    To assign dropdown in the fieldcataogue
      LOOP AT gt_fieldcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'SLART'.
    *drdn-hndl = '1' is the first list box
            ls_fcat-drdn_hndl = '1'.
            ls_fcat-outputlen = 15.
            MODIFY gt_fieldcat FROM ls_fcat.
    *drdn-hndl = '2' is the second list box
          WHEN 'ABART'.
            ls_fcat-drdn_hndl = '2'.
            ls_fcat-outputlen = 15.
            MODIFY gt_fieldcat FROM ls_fcat.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    "build_fieldcat
    *&      Form  ALV_OUTPUT
    FORM alv_output .
    *Create object for container
      CREATE OBJECT g_custom_container
             EXPORTING container_name = 'CCONT'.
    *create object for grid
      CREATE OBJECT g_grid
             EXPORTING i_parent = g_custom_container.
    Build fieldcat and set column
    *Assign a handle for the dropdown listbox.
      PERFORM build_fieldcat.
    *Build layout
      PERFORM build_layout.
    Define a drop down table.
      PERFORM dropdown_table.
    *fetch values from the T517A table
      SELECT * FROM t517a INTO TABLE gt_outtab.
    *Display ALV output
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
        CHANGING
          it_fieldcatalog = gt_fieldcat
          it_outtab       = gt_outtab.
    ENDFORM.                               "ALV_OUTPUT
    *&      Form  dropdown_table
          text
    -->  p1        text
    <--  p2        text
    FORM dropdown_table.
    *Declarations for drop down lists in ALV.
      DATA: lt_dropdown TYPE lvc_t_drop,
            ls_dropdown TYPE lvc_s_drop.
    First SLART listbox (handle '1').
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '01 Primary school'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '02 Lower Secondary'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '03 Upper Secondary'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '04 Professional School'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '05 College'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '06 University'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '09 Other Establishment'.
      APPEND ls_dropdown TO lt_dropdown.
    Second ABART listbox (handle '2').
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '10 Primary School certificate'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '20 Lower secondary/Junior high'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '30 High school diploma(B-levels)'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '31 Vocational'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '32 Matriculation'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '40 Specialist vocational certificate'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '50 College degree Level1'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '51 College degree Level2'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '52 Masters degree'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '60 Univ Degree level1'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '61 Bachelors degree'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '62 Masters degree'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '63 Licenciate'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '64 Doctors Degree Ph.D'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '89 None'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '90 Unknown'.
      APPEND ls_dropdown TO lt_dropdown.
    *method to display the dropdown in ALV
      CALL METHOD g_grid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_dropdown.
    ENDFORM.                               " dropdown_table
    *&      Form  build_layout
          text
    *layout for ALV output
    FORM build_layout .
      gs_layout-cwidth_opt = 'X'.
      gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
      gs_layout-no_toolbar = 'X'.
    ENDFORM.                    " build_layout
    reference : wiki.

  • List Box in ALV Grid

    Hi all,
        How to bring a list box in ALV Grid
    Regards,
    Vijayakumar
    Message was edited by:
            Vijayakumar V

    Hello Vijayakumar
    You have to do 2 steps (inbetween creating the fieldcatalog and displaying the ALV list):
    (1) Set dropdown handle in fieldcatalog, e.g.
    * Set Drop-Down handle for column 'LOGSYS'
      CLEAR l_wa_fcat.
    *  l_wa_fcat-drdn_field = 'DROP_DOWN_HANDLE'.
      l_wa_fcat-drdn_hndl  = c_drdn_handle_logsys.  " just a unique number
      MODIFY me->mt_fcat FROM l_wa_fcat
          TRANSPORTING drdn_hndl
        WHERE ( fieldname = 'LOGSYS' ).
    (2) Register the dropdown handle, e.g.
    * Set listbox for available source systems (according to
    * SOM Customizing and selection on selection screen)
      CLEAR l_wa_drop.
      l_wa_drop-handle = c_drdn_handle_logsys.
      LOOP AT me->mt_rfc_check INTO l_wa_rfccheck.
        l_wa_drop-value = l_wa_rfccheck-logsys.
        APPEND l_wa_drop TO lt_drop.
      ENDLOOP.
      CALL METHOD me->mo_alvgrid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_drop.
    Regards
      Uwe

  • 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

  • Mix AVG and Total for the same column in ALV grid

    Hi,
    We are using CL_GUI_ALV_GRID=>SET_TABLE_FOR_FIRST_DISPLAY, and I'd like to know if the following situation is possible.
    Let's say we have a column which contains a number of hours, and we set it up to subtotal by period, but as an average rather than a total (DO_SUM = "C"). This is not a problem so far.
    The problem is that we'd like for the "Grand Total" at the bottom of the ALV grid to total all of the subtotal averages, instead of calculating an average.
    Ex:
    Period            Hours
    2010/01           6.0
    2010/02           7.0
    2010/03           2.0
                    5.0  (This is an average... 6.0 + 7.0 + 2.0 / 3)
    2011/01          12.0
    2011/02           5.0
    2011/03           4.0
                    7.0  (This is an average... 12.0 + 5.0 + 4.0 / 3)
                12.0 (We want this to be a total of 5.0 + 7.0)
    So we want the "grand total" line to be 12.0 which is the sum, but it currently comes out as an average.
    Therefore we're looking to average at the sub total level, but we want a total of the subtotal levels at the grand total level for the same column.
    Thanks,
    Denis

    Refer to the suggestion given by Naimesh here Can we modify a sub-total in ALV making use of function GET_GLOBALS_FROM_SLVC_FULLSCR and the method GET_SUBTOTALS. You can see the parameter ep_collect01 refered in case of subtotals. Can you please check ep_collect00 for grand total in your case.
    As said about EP_COLLECT00,here goes a classic example Modify grand total in ALV GRID
    BR
    Keshav
    Edited by: Keshav.T on Sep 21, 2011 9:39 AM

  • Event for edit fields in Object ALV grid

    Hi community,
    I've building an ALV Grid in a SubDynpro of Tabstrip...
    Any fields are edit.
    I would like refresh my internal table at data changed of ALV object but if not assign a field at F4 event this result 
    not refresh.
    Thanks everybody,
    Antonello

    Hi Antonello Didonna,
    Use this code, its working:-
    After the user edits any records and performs an action then place this code.
    Say when user presses a button with function code 'EXECUTE', and all the changes from the output screen in ALV reflects back to internal table.
    * handle the code execution based on the function code encountered
    CASE sy-ucomm.
    * when the function code is EXECUTE then process the selected records
      WHEN 'EXECUTE'.
    * to reflect the data changed into internal table
        DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
        IF ref_grid IS INITIAL.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              e_grid = ref_grid.
        ENDIF.
        IF NOT ref_grid IS INITIAL.
          CALL METHOD ref_grid->check_changed_data.
        ENDIF.
        " now your internal table data is changed as in ALV output
        " append your code
      WHEN OTHERS.
        " your code
    ENDCASE.
    Hope this solves your problem.
    Thanks & Regards,
    Tarun Gambhir

  • How to change the position of the dialog for the error log from ALV Grid

    Hi,
    I've written a program using the method display_protocol to display the error detected in an ALV Grid and find that the error popup at the top left corner of the screen irrespective of the window of the SAP session.
    I'm wondering if I can specify to locate the error popup relative to the top left corner of the window of the SAP session.
    Thanks,
    Francis

    HI PG,
    do below whie filling the filed catlog
    wa_fieldcat-fieldname        = 'Field1".
    wa_fieldcat-COL_POS = '1',
    append wa_fieldcat to it_fieldcat.
    wa_fieldcat-fieldname         = 'Field2".
    wa_fieldcat-COL_POS = '2',
    wa_fieldcat-fieldname         = 'Field3".
    wa_fieldcat-COL_POS = '3',
    Thanks!

  • Question about the "goback" opterations in ALV GRID control.

    Hi everyone,
      I have a little situation here:
        in my ALV ,I deactive some of the standard toolbar functions  and  add one button of mine
    on the toolbar.  I leave 3 standard toolbar functions: insert a row ,delete a row and  go back.
    after I used standard toolbar functions to insert/delete a row, I can use the function "go back" and
    It really goes back to the previous status. But after I used my own button(the function is insert a
    row too) to insert a row, I can never go back to the previous status by pressing the button "go back".
    I want to know why and how can I make my own button able to go back.
    thanks for your help.

    see example
    Button  > : displays the next N records                            *
    Button  < : displays the previous N records                       *
    Button I< : displays the first page                                     *
    Button >I : displays the last page                                      *
    When the buttons Sort up, sort down, Filter, Delete Filter are      *
    pressed, N record are still displayed                  
    FORM f_read_data USING u_ucomm TYPE syucomm.
      STATICS :
        l_1   TYPE sytabix,
        l_2   TYPE sytabix.
      DATA l_max TYPE sytabix.             " Internal table size
      DESCRIBE TABLE gt_mara_ftr LINES l_max.
      CASE u_ucomm.
        WHEN c_first_page.                 " 1st page
          l_1 = 1.
        WHEN c_prev_page.                  " Previous page
          SUBTRACT p_max FROM l_1.
          IF l_1 < 1.
            l_1 = 1.
          ENDIF.
        WHEN c_next_page.                  " Next page
          IF l_1 IS INITIAL.
            l_1 = 1.
          ELSE.
            ADD p_max TO l_1.
          ENDIF.
          IF l_1 > l_max.
            l_1 = l_max.
          ENDIF.
        WHEN c_last_page.                  " Last page
          l_1 = l_max - p_max + 1.
          IF l_1 < 1.
            l_1 = 1.
          ENDIF.
      ENDCASE.
      l_2 = l_1 + p_max - 1.
      IF l_2 > l_max.
        l_2 = l_max.
      ENDIF.
      REFRESH gt_mara.
      IF l_max > 0.
        APPEND LINES OF gt_mara_ftr FROM l_1
                                      TO l_2
                                      TO gt_mara.
      ENDIF.
    ENDFORM.                               " F_READ_DATA
    FORM user_command USING u_ucomm     TYPE syucomm
                            us_selfield TYPE slis_selfield.     "#EC CALLED
      CASE u_ucomm.
        WHEN c_first_page OR c_next_page OR
        c_prev_page OR c_last_page.        " Page F, P, N, L
          PERFORM f_read_data USING u_ucomm.             " Update gt_mara
          us_selfield-refresh = 'X'.
        WHEN '&OUP' OR '&ODN'.             " Sort
          PERFORM f_sort_big_table.
          PERFORM f_read_data USING c_first_page.
          us_selfield-refresh = 'X'.
        WHEN '&ILT'.                       " Filter
          PERFORM f_filter_data.
          PERFORM f_read_data USING c_first_page.
          us_selfield-refresh = 'X'.
        WHEN '&ILD'.                       " Delete filter
          gt_mara_ftr[] = gt_mara_all[].
          PERFORM f_read_data USING c_first_page.
          us_selfield-refresh = 'X'.
      ENDCASE.
    ENDFORM.                               " USER_COMMAND

  • ALV Grid: event for user return in ALV Grid Control

    Hi developers,
    i'm wanna do something after a user has pressed the return button in a alv grid control. For that i need probably a event. But i can not find a proper event in the documentation. Could one of you guys help me?
    Best regards christian

    Hi Christian
    ALV grid is an encapsulated object, so it seems there is no way, you ought to implement the data_changed event. So if you want to make bulk data input and after trigger the event by pressing the return key, you should make the ALV Grid get your changes after pressing the key but not after a cell change of a modified cell.
    To set this attribute:
    CALL METHOD gr_alvgrid->register_edit_event
         EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter .
    This way "data_changed" event will be triggered whenever you press the return key while editing.
    For some more information you can also refer to the tutorial <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">"An Easy Reference for ALV Grid Control"</a>.
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

  • Deactivate the double click/ hot spot for a particular row in alv grid.

    Hello,
       As per a certain condition how to deactivate the double click/ hot spot for a particular row in alv grid.
    Regards,
    Saroj

    where u define layout there is a field hotspot.like
    data: var.
    if con is true
    var = 'X'. (show hotspot)
    else.
    var = ' '. (deactive hotspot)
    elseif ws_fieldcat-fieldname = 'DMBTR'
                    AND ws_fieldcat-tabname = 'T_MTAB'.
          ws_fieldcat-do_sum = C_X.
          <b>ws_fieldcat-hotsopts = var.</b>
          MODIFY Wt_fieldcat FROM ws_fieldcat
                  TRANSPORTING   DO_SUM.
    It is helpful for u. if any problen send me ur coding i will change it.
    Regards
    Manish Kumar

  • What is the constant name for Change layout Button in ALV Grid ABAP Objects

    Dear All,
    I have one query please help me.
    what is the constant name for Change layout Button in ALV Grid ABAP Objects.
    With Rgds,
    Babu

    Halo Vinod,
    The consant name is cl_gui_alv_grid=>mc_fc_current_variant.
    Regards
    Arshad

  • How to move up the List Box for para. values in the "Edit Values" window?

    Hi,
    I am using Crystal Reprots 11.
    I create 10 subreports, and each subreport contains a Parameters Field.
    The 10 subreports are put in 10 footer sections in increasing order, i.e. subreport1, subreport2, subreport3, ..., subreport10.
    When I use "Print Preview" to take a look at the whole report, CR prompts a "Edit Values" window for selecting parameter values.
    Maybe because I created subreport3 & subreport4 after I completed other subreports, the List Box with the values required to select for subreport3 & subreport4 were located at the bottom of the "Edit Values" window.
    How to move List Box with the values required to select for subreport3 & subreport4 up to the proper location (based on the order of subreports) in the "Edit Values" window?
    Thank you in adavance.

    Hi,
    Yes, that is true. The subreport parameters are prompted in the order you insert the subreport.
    The only way to fix this is to save subreports from 5 through 10 (Right-click subreport > select Save Subreport as) first.
    So, now all you have is Subreports 1, 2 and 3. Go ahead and add the Subreports from 5 to 10 in order and the prompts should be in order too.
    -Abhilash

  • How to change the list box to F4 Help for Billing type in VF01

    Hi All,
    In VF01 for Billing type i am getting List box. Now  I have to add one more field to that list box.
    like  F1 invoice
           F2 Invoice returns.
    or
    Is there any possiblity of making it as F4 Help instead of List Box.
    Please throw some lite on this issue.
    Regards,
    Rohit.

    Hi ,
    The list box is getting the value from the table TVFK .
    You can get the table name from the VALUE  TABLE of  FKART which is the domain
    for the field Billing Type .
    You need to Update the table TVFk programatically. Like  - -
    TABLES : tvfk.
    tvfk-FKART = 'F1'.  " Billing type
    tvfk-KOPGR =
    tvfk-VTEXT = 'Invoice '.  " Billing type description
    UPDATE TVKF FROM TVKF.  " Update the table
    Similarly you have to update the table by the F2 and and description.
    tvfk-FKART = 'F2'.
    tvfk-KOPGR =
    tvfk-VTEXT = 'Invoice returns'.
    UPDATE TVKF FROM TVKF.
    Regards
    Pinaki

  • To provide the list box for field

    hi experts
    my problem is in me53n screen.in that screen i have to provide the list box for the screen field 'requisitioner'.ple tell me whats the way to provide the list box for the field.

    Hi ,
           Use FM VRM_SET_VALUES
    which has a table of key and values .
    and import parameter for fieldname where listbox has to be provided.
    below is the code.
    form fill_list_box .
      data : s_listbox type vrm_value .
      data : t_listbox type standard table of vrm_value initial size 0 .
      s_listbox-key = '1' .
      s_listbox-text = 'Class/Interface' .
      append s_listbox to t_listbox .
      s_listbox-key = '2' .
      s_listbox-text = 'Description' .
      append s_listbox to t_listbox .
      s_listbox-key = '3' .
      s_listbox-text = 'Method' .
      append s_listbox to t_listbox .
      g_vrm_id =  'ZCW_LIST-T1' .
    *loop at t_listbox into s_listbox .
      set parameter id 'AUN' field space.
      call function 'VRM_SET_VALUES'
           exporting
                id              = g_vrm_id
                values          = t_listbox
           exceptions
                id_illegal_name = 1
                others          = 2.
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " fill_list_box

  • Events in ALV Grid Control

    Hi,
      I am working on ALV Grid Control. When the user clicks enter button on the keyboard the event DATA_CHANGED is triggered. I am actually collecting the data entered on the screen in the handler method of this event.
      Now, I want the same functionality with the Enter button on the SAP Screen (this button appears next to the Command Box in SAP Screen). Whenever I click the button in the SAP Screen, the DATA_CHANGED is not called.
    How can I make the button on the screen work the same way as the Enter button on the keyboard.
    This is very urgent requirement. Please help me.
    Regards,
    Vara

    Hi ,
    You are missing OK CODE at your Container Screen(Where you defined the custom Control to populate your ALV grid).
    Please define General attribute "OK_CODE" in your screen which you are using for Container(Where you defined the custom Control to populate your ALV GRID)..
    In User Command routine:
    Case OK_CODE = 'DATA_CHANGED'.
    ENDCASE.
    Hope this may help you.
    Regards,
    Lanka

Maybe you are looking for

  • Sales order schedule confirmed date will consider Production capacity load

    As we know about schedule confirm delivery dates of sales order will consider based on material master lead time ,shiping point etc How to consider production capacity plan on sales order's delivery date. Say for example : Production workcenter capac

  • No parameter found to add service item detail in BAPI_PR_CHANGE.

    Hi, I am trying to add new service item in an existing purchase requisition. But i can not find any parameter, where i can pass these service details. Regards PG

  • I can't open Bridge and Mini Bridge from Photoshop CS6 (64bit)

    I can't open Bridge CS6 64(Bit) and Mini Bridge from Photoshop CS6 (64bit), I get an error message (APPCRASH ). I can open only Bridge (32bit) as a stand alone program. Operating system Windows 7 (64bit).

  • Oh crap, I think it's dead...

    To lead off... Yes, I've checked the official support pages, and some unofficial ones. I have an e-mail outstanding to Apple support. There isn't an apple store close enough to go to. I just want to probe the minds of you fine people. I think my iPod

  • Yahoo Contacts more than 255 disappear

    So I synch my contacts with Yahoo.  I have 413 contacts.  But the other day I go into my contact list on my iPhone 5 and all contracts after "M" are gone.  It shows 255 on hte iPhone.  All are still in Yahoo.  So I turn off the synching with Yahoo. D