Code: Alles auswählen.
REPORT z_container_test.
* Deklarationen
DATA: ok_code TYPE syucomm,
lt_data TYPE TABLE OF zcas_test, " Datentabelle
ls_variant TYPE disvariant, " Struktur zur Layout-Konfiguration
lo_container TYPE REF TO cl_gui_container, " Containerklasse
lo_custom_container TYPE REF TO cl_gui_custom_container, " Custom-Container-Klasse
lo_splitter TYPE REF TO cl_gui_splitter_container, " Splittercontainer-Klasse
lo_alv TYPE REF TO cl_gui_alv_grid, " ALV-Klasse
lv_variante TYPE int1. " Auswahl der Container-Variante
* Select und Vorbereitung
SELECT matnr, ernam FROM mara INTO TABLE @lt_data UP TO 100 ROWS.
* Konfiguration des Layouts, damit der Layout-Admin läuft
ls_variant-username = sy-uname.
ls_variant-REPORT = sy-repid.
ls_variant-handle = 'testprogramm'.
PARAMETERS pv_var LIKE lv_variante.
START-OF-SELECTION.
* Hier die Container-Variante festlegen: Variante 3 ist die, die nicht funktioniert...
lv_variante = pv_var. " 1,2,3 oder 4
* 1: Default-Screen -> ALV (Layout-Admin funktioniert)
* 2: Custom-Container -> ALV (Layout-Admin funktioniert)
* !!!!! 3: Default-Screen -> Splitter-Container -> Container -> ALV (Layout-Admin funktioniert NICHT!!!)
* 4: Default-Screen -> Custom-Container -> Splitter-Container -> Container -> ALV (Layout-Admin funktioniert)
CASE lv_variante.
WHEN 1.
PERFORM alv_in_custom_container.
WHEN 2.
PERFORM alv_on_default_screen.
WHEN 3.
PERFORM alv_in_splitter_on_def_screen.
WHEN 4.
PERFORM alv_in_splitter_on_cc.
ENDCASE.
* Unterprogramme mit den verschiedenen Varianten
FORM alv_on_default_screen. " Default-Screen -> ALV
lo_alv = NEW #( i_parent = cl_gui_container=>default_screen ).
lo_alv->set_table_for_first_display( EXPORTING i_structure_name = 'ZCAS_TEST'
is_variant = ls_variant
i_save = 'A'
CHANGING it_outtab = lt_data
).
CALL SCREEN 9000. " Screen 9000 ist vollständig leer
ENDFORM.
FORM alv_in_custom_container. " Custom-Container -> ALV
lo_custom_container = NEW #( container_name = 'CC' ).
lo_alv = NEW #( i_parent = lo_custom_container ).
lo_alv->set_table_for_first_display( EXPORTING i_structure_name = 'ZCAS_TEST'
is_variant = ls_variant
i_save = 'A'
CHANGING it_outtab = lt_data
).
CALL SCREEN 9001. " Screen 9001 enthält einen Custom-Container
ENDFORM.
FORM alv_in_splitter_on_def_screen. " Default-Screen -> Splitter-Container -> Container -> ALV
lo_splitter = NEW #( parent = cl_gui_container=>default_screen
no_autodef_progid_dynnr = abap_true
rows = 1
columns = 2
).
lo_container = lo_splitter->get_container( row = 1 column = 1 ).
lo_alv = NEW #( i_parent = lo_container ).
lo_alv->set_table_for_first_display( EXPORTING i_structure_name = 'ZCAS_TEST'
is_variant = ls_variant
i_save = 'A'
CHANGING it_outtab = lt_data
).
CALL SCREEN 9000. " Screen 9000 ist vollständig leer
ENDFORM.
FORM alv_in_splitter_on_cc. " Custom-Container -> Splitter-Container -> Container -> ALV
lo_custom_container = NEW #( container_name = 'CC' ).
lo_splitter = NEW #( parent = lo_custom_container
no_autodef_progid_dynnr = abap_true
rows = 1
columns = 2
).
lo_container = lo_splitter->get_container( row = 1 column = 1 ).
lo_alv = NEW #( i_parent = lo_container ).
lo_alv->set_table_for_first_display( EXPORTING i_structure_name = 'ZCAS_TEST'
is_variant = ls_variant
i_save = 'A'
CHANGING it_outtab = lt_data
).
CALL SCREEN 9001. " Screen 9001 enthält einen Custom-Container
ENDFORM.
* PBOs und PAIs
*&---------------------------------------------------------------------*
*& Include Z_CONTAINER_TEST_PBO_PAI
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
SET PF-STATUS 'STATUS_9000'.
* SET TITLEBAR 'xxx'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
CASE ok_code.
WHEN 'OK'.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_9001 OUTPUT.
SET PF-STATUS 'STATUS_9001'.
* SET TITLEBAR 'xxx'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9001 INPUT.
CASE ok_code.
WHEN 'OK'.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
Code: Alles auswählen.
lo_splitter = NEW #( parent = cl_gui_container=>default_screen
no_autodef_progid_dynnr = abap_false
link_dynnr = '9000'
link_repid = sy-cprog
rows = 1
columns = 2 ).
Folgende Benutzer bedankten sich beim Autor ewx für den Beitrag:
tonyparzonka