REPORT Z_ALV_CONTEXT_MENU NO STANDARD PAGE HEADING.
TYPE-POOLS: SLIS.
DATA: BEGIN OF GT_OUTTAB OCCURS 0.
INCLUDE STRUCTURE SFLIGHT.
DATA: END OF GT_OUTTAB.
DATA: GT_EVENTS TYPE SLIS_T_EVENT.
DATA: G_REPID LIKE SY-REPID,
EVENT TYPE SLIS_ALV_EVENT.
START-OF-SELECTION.
G_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 4
IMPORTING
ET_EVENTS = GT_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC = 0.
REFRESH GT_EVENTS.
EVENT-NAME = 'CONTEXT_MENU'.
EVENT-FORM = 'CONTEXT_MENU'.
APPEND EVENT TO GT_EVENTS.
ENDIF.
SELECT * FROM SFLIGHT INTO CORRESPONDING FIELDS OF TABLE GT_OUTTAB UP TO 30 ROWS.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE'
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_STRUCTURE_NAME = 'SFLIGHT'
IT_EVENTS = GT_EVENTS
TABLES
T_OUTTAB = GT_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
***********************************************************************
* FORM html_top_of_page
***********************************************************************
FORM HTML_TOP_OF_PAGE USING TOP TYPE REF TO CL_DD_DOCUMENT.
CALL METHOD TOP->ADD_TEXT
EXPORTING
TEXT = 'Hello world '
SAP_STYLE = 'heading'.
CALL METHOD TOP->ADD_GAP
EXPORTING
WIDTH = 100.
CALL METHOD TOP->ADD_PICTURE
EXPORTING
PICTURE_ID = 'ENJOYSAP_LOGO'.
ENDFORM. "html_top_of_page
***********************************************************************
* Form context_menu
***********************************************************************
FORM CONTEXT_MENU USING E_OBJECT TYPE REF TO CL_CTMENU.
DATA: L_SMENU TYPE REF TO CL_CTMENU.
IF E_OBJECT IS BOUND.
CREATE OBJECT L_SMENU.
CALL METHOD L_SMENU->ADD_FUNCTION
EXPORTING
FCODE = 'HIDE'
TEXT = 'Hide Column'.
CALL METHOD E_OBJECT->ADD_SUBMENU
EXPORTING
MENU = L_SMENU
TEXT = 'Hide'.
ENDIF.
ENDFORM. "CONTEXT_MENU
***********************************************************************
* Form user_command
***********************************************************************
FORM USER_COMMAND USING R_UCOMM TYPE SY-UCOMM
LS_SELFIELD TYPE SLIS_SELFIELD.
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID,
T_CATALOG TYPE LVC_T_FCAT,
W_CATALOG TYPE LVC_S_FCAT,
L_REPID TYPE SY-REPID.
CASE R_UCOMM.
WHEN 'HIDE'.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_CALLBACK_PROGRAM = L_REPID
E_GRID = G_GRID
ET_FIELDCAT_LVC = T_CATALOG.
CHECK L_REPID = G_REPID.
IF G_GRID IS BOUND AND T_CATALOG[] IS NOT INITIAL.
W_CATALOG-NO_OUT = 'X'.
MODIFY T_CATALOG FROM W_CATALOG TRANSPORTING NO_OUT WHERE FIELDNAME = LS_SELFIELD-FIELDNAME.
IF SY-SUBRC = 0.
CALL METHOD G_GRID->SET_FRONTEND_FIELDCATALOG
EXPORTING
IT_FIELDCATALOG = T_CATALOG.
ENDIF.
ENDIF.
ENDCASE.
LS_SELFIELD-REFRESH = 'X'.
ENDFORM. "USER_COMMAND
阅读(1999) | 评论(0) | 转发(0) |