Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to handle user command method in module ALV Grid

HI Experts,

I have 3 containers grid.

GR_GRID TYPE REF TO CL_GUI_ALV_GRID,

GR_GRID1 TYPE REF TO CL_GUI_ALV_GRID,

GR_GRID2 TYPE REF TO CL_GUI_ALV_GRID.

Please advise me how can I insert, save, delete 3 Module ALV Grid in method user command. How can i get which grid button (save, insert, delete) is clicked and how can i control those grid.

Thks in advance.

CLASS LCL_EVENT_RECEIVER DEFINITION.

PUBLIC SECTION.

METHODS :

HANDLE_TOOLBAR

FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID

IMPORTING E_OBJECT E_INTERACTIVE SENDER,

HANDLE_USER_COMMAND

FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID

IMPORTING E_UCOMM,

HANDLE_DATA_CHANGED

FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID

IMPORTING ER_DATA_CHANGED

E_ONF4

E_ONF4_BEFORE

E_ONF4_AFTER,

HANDLE_DOUBLE_CLICK

FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID

IMPORTING E_ROW

E_COLUMN,

HANDLE_HOTSPOT_CLICK

FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID

IMPORTING E_ROW_ID

E_COLUMN_ID

ES_ROW_NO.

ENDCLASS. "(LCL_EVENT_RECEIVER DEFINITION)

METHOD HANDLE_USER_COMMAND.

CLEAR G_CODE.

G_CODE = E_UCOMM.

CASE G_CODE.

WHEN 'INSERT'.

MESSAGE 'insert' TYPE 'I'.

  • APPEND INITIAL LINE TO GT_MAIN.

WHEN 'SAVE'.

  • MODIFY ZTNBOOK FROM GT_MAIN.

MESSAGE 'save' TYPE 'I'.

WHEN 'DELETE'.

  • DELETE FROM ZTNBOOK WHERE B_ID EQ GT_ZTBOOK-B_ID.

MESSAGE 'delete' TYPE 'I'.

ENDCASE.

IF NOT G_CODE IS INITIAL.

  • PBO, PAI

  • CALL METHOD CL_GUI_CFW=>SET_NEW_OK_CODE

  • EXPORTING

  • NEW_CODE = G_CODE.

  • CLEAR G_CODE.

ENDIF.

ENDMETHOD.

Former Member
Not what you were looking for? View more on this topic or Ask a question