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

Similar Messages

  • 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

  • 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 perform an autocheck event when the field changes in ALV

    Hi everybody,
    how can I build an event or something which would make my 'wa_fieldcat-checkbox' set to 'X' (auto checked) everytime an editable field in the ALV is changed manually by the user?
    I want to perform this task in order to avoid asking the user to manually check the "check box" field everytime wants to make a change, since after the user's changes in the ALV I want to sort the itab with the check box column of the edited items.
    Thanks,
    Denis M

    Hi Denis,
    For ALV a FM REUSE_ALV_GRID_DISPLAY is available.
    The FM, has events as importing option.
    SLIS_T_EVENT
    EVENT - Basically this is the FM to handle Event's. When the user needs to do
    some event operation like when double clicking the a particular field we need to
    perform some operation.   These events are captured by this FM.
    slis_ev_data_changed -- To capture user command
    slis_ev_user_command -- To capture data changed.
    Also please refer the below link in scn. This shows sample code to capture ALV grid data changed.
    http://scn.sap.com/thread/261210
    Hope this will solve the problem.
    Thanks,
    Soundarya.

  • How to make a field manadatory within ALV Grid using methods and classes

    Hi,
    I am using ALV Grid using set_table_for_first_display
    inside my dialog programming. I have a field called project number inside my grid which has to be made as mandatory field.
    I have defined a method called catch_data_changed inside my class lcl_event_receiver. This method captures the changes made to one of the fields inside my ALV grid and displays all the default values of the other fields from the grid.
    Now, i have to make project number which is one of my fields inside my ALV grid as mandatory. At the field catalog level i did not find any such option for making a field as required field.
    Is there any other way, i can accomplish this within the ALV grid?

    from my understanding from ur question, i understood that u want the editable field inside alvgrid to be mandatory.
    i dont know anthing in fieldcat, but u can try the following logic.
    FORM DATA_CHANGED  USING P_ER_DATA_CHANGED TYPE REF TO
    CL_ALV_CHANGED_DATA_PROTOCOL .
      DATA: L_VALUE TYPE LVC_VALUE,
        ls_mod_cell type lvc_s_modi.
      READ TABLE P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
    if sy-subrc = 0.
        CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
          EXPORTING
            I_ROW_ID    = LS_MOD_CELL-row_id
            I_FIELDNAME = LS_MOD_CELL-fieldname
          IMPORTING
            E_VALUE     = L_VALUE.
    IF LS_MOD_CELL-FIELDNAME <> 'fieldname what u want'
    MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
    ENDIF.
    ELSE.
    MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
    ENDIF.

  • How to disable sorting for some columns in a ALV GRID?

    Hi i have requirement where I have to disable sorting for some columns in a ALV GRID. i am using REUSE_ALV_GRID_DISPLAY function module.
    Can anybody help me. how to acieve this? Any code snippets will really be appreciated.

    Hi,
    I have tried this but not completely successful. I think this can be done using the OOPS method.
      DATA: it_event_exit TYPE  slis_t_event_exit.
      DATA: w_exit TYPE slis_event_exit.
      w_exit-ucomm = '&ODN'.
      w_exit-before = 'X'.
      CLEAR w_exit-after.
      APPEND w_exit TO it_event_exit.
      w_exit-ucomm = '&OUP'.
      w_exit-before = 'X'.
      CLEAR w_exit-after.
      APPEND w_exit TO it_event_exit.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = w_repid
          i_callback_top_of_page      = 'ALV_TOP_OF_PAGE'
          i_callback_html_top_of_page = 'ALV_HTML_TOP_OF_PAGE'
          i_callback_user_command     = 'USER_COMMAND'  <- User command form
          is_layout                   = wm_layout
          it_fieldcat                 = wt_fieldcat
          it_events                   = i_events
          it_event_exit               = it_event_exit    <- Need to fill
          it_sort                     = wt_sort
          i_default                   = 'X'
    Now you can capture this events in the user command
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      IF r_ucomm = '&OUP' and rs_selfield-SEL_TAB_FIELD = 'Your field name'.
      ENDIF.
    ENDFORM.                    "user_command
    In this form you will get the function code in 'r_ucomm' and the field selected for sorting in 'rs_selfield-SEL_TAB_FIELD'. But reseting 'r_ucomm' will not work.
    May be somebody else can give some help on this.
    But this will work if you follow the oop method.
    Please see this document for more info.
    http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an easy reference for alv grid control.pdf
    Thanks
    Vinod

  • ME51N/ME52N: Editable customer columns in ALV grid item overview

    Hi All,
    In purchase requisition ME51N-ME53N I added a customer tab with customer fields. But they are outputed every time in ALV grid item overview in display mode.
    Hence my question is how I can make them editable for tcodes ME51N/ME52N?
    The customer tab I implemented with the User-Exit enhancement MEREQ001. In the forum I found that I have to use for handling the fields in the ALV grid the BADI ME_PROCESS_REQ_CUST.
    Can anyone give me a working example?
    Thank you very much  in advance for your support!
    Kind regards
    Silvan

    Hi Sankarbabu
    Thanks a lot for your reply.
    May you have an example to modify the field catalog? I didn't find out how this can be done.
    Do I have to do the changes in the method "FIELDSELECTION_ITEM"? Curiously this method wouldn't be called...
    Kind regards,
    Silvan

  • Displaying Field Names in ALV GRID

    hi,
         I have a requirement that i have to display the type of the GL Indicators.
         Now i want the corressponding name/desc of that GL indicator to be displayed down in the ALV GRID.Can any one tell how can i solve this issue..
    For Ex.
    This is my ALV GRID.
        Comp_Code     Vendor_Id       GL_indicator 1          GL_indicator 2
                                                          ABC                         EDF                 
         1000                1000001           20000.00                    500.00
    In this ABC and EDF are the desc of GL_indicator 1 and GL_indicator 2 resp..
    How can i display such type of ALV..
    Rewards points will be given
    Thank You.

    Hi,
    Check the below test code......You will understand.
    TYPE-POOLS: SLIS.
    DATA: GT_OUTTABH TYPE SCARR OCCURS 0 WITH HEADER LINE,
          GT_OUTTAB TYPE SFLIGHT OCCURS 0 WITH HEADER LINE,
          GT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE ,
          GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
          GS_KEYINFO  TYPE SLIS_KEYINFO_ALV,
          G_REPID LIKE SY-REPID.
    DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE .
    DATA:
        GT_EVENTS      TYPE SLIS_T_EVENT,
        GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
        G_STATUS_SET   TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',
        G_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
        G_TOP_OF_PAGE  TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
        G_TOP_OF_LIST  TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',
        G_END_OF_LIST  TYPE SLIS_FORMNAME VALUE 'END_OF_LIST'.
    INITIALIZATION.
    define keyinfo
      CLEAR GS_KEYINFO.
      GS_KEYINFO-HEADER01 = 'CARRID'.
      GS_KEYINFO-ITEM01   = 'CARRID'.
      GS_KEYINFO-HEADER02 = SPACE.
      GS_KEYINFO-ITEM02   = 'CONNID'.
      G_REPID = SY-REPID.
      GS_LAYOUT-GROUP_CHANGE_EDIT = 'X'.
      GT_SORT-FIELDNAME = 'CURRCODE'.
      GT_SORT-tabNAME = '1'.
      GT_SORT-SPOS      = 1.
      GT_SORT-UP        = 'X'.
      GT_SORT-SUBTOT    = 'X'.
      GT_SORT-GROUP    = '*'.
      APPEND GT_SORT.
      GT_SORT-FIELDNAME = 'CARRID'.
      GT_SORT-tabNAME = '1'.
      GT_SORT-SPOS      = 2.
      GT_SORT-UP        = 'X'.
      GT_SORT-SUBTOT    = 'X'.
      GT_SORT-GROUP    = ' '.
      APPEND GT_SORT.
      GT_FIELDCAT-FIELDNAME    = 'PRICE'.
      GT_FIELDCAT-tabname    = '2'.
      GT_FIELDCAT-outputlen    = 12.
      GT_FIELDCAT-DO_SUM       = 'X'.
      APPEND GT_FIELDCAT.
      GT_FIELDCAT-FIELDNAME    = 'CARRID'.
      GT_FIELDCAT-tabname    = '1'.
      GT_FIELDCAT-outputlen    = 6.
      GT_FIELDCAT-DO_SUM       = space.
      APPEND GT_FIELDCAT.
      PERFORM EVENTTAB_BUILD USING GT_EVENTS[].
    START-OF-SELECTION.
      SELECT * FROM SCARR INTO CORRESPONDING FIELDS
           OF TABLE GT_OUTTABH.
      SELECT * FROM SFLIGHT INTO CORRESPONDING FIELDS
      OF TABLE GT_OUTTAB.
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM      = G_REPID
                I_STRUCTURE_NAME_HEADER = 'SCARR'
                I_STRUCTURE_NAME_ITEM   = 'SFLIGHT'
                IS_KEYINFO              = GS_KEYINFO
                IS_LAYOUT               = GS_LAYOUT
                IT_FIELDCAT             = GT_FIELDCAT[]
                I_TABNAME_HEADER        = '1'
                I_TABNAME_ITEM          = '2'
                IT_EVENTS               = GT_EVENTS[]
                IT_SORT                 = GT_SORT[]
           TABLES
                T_OUTTAB_HEADER         = GT_outtabh
                T_OUTTAB_ITEM           = GT_outtab.
          FORM EVENTTAB_BUILD                                           *
    FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.
    *"Registration of events to happen during list display
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = RT_EVENTS.
      READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE G_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO RT_EVENTS.
      ENDIF.
    ENDFORM.
          FORM TOP_OF_PAGE                                              *
    FORM TOP_OF_PAGE.
      DATA: LS_LINE TYPE SLIS_LISTHEADER.
      REFRESH GT_LIST_TOP_OF_PAGE.
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'H'.
      LS_LINE-INFO = '<Header>'.
      APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
    STATUS LINE: TYPE S
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'S'.
      LS_LINE-KEY  = '<Status1>'.
      LS_LINE-INFO = GT_OUTTABH-CURRCODE.
      APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
    ENDFORM.
    Regards,
    Omkar.

  • Field Length in Alv Grid out put

    hi,
    How to increase the length of the filed in the output of alv grid,
    Actually i am getting one blank field in the alv grid out put, my requirement is to increase the length through out the column how to do that
    can anyone guide me plz
    SIRI

    in your fieldcat of the field
    wfieldcat-fieldname = '<your fieldname in caps>'
    wfieldcat-outputlen = 10 (or the length you want for the field)
    <you can define any other property also for that field>
    append wfieldcat to ifieldcat.
    now pass it in fm.
    regards
    shiba dutta

  • 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

  • Need help for hotspot linking from an ALV Grid to another transaction

    Hi all,
    I have to make a field in an ALV Grid link to a transaction. I activated the hotspot for the field in the field catalog and created a 'User_command' that i call in the REUSE_ALV_GRID_DISPLAY, but when i click on the hotpsot, it doesnot take me to the transaction. Please provide some help.
    Here is the code:
    *Internal table and work area for field catalog
    DATA: i_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv,
              wa_fieldcat TYPE slis_fieldcat_alv,
              v_repid LIKE sy-repid,
              wa_layout TYPE slis_layout_alv,
              i_event TYPE slis_t_event,
    internal table and work area for subtotals
            i_sort TYPE STANDARD TABLE OF slis_sortinfo_alv,
            wa_sort TYPE slis_sortinfo_alv.
      PERFORM prepare_fieldcatalog.
      PERFORM prepare_layout.
      PERFORM prepare_subtotal.
      PERFORM display_alv.
    FORM display_alv .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
       i_callback_program               = v_repid
       i_callback_pf_status_set          = 'STATUS'
       i_callback_user_command           = 'USER_COMMAND'
        is_layout                         = wa_layout
        it_fieldcat                       = i_fieldcat
       IT_SORT                           = i_sort
       it_events                         = i_event
        TABLES
          t_outtab                          = i_final
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " display_alv
    *&      Form  prepare_fieldcatalog
    FORM prepare_fieldcatalog .
      PERFORM f_build USING:
        c_bukrs text-011,
        c_gjahr text-012,
        c_lifnr text-013,
        c_ebeln text-014,
        c_ebelp text-015,
        c_dmbtr text-016,
        c_hkont text-017,
        c_wrbtr text-018,
        c_wmwst text-019,
        c_mwskz text-020,
        c_text1 text-021,
        c_kbetr text-022,
        c_spcode text-023.
    ENDFORM.                    " prepare_fieldcatalog
    *&      Form  f_build
    FORM f_build  USING    p_c_fieldname TYPE slis_fieldname
                           p_text TYPE c.
      CLEAR wa_fieldcat.
      CASE p_c_fieldname.
        WHEN c_dmbtr OR c_wrbtr OR c_wmwst.
          wa_fieldcat-do_sum = 'x'.
      ENDCASE.
      IF p_c_fieldname = c_ebeln.
        wa_fieldcat-hotspot = 'X'.
      ENDIF.
      wa_fieldcat-fieldname = p_c_fieldname.
      wa_fieldcat-seltext_m = p_text.
      APPEND wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " f_build
    *&      Form  prepare_layout
    FORM prepare_layout .
      wa_layout-info_fieldname = c_rowcolor.
    wa_layout-f2code = '<F2CODE>'.
    *APPEND wa_layout to i_layout.
    ENDFORM.                    " prepare_layout
    *&      Form  USER_COMMAND
    FORM user_command USING r_ucomm LIKE sy-ucomm
                                   rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
        WHEN c_back OR c_canc OR c_exit.
          LEAVE TO SCREEN 0.
        WHEN c_click.
          READ TABLE i_final INTO wa_final INDEX rs_selfield-tabindex .
          IF sy-subrc EQ 0.
            IF rs_selfield-fieldname EQ c_ebeln.
              SET PARAMETER ID c_bes FIELD wa_final-ebeln.
              CALL TRANSACTION c_me23n AND SKIP FIRST SCREEN.
            ENDIF.
          ENDIF.
      ENDCASE.
    ENDFORM.                    " USER_COMMAND
    *&      Form  status
    FORM status  USING    p_extab TYPE slis_t_extab.
      SET PF-STATUS c_standard.
    ENDFORM.                    " status
    *&      Form  prepare_subtotal
    FORM prepare_subtotal .
      wa_sort-spos = c_10.
      wa_sort-fieldname = c_mwskz.
      wa_sort-subtot = 'X'.
      wa_sort-up = 'X'.
      APPEND wa_sort TO i_sort.
    ENDFORM.                    " prepare_subtotal

    Hi,
    Check this example..
    TYPE-POOLS: slis.
    DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: BEGIN OF wa_ekko,
    ebeln like ekko-ebeln,
    ekorg like ekko-ekorg,
    ekgrp like ekko-ekgrp,
    END OF wa_ekko.
    DATA: v_repid TYPE syrepid.
    v_repid = sy-repid.
    DATA it_ekko LIKE STANDARD TABLE OF wa_ekko WITH HEADER LINE.
    SELECT * UP TO 100 ROWS
    FROM ekko
    INTO CORRESPONDING FIELDS OF TABLE it_ekko.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
         EXPORTING
              i_program_name     = v_repid
              i_internal_tabname = 'WA_EKKO'
              i_inclname         = v_repid
         CHANGING
              ct_fieldcat        = gt_fieldcat.
    have hotspot for a PO.
    DATA: s_fieldcat LIKE LINE OF gt_fieldcat.
    s_fieldcat-hotspot = 'X'.
    MODIFY gt_fieldcat FROM s_fieldcat TRANSPORTING hotspot
           WHERE fieldname = 'EBELN'.
    Pass the program.
    v_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
         EXPORTING
              i_callback_program      = v_repid
              it_fieldcat             = gt_fieldcat
              i_callback_user_command = 'USER_COMMAND'
         TABLES
              t_outtab                = it_ekko.
          FORM display_detail                                           *
    -->  UCOMM                                                         *
    -->  SELFIELD                                                      *
    FORM user_command USING ucomm LIKE sy-ucomm
    selfield TYPE slis_selfield.
      IF ucomm = '&IC1'.
        READ TABLE it_ekko INDEX selfield-tabindex.
        IF sy-subrc = 0.
          SET PARAMETER ID 'BES' FIELD it_ekko-ebeln.
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDIF.
    ENDFORM.
    Thanks,
    Naren

  • Validation I/P Enabled field in the ALV grid

    Hi all,
    Which method is used for validating a value entered in a reprot output field of an ALV Grid OO report.
    can some one please throw some light on this.
    with a few example programs where it has been implemented.
    Regrds

    Hi sushi,
      check this Program :  BCALV_EDIT_04
      to check out, Execute it , select the checkbox , and give any non numeric amount in the amount field , it will display an error

  • How to add an editable checkbox to an alv grid

    Hi..
    I need to add an editable checkbox to a alv grid.
    I wouls appreciatet it if anyone could provide some sample code.
    The standard example  BCALV_EDIT_05 is an oops example... I need a simple example
    Please help
    thanks
    Karen

    hi
    after you pass a field as checkbox in fieldcat
    then in layout populate edit
    ex wa_layout-edit = 'X'.
    try the following code
    REPORT  ZALV5.
    TYPE-POOLS: slis.
    tables: mara.
    DATA: begin of it_mara OCCURS 0,
          matnr like mara-matnr,
          mbrsh like mara-mbrsh,
          matkl like mara-matkl,
          meins like mara-meins,
          ersda like mara-ersda,
          ernam like mara-ernam,
          W_CHK type c ,
         END OF it_mara.
    *data: it_mara like  mara occurs 0 with header line.
    data:it_feildtab type slis_t_fieldcat_alv,
         wa_fieldcat type slis_fieldcat_alv.
    *DATA: i_private TYPE slis_data_caller_exit,
    data:     i_selfield TYPE slis_selfield,
          W_exit(1) TYPE c.
    PARAMETERS: p_title TYPE sy-title default 'ALV'.
    START-OF-SELECTION.
      SELECT matnr mbrsh matkl meins  ersda ernam FROM mara
        INTO corresponding fields of  table it_mara.
    wa_fieldcat-col_pos   = '1'.
    wa_fieldcat-fieldname = 'W_CHK'.
    *wa_FIELDCAT-KEY = 'X'.
    *wa_fieldcat-tabname   = 'IT_MARA'.
    *wa_fieldcat-seltext_s = 'units of measure'.
    wa_fieldcat-checkbox = 'X'.
    APPEND wa_fieldcat TO it_feildtab.
    CLEAR wa_fieldcat .
    CLEAR wa_fieldcat.
    wa_fieldcat-col_pos   = '2'.
    wa_fieldcat-tabname   = 'IT_MARA'.
    wa_fieldcat-fieldname = 'MATNR'.
    wa_fieldcat-key = 'X'.
    wa_fieldcat-hotspot = 'X'.
    wa_fieldcat-seltext_s = 'no'.
    APPEND wa_fieldcat TO it_feildtab.
    CLEAR wa_fieldcat .
    wa_fieldcat-col_pos   = '3'.
    wa_fieldcat-fieldname = 'MBRSH'.
    *wa_FIELDCAT-KEY = 'X'.
    wa_fieldcat-tabname   = 'IT_MARA'.
    wa_fieldcat-seltext_s = 'Ind.sec'.
    APPEND wa_fieldcat TO it_feildtab.
    CLEAR wa_fieldcat .
    wa_fieldcat-col_pos   = '4'.
    wa_fieldcat-fieldname = 'MATKL'.
    *wa_FIELDCAT-KEY = 'X'.
    wa_fieldcat-tabname   = 'IT_MARA'.
    wa_fieldcat-seltext_s = 'Description'.
    APPEND wa_fieldcat TO it_feildtab.
    CLEAR wa_fieldcat .
    wa_fieldcat-col_pos   = '5'.
    wa_fieldcat-fieldname = 'MEINS'.
    *wa_FIELDCAT-KEY = 'X'.
    wa_fieldcat-tabname   = 'IT_MARA'.
    wa_fieldcat-edit      = 'X'.
    wa_fieldcat-seltext_s = 'units of measure'.
    APPEND wa_fieldcat TO it_feildtab.
    CLEAR wa_fieldcat .
      CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
           EXPORTING
                i_title                 = p_title
                i_selection             = 'X'
                i_zebra                 = 'X'
               I_SCREEN_START_COLUMN   = 0
               I_SCREEN_START_LINE     = 0
                I_SCREEN_END_COLUMN     = 0
               I_SCREEN_END_LINE       = 0
                i_checkbox_fieldname    = 'W_CHK'
              I_LINEMARK_FIELDNAME    =
              I_SCROLL_TO_SEL_LINE    = 'X'
                i_tabname               = 'IT_MARA'
              i_structure_name        = 'IT_MARA'
               IT_FIELDCAT             = it_feildtab
              IT_EXCLUDING            =
              I_CALLBACK_PROGRAM      =
              I_CALLBACK_USER_COMMAND =
               IS_PRIVATE             = I_PRIVATE
         IMPORTING
                es_selfield             = i_selfield
                e_exit                  = w_exit
           TABLES
                t_outtab                = it_mara
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
       MESSAGE i000(0k) WITH sy-subrc.
      ENDIF.
      LOOP AT it_mara WHERE W_CHK = 'X'.
        WRITE: /  it_mara-ersda, it_mara-ernam.
      ENDLOOP.
    reward if helpful
    prasanth

  • Setting currency and measurement unit for a field in an ALV report

    Plz give sample code to set currency and measurement unit for a field in an ALV report

    dear friend
    i am seanding you
    the display form
    if you need select form
    and process form also pls keep in touch.
    if help full rewards are expecting.
    yours
    vivek
    FORM build_field_catalog .
      DATA: w_dthigh(10).
      CLEAR fcat.
      fcat-fieldname = 'VBELN'.
      fcat-outputlen = 10.
      fcat-seltext_s = 'COMMERCIAL INVOICE'.
      fcat-seltext_m = 'Commercial Invoice'.
      fcat-seltext_l = 'COMMERCIAL INVOICE'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CHAR'.
      fcat-key = 'X'.
      fcat-hotspot = 'X'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'EXNUM'.
      fcat-outputlen = 10.
      fcat-seltext_s = 'EXCISE INVOICE'.
      fcat-seltext_m = 'Excise Invoice'.
      fcat-seltext_l = 'EXCISE INVOICE'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CHAR'.
      fcat-hotspot = 'X'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'EXDAT'.
      fcat-outputlen = 10.
      fcat-seltext_s = 'EXCISE DATE'.
      fcat-seltext_m = 'Excise Date'.
      fcat-seltext_l = 'EXCISE DATE'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'D'.
      fcat-datatype = 'DATS'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'NAME1'.
      fcat-outputlen = 30.
      fcat-seltext_s = 'CUSTOMER'.
      fcat-seltext_m = 'Customer'.
      fcat-seltext_l = 'CUSTOMER'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CHAR'.
      fcat-lowercase = 'X'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'ZZPD'.
      fcat-outputlen = 15.
      fcat-seltext_s = 'COUNTRY'.
      fcat-seltext_m = 'COUNTRY'.
      fcat-seltext_l = 'COUNTRY'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CHAR'.
      fcat-lowercase = 'X'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'WERKS'.
      fcat-outputlen = 4.
      fcat-seltext_s = 'PLANT'.
      fcat-seltext_m = 'Plant'.
      fcat-seltext_l = 'PLANT'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CHAR'.
      fcat-key = 'X'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'ARKTX'.
      fcat-outputlen = 40.
      fcat-seltext_s = 'MATERIAL DESCRIPTION'.
      fcat-seltext_m = 'Material Description'.
      fcat-seltext_l = 'MATERIAL DESCRIPTION'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CHAR'.
      fcat-lowercase = 'X'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'FKART'.
      fcat-outputlen = 4.
      fcat-seltext_s = 'Billing type'.
      fcat-seltext_m = 'Billing type'.
      fcat-seltext_l = 'Billing type'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CHAR'.
      fcat-key = 'X'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'INCO1'.
      fcat-outputlen = 5.
      fcat-seltext_s = 'INCO TERMS'.
      fcat-seltext_m = 'INCO TERMS'.
      fcat-seltext_l = 'INCO TERMS'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CHAR'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'INCO2'.
      fcat-outputlen = 10.
      fcat-seltext_s = 'INCO TERMS DES'.
      fcat-seltext_m = 'INCO TERMS DES'.
      fcat-seltext_l = 'INCO TERMS DES'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CHAR'.
      APPEND fcat.
    CLEAR fcat.
    fcat-fieldname = 'FKIMG'.
    fcat-outputlen = 14.
    fcat-seltext_s = 'QUANTITY'.
    fcat-seltext_m = 'Quantity'.
    fcat-seltext_l = 'QUANTITY'.
    fcat-ddictxt = 'M'.
    fcat-inttype = 'P'.
    fcat-datatype = 'QUAN'.
    APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'FKLMG'.
      fcat-outputlen = 10.
      fcat-seltext_s = 'QUANTITY'.
      fcat-seltext_m = 'QUANTITY'.
      fcat-seltext_l = 'QUANTITY'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'P'.
      fcat-datatype = 'QUAN'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'MEINS'.
      fcat-outputlen = 5.
      fcat-seltext_s = 'UNIT'.
      fcat-seltext_m = 'UNIT'.
      fcat-seltext_l = 'UNIT'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CHAR'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'KBETR'.
      fcat-outputlen = 8.
      fcat-seltext_s = 'RATE'.
      fcat-seltext_m = 'Rate'.
      fcat-seltext_l = 'RATE'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'P'.
      fcat-datatype = 'CURR'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'NSR'.
      fcat-outputlen = 8.
      fcat-seltext_s = 'Exmill'.
      fcat-seltext_m = 'Exmill'.
      fcat-seltext_l = 'Exmill'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'P'.
      fcat-datatype = 'CURR'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'KURSK'.
      fcat-outputlen = 8.
      fcat-seltext_s = 'EXCHANGE RATE'.
      fcat-seltext_m = 'Exchange Rate'.
      fcat-seltext_l = 'Exchange Rate'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'P'.
      fcat-datatype = 'CURR'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'WAERK'.
      fcat-outputlen = 5.
      fcat-seltext_s = 'CURRENCY'.
      fcat-seltext_m = 'Currency'.
      fcat-seltext_l = 'CURRENCY'.
      fcat-ddictxt = 'M'.
      fcat-inttype = 'C'.
      fcat-datatype = 'CUKY'.
      APPEND fcat.
      CLEAR fcat.
      fcat-fieldname = 'LCURR1'.
      fcat-outputlen = 14.
      fcat-seltext_s = 'GROSS AMT'.
      fcat-seltext_m = 'Gross Amt'.
      fcat-seltext_l = 'GROSS AMT'.
      fcat-ddictxt = 'L'.
      fcat-inttype = 'P'.
      fcat-datatype = 'CURR'.
    fcat-do_sum = 'X'.
      APPEND fcat.
    ================================= *****************
      fheader-typ = 'H'.
      SELECT SINGLE butxt
        FROM t001
        INTO fheader-info
       WHERE bukrs EQ '1000'.
      APPEND fheader.
      CLEAR fheader.
      fheader-typ = 'H'.
      fheader-info = 'Daily Shipments For Exp'.
      APPEND fheader.
      CLEAR fheader.
    Plant
      SORT s_werks BY low.
      READ TABLE s_werks INDEX 1.
      fheader-typ = 'S'.
      WRITE s_werks-low TO fheader-key.
      SORT s_werks BY high DESCENDING.
      READ TABLE s_werks INDEX 1.
      IF s_werks-high NE space.
        CONCATENATE fheader-key 'TO' s_werks-high INTO fheader-info
                                SEPARATED BY space.
      ELSE.
        WRITE fheader-key TO fheader-info.
      ENDIF.
      CLEAR fheader-key.
      fheader-key = 'PLANT : '.
      APPEND fheader.
      CLEAR fheader.
    Billing Typ
    SORT S_FKART BY LOW.
    READ TABLE S_FKART INDEX 1.
    FHEADER-TYP = 'S'.
    WRITE S_FKART-LOW TO FHEADER-KEY.
    SORT S_FKART BY HIGH DESCENDING.
    READ TABLE S_FKART INDEX 1.
    IF S_FKART-HIGH NE SPACE.
    CONCATENATE FHEADER-KEY 'TO' S_FKART-HIGH INTO FHEADER-INFO
                             SEPARATED BY SPACE.
    ELSE.
       WRITE FHEADER-KEY TO FHEADER-INFO.
    ENDIF.
    CLEAR FHEADER-KEY.
    FHEADER-KEY = 'DOCUMENT TYPE : '.
    APPEND FHEADER.
    CLEAR FHEADER.
    Date...
      fheader-typ = 'S'.
    FHEADER-KEY = S_FKDAT-LOW.
      WRITE s_fkdat-low  TO fheader-key.
      WRITE s_fkdat-high TO w_dthigh.
      CONCATENATE fheader-key 'TO' w_dthigh INTO fheader-info
                              SEPARATED BY space.
      CLEAR fheader-key.
      fheader-key = 'PERIOD : '.
      APPEND fheader.
      CLEAR fheader.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = fevents[]
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      READ TABLE fevents WITH KEY name = 'TOP_OF_PAGE'.
      IF sy-subrc = 0.
        fevents-form = 'TOPOFPAGE'.
        MODIFY fevents INDEX sy-tabix.
        CLEAR fevents.
      ENDIF.
      rptname = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
                        EXPORTING
                          i_callback_program                = rptname
                          it_fieldcat                       = fcat[]
                          i_default                         = 'S'
                          it_events                         = fevents[]
                          i_save                            = 'X'
                         TABLES
                           t_outtab                          = it_output[]
                      EXCEPTIONS
                        PROGRAM_ERROR                     = 1
                        OTHERS                            = 2
    ENDFORM.                    " BUILD_FIELD_CATALOG

  • F4 for Editable field in ALV, display Name but capture ID

    Hi Friends,
    I have a ALV for which i have defined a Structure, which is passed to Fieldcatlog.
    I have defined a Search help - ZUSER_NAME which has following fields to display.
    USERID - USR02-BNAME
    FNAME
    LNAME
    FULLNAME
    So my structure for fieldcatalog has User-id which is linked to this search help with Domain XUBNAME.
    So in my report i made this User-Id as editable and F4 available, everything is working fine.
    when user does a F4, its displaying Userid,Fname,Lname and complete name.upon selection and save i am capturing the id and storing in the ztable.
    But now i have a requirement that when user selects a value from this search help on F4, i need to display Fullname but capture the User Id. How can i do that?
    This is something similar to the one we have in BSP- key-value pair.
    how to do this in ALV.
    Appreciate if someone can guide me thru.
    Thanks,
    Simha
    Edited by: Simha on Sep 6, 2008 2:24 PM

    hai ,  this is example code for editing the F4 display .. check out this
    REPORT zalv_editf4display.
    *Type pools for alv
    TYPE-POOLS : slis.
    *structure for t582a tbale
    TYPES : BEGIN OF ty_table,
            infty TYPE infty,
            pnnnn TYPE pnnnn_d,
            zrmkz TYPE dzrmkz,
            zeitb TYPE dzeitb,
            dname TYPE dianm,
             davo TYPE davo,
            davoe TYPE davoe,
            END OF ty_table.
    *Structure for infotype text
    TYPES : BEGIN OF ty_itext,
            infty TYPE infty,
            itext TYPE intxt,
            sprsl TYPE sprsl,
            END OF ty_itext.
    *Structure for output display
    TYPES : BEGIN OF ty_output,
            infty TYPE infty,
            itext TYPE intxt,
            pnnnn TYPE pnnnn_d,
            zrmkz TYPE dzrmkz,
            zeitb TYPE dzeitb,
            dname TYPE dianm,
            davo TYPE davo,
            davoe TYPE davoe,
           END OF ty_output.
    *internal table and work area declarations
    DATA : it_table TYPE STANDARD TABLE OF ty_table INITIAL SIZE 0,
           it_output TYPE STANDARD TABLE OF ty_output INITIAL SIZE 0,
           it_pbo TYPE STANDARD TABLE OF ty_output INITIAL SIZE 0,
           it_ittext TYPE STANDARD TABLE OF ty_itext INITIAL SIZE 0,
           wa_table TYPE ty_table,
           wa_output TYPE ty_output,
           wa_ittext TYPE ty_itext.
    *Data declarations for dropdown lists for f4
    DATA: it_dropdown TYPE lvc_t_drop,
          ty_dropdown TYPE lvc_s_drop,
    *data declaration for refreshing of alv
          stable TYPE lvc_s_stbl.
    *Global variable declaration
    DATA: gstring TYPE c.
    *Data declarations for ALV
    DATA: c_ccont TYPE REF TO cl_gui_custom_container,         "Custom container object
          c_alvgd         TYPE REF TO cl_gui_alv_grid,         "ALV grid object
          it_fcat            TYPE lvc_t_fcat,                  "Field catalogue
          it_layout          TYPE lvc_s_layo.                  "Layout
    *ok code declaration
    DATA:
      ok_code       TYPE ui_func.
    *initialization event
    INITIALIZATION.
    *start of selection event
    START-OF-SELECTION.
    *select the infotypes maintained
      SELECT infty
              pnnnn
              zrmkz
              zeitb
              dname
              davo
              davoe
              FROM t582a UP TO 10 ROWS
              INTO CORRESPONDING FIELDS OF TABLE it_table.
    *Select the infotype texts
      IF it_table[] IS NOT INITIAL.
        SELECT itext
                 infty
                 sprsl
                 FROM t582s
                 INTO CORRESPONDING FIELDS OF TABLE it_ittext
                 FOR ALL ENTRIES IN it_table
                 WHERE infty = it_table-infty
                 AND sprsl = 'E'.
      ENDIF.
    *Apppending the data to the internal table of ALV output
      LOOP AT it_table INTO wa_table.
        wa_output-infty = wa_table-infty.
        wa_output-pnnnn = wa_table-pnnnn.
        wa_output-zrmkz = wa_table-zrmkz.
        wa_output-zeitb = wa_table-zeitb.
        wa_output-dname = wa_table-dname.
        wa_output-davo = wa_table-davo.
        wa_output-davoe = wa_table-davoe.
    For texts
        READ TABLE it_ittext INTO wa_ittext WITH KEY infty = wa_table-infty.
        wa_output-itext = wa_ittext-itext.
        APPEND wa_output TO it_output.
        CLEAR wa_output.
      ENDLOOP.
    Calling the ALV screen with custom container
      CALL SCREEN 0600.
    *On this statement double click  it takes you to the screen painter SE51.
    *Enter the attributes
    *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
    *create 2 buttons with function code 'SAVE' and 'EXIT'.
    GIVE A SUITABLE TITLE
    *&      Module  STATUS_0600  OUTPUT
          text
    MODULE status_0600 OUTPUT.
      SET PF-STATUS 'DISP'.
      SET TITLEBAR 'ALVF4'.
    ENDMODULE.                 " STATUS_0600  OUTPUT
    calling the PBO module ALV_GRID.
    *&      Module  PBO  OUTPUT
          text
    MODULE pbo OUTPUT.
    *Creating objects of the container
      CREATE OBJECT c_ccont
           EXPORTING
              container_name = 'CCONT'.
    create object for alv grid
      create object c_alvgd
      exporting
      i_parent = c_ccont.
    SET field for ALV
      PERFORM alv_build_fieldcat.
    Set ALV attributes FOR LAYOUT
      PERFORM alv_report_layout.
      CHECK NOT c_alvgd IS INITIAL.
    Call ALV GRID
      CALL METHOD c_alvgd->set_table_for_first_display
        EXPORTING
          is_layout                     = it_layout
          i_save                        = 'A'
        CHANGING
          it_outtab                     = it_output
          it_fieldcatalog               = it_fcat
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDMODULE.                 " PBO  OUTPUT
    *&      Form  alv_build_fieldcat
          text
         <--P_IT_FCAT  text
    *subroutine to build fieldcat
    FORM alv_build_fieldcat.
      DATA lv_fldcat TYPE lvc_s_fcat.
      CLEAR lv_fldcat.
      lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '1'.
      lv_fldcat-fieldname = 'INFTY'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 8.
      lv_fldcat-scrtext_m = 'Infotype'.
      lv_fldcat-icon = 'X'.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
      lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '2'.
      lv_fldcat-fieldname = 'PNNNN'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 15.
      lv_fldcat-scrtext_m = 'Structure'.
      lv_fldcat-icon = ''.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
      lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '3'.
      lv_fldcat-fieldname = 'ITEXT'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 60.
      lv_fldcat-scrtext_m = 'Description'.
      lv_fldcat-icon = ''.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
      lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '5'.
      lv_fldcat-fieldname = 'ZRMKZ'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 1.
      lv_fldcat-scrtext_m = 'PERIOD'.
      lv_fldcat-icon = ''.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
      lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '6'.
      lv_fldcat-fieldname = 'ZEITB'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 5.
      lv_fldcat-scrtext_m = 'Time constraint'.
      lv_fldcat-edit = 'X'.
    *To avail the existing F4 help these are to
    *be given in the field catalogue
      lv_fldcat-f4availabl = 'X'.
      lv_fldcat-ref_table = 'T582A'.
      lv_fldcat-ref_field = 'ZEITB'.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
      lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '7'.
      lv_fldcat-fieldname = 'DNAME'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 15.
      lv_fldcat-scrtext_m = 'Dialogmodule'.
      lv_fldcat-icon = ''.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
      lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '8'.
      lv_fldcat-fieldname = 'DAVO'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 15.
      lv_fldcat-scrtext_m = 'Start'.
      lv_fldcat-edit = 'X'.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
      lv_fldcat-row_pos   = '1'.
      lv_fldcat-col_pos   = '9'.
      lv_fldcat-fieldname = 'DAVOE'.
      lv_fldcat-tabname   = 'IT_OUTPUT'.
      lv_fldcat-outputlen = 15.
      lv_fldcat-scrtext_m = 'End'.
      lv_fldcat-icon = ''.
      APPEND lv_fldcat TO it_fcat.
      CLEAR lv_fldcat.
    *To create drop down for the field 'DAVO'
    with our own f4 help
      ty_dropdown-handle = '1'.
      ty_dropdown-value = ' '.
      APPEND ty_dropdown TO it_dropdown.
      ty_dropdown-handle = '1'.
      ty_dropdown-value = '1'.
      APPEND ty_dropdown TO it_dropdown.
      ty_dropdown-handle = '1'.
      ty_dropdown-value = '2'.
      APPEND ty_dropdown TO it_dropdown.
      ty_dropdown-handle = '1'.
      ty_dropdown-value = '3'.
      APPEND ty_dropdown TO it_dropdown.
      CALL METHOD c_alvgd->set_drop_down_table
        EXPORTING
          it_drop_down = it_dropdown.
      LOOP AT it_fcat INTO lv_fldcat.
        CASE lv_fldcat-fieldname.
    To assign dropdown in the fieldcataogue
          WHEN 'DAVO'.
            lv_fldcat-drdn_hndl = '1'.
            lv_fldcat-outputlen = 15.
            MODIFY it_fcat FROM lv_fldcat.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    " alv_build_fieldcat
    *&      Form  alv_report_layout
          text
         <--P_IT_LAYOUT  text
    *Subroutine for setting alv layout
    FORM alv_report_layout.
      it_layout-cwidth_opt = 'X'.
      it_layout-col_opt = 'X'.
      it_layout-zebra = 'X'.
    ENDFORM.                    " alv_report_layout
    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
          text
    MODULE pai INPUT.
    *To change the existing values and refresh the grid
    *And only values in the dropdown or in the default
    *F4 can be given , else no action takes place for the dropdown
    *and error is thrown for the default F4 help and font changes to red
    *and on still saving, value is not changed
      c_alvgd->check_changed_data( ).
    *Based on the user input
    *When user clicks 'SAVE;
      CASE ok_code.
        WHEN 'SAVE'.
    *A pop up is called to confirm the saving of changed data
          CALL FUNCTION 'POPUP_TO_CONFIRM'
            EXPORTING
              titlebar       = 'SAVING DATA'
              text_question  = 'Continue?'
              icon_button_1  = 'icon_booking_ok'
            IMPORTING
              answer         = gstring
            EXCEPTIONS
              text_not_found = 1
              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.
    *When the User clicks 'YES'
          IF ( gstring = '1' ).
            MESSAGE 'Saved' TYPE 'S'.
    *Now the changed data is stored in the it_pbo internal table
            it_pbo = it_output.
    *Subroutine to display the ALV with changed data.
            PERFORM redisplay.
          ELSE.
    *When user clicks NO or Cancel
            MESSAGE 'Not Saved'  TYPE 'S'.
          ENDIF.
    **When the user clicks the 'EXIT; he is out
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
      CLEAR: ok_code.
    ENDMODULE.                 " PAI  INPUT
    *&      Form  REDISPLAY
          text
    -->  p1        text
    <--  p2        text
    FORM redisplay .
    *Cells of the alv are made non editable after entering OK to save
      CALL METHOD c_alvgd->set_ready_for_input
        EXPORTING
          i_ready_for_input = 0.
    *Row and column of the alv are refreshed after changing values
      stable-row = 'X'.
      stable-col = 'X'.
    *REfreshed ALV display with the changed values
    *This ALV is non editable and contains new values
      CALL METHOD c_alvgd->refresh_table_display
        EXPORTING
          is_stable = stable
        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.
    ENDFORM.                    " REDISPLAY

Maybe you are looking for