ALV без экрана
Создание на write экране:
1 2 3 4 5 6 7 8 9 10 |
START-OF-SELECTION. DATA: it_sflight TYPE STANDARD TABLE OF sflight. SELECT * FROM sflight INTO TABLE @it_sflight. DATA(o_alv) = NEW cl_gui_alv_grid( i_parent = cl_gui_container=>default_screen ). o_alv->set_table_for_first_display( EXPORTING i_structure_name = 'SFLIGHT' CHANGING it_outtab = it_sflight ). WRITE space. |
Создание на подэкране:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
SELECTION-SCREEN BEGIN OF SCREEN 100. SELECTION-SCREEN END OF SCREEN 100. START-OF-SELECTION. DATA: it_sflight TYPE STANDARD TABLE OF sflight. SELECT * FROM sflight INTO TABLE @it_sflight. DATA(o_alv) = NEW cl_gui_alv_grid( i_parent = cl_gui_container=>default_screen ). o_alv->set_table_for_first_display( EXPORTING i_structure_name = 'SFLIGHT' CHANGING it_outtab = it_sflight ). CALL SCREEN 100. |
Два ALV через разделитель:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
DATA: lt_sflight TYPE TABLE OF sflight. START-OF-SELECTION. SELECT * FROM sflight INTO TABLE @lt_sflight. DATA(l_splitter) = NEW cl_gui_splitter_container( parent = cl_gui_container=>default_screen no_autodef_progid_dynnr = abap_true " wichtig rows = 1 columns = 2 ). DATA(l_container_left) = l_splitter->get_container( row = 1 column = 1 ). DATA(l_container_right) = l_splitter->get_container( row = 1 column = 2 ). l_splitter->set_column_width( id = 1 width = 30 ). DATA(l_alv_left) = NEW cl_gui_alv_grid( i_parent = l_container_left ). DATA(l_alv_right) = NEW cl_gui_alv_grid( i_parent = l_container_right ). l_alv_left->set_table_for_first_display( EXPORTING i_structure_name = 'SFLIGHT' CHANGING it_outtab = lt_sflight ). l_alv_right->set_table_for_first_display( EXPORTING i_structure_name = 'SFLIGHT' CHANGING it_outtab = lt_sflight ). WRITE: space. |
Во всплывающем диалоге:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
CLASS lcl_events DEFINITION. PUBLIC SECTION. CLASS-METHODS: on_close FOR EVENT close OF cl_gui_dialogbox_container IMPORTING sender. ENDCLASS. CLASS lcl_events IMPLEMENTATION. METHOD on_close. IF sender IS NOT INITIAL. sender->free( ). ENDIF. ENDMETHOD. ENDCLASS. START-OF-SELECTION. DATA: it_sflight TYPE STANDARD TABLE OF sflight WITH DEFAULT KEY. SELECT * INTO TABLE it_sflight FROM sflight WHERE carrid = 'LH'. DATA(o_cnt) = NEW cl_gui_dialogbox_container( no_autodef_progid_dynnr = abap_true caption = 'Flüge' top = 1 left = 1 width = 640 height = 480 ). * Dialogbox-Container fullscreen (maximized) setzen o_cnt->set_alignment( cl_gui_control=>align_at_left + cl_gui_control=>align_at_right + cl_gui_control=>align_at_top + cl_gui_control=>align_at_bottom ). * OnClose-Handler setzen SET HANDLER lcl_events=>on_close FOR o_cnt. DATA: o_salv TYPE REF TO cl_salv_table. * SALV-Grid erzeugen cl_salv_table=>factory( EXPORTING r_container = o_cnt IMPORTING r_salv_table = o_salv CHANGING t_table = it_sflight ). o_salv->display( ). * cl_gui_container=>screen0 erzwingen WRITE: / space. |
Где в таком случае PAI ?
В ALV обработка событий осуществляется через класс обработчик и регистрацию на события.