Bsp. für die Verwendung von Events und Erzeugung von Headern
- REUSE_ALV_COMMENTARY_WRITE
- REUSE_ALV_EVENTS_GET,
- REUSE_ALV_GRID_DISPLAY I_CALLBACK_TOP_OF_PAGE,
- REUSE_ALV_GRID_DISPLAY IT_EVENTS
REPORT ztest42. "Bsp für "REUSE_ALV_COMMENTARY_WRITE " "REUSE_ALV_GRID_DISPLAY I_CALLBACK_TOP_OF_PAGE "REUSE_ALV_GRID_DISPLAY IT_EVENTS "REUSE_ALV_EVENTS_GET " "REUSE_ALV_COMMENTARY_WRITE "Variante 1: Aufruf über REUSE_ALV_GRID_DISPLAY I_CALLBACK_TOP_OF_PAGE "Variante 2: Aufruf über REUSE_ALV_GRID_DISPLAY IT_EVENTS "Variante 3: Aufruf direkt über PERFORM --> Ohne Wirkung TYPE-POOLS slis. data lt_fieldcat type SLIS_T_FIELDCAT_ALV. data lt_events type SLIS_T_EVENT. data lt_poarch like table of sflight. select * from sflight into CORRESPONDING FIELDS OF table lt_poarch. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_structure_name = 'SFLIGHT' CHANGING ct_fieldcat = lt_fieldcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. DELETE lt_fieldcat WHERE NOT ( fieldname = 'CARRID' OR fieldname = 'CONNID' OR fieldname = 'FLDATE' OR fieldname = 'PLANETYPE'). PERFORM set_event_for_alv USING lt_events. "Events umlegen perform form1. perform form2. perform form3. form form1. * call ALV data iv_repid like sy-repid. iv_repid = sy-repid. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = iv_repid it_fieldcat = lt_fieldcat "it_events = lt_events i_callback_top_of_page = 'DO_TOP_OF_PAGE' TABLES t_outtab = lt_poarch EXCEPTIONS program_error = 1 OTHERS = 2. endform. form form2. data iv_repid like sy-repid. iv_repid = sy-repid. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = iv_repid it_fieldcat = lt_fieldcat it_events = lt_events "i_callback_top_of_page = 'DO_TOP_OF_PAGE' TABLES t_outtab = lt_poarch EXCEPTIONS program_error = 1 OTHERS = 2. "PERFORM do_top_of_page. " endform. form form3. PERFORM do_top_of_page. " endform. *&--------------------------------------------------------------------* *& Form DO_TOP_OF_PAGE *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* FORM do_top_of_page. DATA: ls_line TYPE slis_listheader, lt_top_of_page TYPE TABLE OF slis_listheader. * Listenüberschrift: Typ H CLEAR ls_line. ls_line-typ = 'H'. * LS_LINE-KEY: not used for this type ls_line-info = 'Na'. APPEND ls_line TO lt_top_of_page. * Kopfinfo: Typ S CLEAR ls_line. ls_line-typ = 'S'. ls_line-key = 'wie'. ls_line-info = 'gehts'. APPEND ls_line TO lt_top_of_page. * Aktionsinfo: Typ A CLEAR ls_line. ls_line-typ = 'A'. * LS_LINE-KEY: not used for this type ls_line-info = 'so?'. APPEND ls_line TO lt_top_of_page. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = lt_top_of_page " I_LOGO = 'ENJOYSAP_LOGO' "I_END_OF_LIST_GRID = lt_poarch. . 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. "DO_TOP_OF_PAGE *&--------------------------------------------------------------------* *& Form set_event_for_alv *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* * -->LT_EVENTS text *---------------------------------------------------------------------* FORM set_event_for_alv USING lt_events TYPE slis_t_event. DATA: ls_event TYPE slis_alv_event. CALL FUNCTION 'REUSE_ALV_EVENTS_GET' EXPORTING i_list_type = 0 IMPORTING et_events = lt_events. * prüfen, ob das event für den listentyp 0 gibt. READ TABLE lt_events WITH KEY name = slis_ev_top_of_page INTO ls_event. IF sy-subrc = 0. * wenn ja dann unseren Perform setzten. MOVE 'DO_TOP_OF_PAGE' TO ls_event-form. modify lt_events from ls_event index sy-tabix. "APPEND ls_event TO lt_events. ENDIF. ENDFORM. "set_event_for_alv