*&---------------------------------------------------------------------*
*& Module pool ZGDEMO_SIMPLE_ALV_GRID_7AM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
PROGRAM ZGDEMO_OO_ALV_PRINT_EVENTS_7AM.
*REPORT ZGDEMO_OO_ALV_PRINT_EVENTS_7AM.
DATA : O_CONTAINER TYPE REF TO
CL_GUI_CUSTOM_CONTAINER,
O_GRID TYPE REF TO
CL_GUI_ALV_GRID.
DATA : IT_EKKO TYPE TABLE OF EKKO,
WA_EKKO TYPE EKKO,
IT_EKPO TYPE TABLE OF EKPO.
*DEFINE EVENT HANDLER CLASS
CLASS LCL_EVENT_HANDLER DEFINITION.
PUBLIC SECTION.
METHODS : HANDLE_PRINT_TOP_OF_PAGE FOR EVENT
PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID,
HANDLE_PRINT_TOP_OF_LIST FOR EVENT
PRINT_TOP_OF_LIST OF CL_GUI_ALV_GRID,
HANDLE_PRINT_END_OF_LIST FOR EVENT
PRINT_END_OF_LIST OF CL_GUI_ALV_GRID,
HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK
OF CL_GUI_ALV_GRID
IMPORTING ES_ROW_NO,
HANDLE_TOOLBAR FOR EVENT TOOLBAR
OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT,
HANDLE_USER_COMMAND FOR EVENT USER_COMMAND
OF CL_GUI_ALV_GRID
IMPORTING E_UCOMM.
ENDCLASS.
*IMPLEMENTATION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
METHOD HANDLE_PRINT_TOP_OF_PAGE.
WRITE / 'I AM TOP OF PAGE'.
ENDMETHOD.
METHOD HANDLE_PRINT_TOP_OF_LIST.
WRITE / 'I AM TOP OF LIST'.
ENDMETHOD.
METHOD HANDLE_PRINT_END_OF_LIST.
WRITE / 'I AM END OF LIST'.
ENDMETHOD.
METHOD HANDLE_DOUBLE_CLICK.
READ TABLE IT_EKKO INTO WA_EKKO
INDEX ES_ROW_NO-ROW_ID.
SET PARAMETER ID 'BES' FIELD WA_EKKO-EBELN.
CALL TRANSACTION 'ME23N'.
ENDMETHOD.
METHOD HANDLE_TOOLBAR.
DATA WA_TOOLBAR TYPE STB_BUTTON.
WA_TOOLBAR-FUNCTION = 'DETAILED'.
WA_TOOLBAR-TEXT = 'Detailed List'.
APPEND WA_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
ENDMETHOD.
METHOD HANDLE_USER_COMMAND.
CASE E_UCOMM.
WHEN 'DETAILED'.
SELECT * INTO TABLE IT_EKPO FROM EKPO
FOR ALL ENTRIES IN IT_EKKO
WHERE EBELN = IT_EKKO-EBELN.
call method O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'EKPO'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
* IR_SALV_ADAPTER =
changing
IT_OUTTAB = IT_EKPO
* IT_FIELDCATALOG =
* IT_SORT =
* IT_FILTER =
* 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.
ENDCASE.
ENDMETHOD.
ENDCLASS.
*&---------------------------------------------------------------------*
*& Module READ_DATA OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE READ_DATA OUTPUT.
SELECT * INTO TABLE IT_EKKO FROM EKKO
UP TO 15 ROWS.
ENDMODULE. " READ_DATA OUTPUT
*&---------------------------------------------------------------------*
*& Module DISPLAY_ALV OUTPUT
*&---------------------------------------------------------------------*
MODULE DISPLAY_ALV OUTPUT.
*CREATE CONTAINER OBJ
create object O_CONTAINER
exporting
CONTAINER_NAME = 'CONTAINER'
.
if SY-SUBRC = 0.
*CREATE GRID OBJ
create object O_GRID
exporting
* I_SHELLSTYLE = 0
* I_LIFETIME =
I_PARENT = O_CONTAINER
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
* I_FCAT_COMPLETE = SPACE
* EXCEPTIONS
* ERROR_CNTL_CREATE = 1
* ERROR_CNTL_INIT = 2
* ERROR_CNTL_LINK = 3
* ERROR_DP_CREATE = 4
* others = 5
.
if SY-SUBRC = 0.
*REGISTER EVENT & HANDLER METHOD
DATA O_HANDLER TYPE REF TO LCL_EVENT_HANDLER.
CREATE OBJECT O_HANDLER.
SET HANDLER : O_HANDLER->HANDLE_PRINT_TOP_OF_PAGE
FOR O_GRID,
O_HANDLER->HANDLE_PRINT_TOP_OF_LIST
FOR O_GRID,
O_HANDLER->HANDLE_PRINT_END_OF_LIST
FOR O_GRID,
O_HANDLER->HANDLE_DOUBLE_CLICK FOR O_GRID,
O_HANDLER->HANDLE_TOOLBAR FOR O_GRID,
O_HANDLER->HANDLE_USER_COMMAND FOR O_GRID.
*DISPLAY
call method O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'EKKO'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
* IR_SALV_ADAPTER =
changing
IT_OUTTAB = IT_EKKO
* IT_FIELDCATALOG =
* IT_SORT =
* IT_FILTER =
* 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.
endif.
endif.
ENDMODULE. " DISPLAY_ALV OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ZSTATUS'.
* SET TITLEBAR 'xxx'.
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
*& Module pool ZGDEMO_SIMPLE_ALV_GRID_7AM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
PROGRAM ZGDEMO_OO_ALV_PRINT_EVENTS_7AM.
*REPORT ZGDEMO_OO_ALV_PRINT_EVENTS_7AM.
DATA : O_CONTAINER TYPE REF TO
CL_GUI_CUSTOM_CONTAINER,
O_GRID TYPE REF TO
CL_GUI_ALV_GRID.
DATA : IT_EKKO TYPE TABLE OF EKKO,
WA_EKKO TYPE EKKO,
IT_EKPO TYPE TABLE OF EKPO.
*DEFINE EVENT HANDLER CLASS
CLASS LCL_EVENT_HANDLER DEFINITION.
PUBLIC SECTION.
METHODS : HANDLE_PRINT_TOP_OF_PAGE FOR EVENT
PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID,
HANDLE_PRINT_TOP_OF_LIST FOR EVENT
PRINT_TOP_OF_LIST OF CL_GUI_ALV_GRID,
HANDLE_PRINT_END_OF_LIST FOR EVENT
PRINT_END_OF_LIST OF CL_GUI_ALV_GRID,
HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK
OF CL_GUI_ALV_GRID
IMPORTING ES_ROW_NO,
HANDLE_TOOLBAR FOR EVENT TOOLBAR
OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT,
HANDLE_USER_COMMAND FOR EVENT USER_COMMAND
OF CL_GUI_ALV_GRID
IMPORTING E_UCOMM.
ENDCLASS.
*IMPLEMENTATION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
METHOD HANDLE_PRINT_TOP_OF_PAGE.
WRITE / 'I AM TOP OF PAGE'.
ENDMETHOD.
METHOD HANDLE_PRINT_TOP_OF_LIST.
WRITE / 'I AM TOP OF LIST'.
ENDMETHOD.
METHOD HANDLE_PRINT_END_OF_LIST.
WRITE / 'I AM END OF LIST'.
ENDMETHOD.
METHOD HANDLE_DOUBLE_CLICK.
READ TABLE IT_EKKO INTO WA_EKKO
INDEX ES_ROW_NO-ROW_ID.
SET PARAMETER ID 'BES' FIELD WA_EKKO-EBELN.
CALL TRANSACTION 'ME23N'.
ENDMETHOD.
METHOD HANDLE_TOOLBAR.
DATA WA_TOOLBAR TYPE STB_BUTTON.
WA_TOOLBAR-FUNCTION = 'DETAILED'.
WA_TOOLBAR-TEXT = 'Detailed List'.
APPEND WA_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
ENDMETHOD.
METHOD HANDLE_USER_COMMAND.
CASE E_UCOMM.
WHEN 'DETAILED'.
SELECT * INTO TABLE IT_EKPO FROM EKPO
FOR ALL ENTRIES IN IT_EKKO
WHERE EBELN = IT_EKKO-EBELN.
call method O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'EKPO'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
* IR_SALV_ADAPTER =
changing
IT_OUTTAB = IT_EKPO
* IT_FIELDCATALOG =
* IT_SORT =
* IT_FILTER =
* 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.
ENDCASE.
ENDMETHOD.
ENDCLASS.
*&---------------------------------------------------------------------*
*& Module READ_DATA OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE READ_DATA OUTPUT.
SELECT * INTO TABLE IT_EKKO FROM EKKO
UP TO 15 ROWS.
ENDMODULE. " READ_DATA OUTPUT
*&---------------------------------------------------------------------*
*& Module DISPLAY_ALV OUTPUT
*&---------------------------------------------------------------------*
MODULE DISPLAY_ALV OUTPUT.
*CREATE CONTAINER OBJ
create object O_CONTAINER
exporting
CONTAINER_NAME = 'CONTAINER'
.
if SY-SUBRC = 0.
*CREATE GRID OBJ
create object O_GRID
exporting
* I_SHELLSTYLE = 0
* I_LIFETIME =
I_PARENT = O_CONTAINER
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
* I_FCAT_COMPLETE = SPACE
* EXCEPTIONS
* ERROR_CNTL_CREATE = 1
* ERROR_CNTL_INIT = 2
* ERROR_CNTL_LINK = 3
* ERROR_DP_CREATE = 4
* others = 5
.
if SY-SUBRC = 0.
*REGISTER EVENT & HANDLER METHOD
DATA O_HANDLER TYPE REF TO LCL_EVENT_HANDLER.
CREATE OBJECT O_HANDLER.
SET HANDLER : O_HANDLER->HANDLE_PRINT_TOP_OF_PAGE
FOR O_GRID,
O_HANDLER->HANDLE_PRINT_TOP_OF_LIST
FOR O_GRID,
O_HANDLER->HANDLE_PRINT_END_OF_LIST
FOR O_GRID,
O_HANDLER->HANDLE_DOUBLE_CLICK FOR O_GRID,
O_HANDLER->HANDLE_TOOLBAR FOR O_GRID,
O_HANDLER->HANDLE_USER_COMMAND FOR O_GRID.
*DISPLAY
call method O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'EKKO'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
* IR_SALV_ADAPTER =
changing
IT_OUTTAB = IT_EKKO
* IT_FIELDCATALOG =
* IT_SORT =
* IT_FILTER =
* 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.
endif.
endif.
ENDMODULE. " DISPLAY_ALV OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'ZSTATUS'.
* SET TITLEBAR 'xxx'.
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
No comments:
Post a Comment