sapdev logo background
sapdev logo sapdev logo
Comments

Add User command functionality to ALVgrid report




In order to add user command functioality to the ALV grid you need to perform the following steps:

1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include 'USER_COMMAND' FORM
2. Create 'USER_COMMAND' FORM


 call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = gd_repid
            i_callback_top_of_page   = 'TOP-OF-PAGE'
            I_callback_user_command = 'USER_COMMAND'   "see FORM 
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
            i_save                  = 'X'
       tables
            t_outtab                = it_ekko
       exceptions
            program_error           = 1
            others                  = 2.


*----------------------------------------------------------*
*       FORM USER_COMMAND                                  *
*----------------------------------------------------------*
*       --> R_UCOMM                                        *
*       --> RS_SELFIELD                                    *
*----------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
                  rs_selfield TYPE slis_selfield.

* Check function code
  CASE r_ucomm.
    WHEN '&IC1'.
*   Check field clicked on within ALVgrid report
    IF rs_selfield-fieldname = 'EBELN'.
*     Read data table, using index of row user clicked on
      READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
*     Set parameter ID for transaction screen field
      SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
*     Sxecute transaction ME23N, and skip initial data entry screen
      CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDCASE.
ENDFORM.



comments powered by Disqus