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.
TRY.
DATA: it_sflight TYPE STANDARD TABLE OF sflight WITH DEFAULT KEY.
SELECT * INTO TABLE it_sflight FROM sflight WHERE carrid = 'LH'.
* Window-Style hier ohne cl_gui_control=>ws_thickframe vordefinieren, wenn das Fenster nicht richtig maximized werden soll
DATA(lv_style) = cl_gui_control=>ws_thickframe + cl_gui_control=>ws_minimizebox + cl_gui_control=>ws_maximizebox + cl_gui_control=>ws_sysmenu.
* siehe auch https://download.consolut.com/direct/SAP_PrintDoku/de/BCCIDOCK/BCCIDOCK.PDF
* Top, Left, Width, Height in Pixel
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
style = lv_style
metric = cl_gui_dialogbox_container=>metric_pixel ).
* 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 und in das Containerfenster einbetten
cl_salv_table=>factory( EXPORTING r_container = o_cnt
IMPORTING r_salv_table = o_salv
CHANGING t_table = it_sflight ).
* automatische Spaltenbreite
o_salv->get_columns( )->set_optimize( abap_true ).
* Darstellung mit Striped-Pattern
o_salv->get_display_settings( )->set_striped_pattern( abap_true ).
o_salv->display( ).
* cl_gui_container=>default_screen erzwingen
WRITE: space.
CATCH cx_root.
ENDTRY.