Code: Alles auswählen.
INITIALIZATION.
PERFORM get_default_layout CHANGING p_layout.
Code: Alles auswählen.
FORM get_default_layout CHANGING p_layout TYPE slis_vari.
DATA:
ls_layout TYPE salv_s_layout_info,
ls_key TYPE salv_s_layout_key.
ls_key-report = sy-repid.
ls_layout = cl_salv_layout_service=>get_default_layout(
s_key = ls_key
).
p_layout = ls_layout-layout.
ENDFORM.
Code: Alles auswählen.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
PERFORM f4_layout CHANGING p_layout.
Code: Alles auswählen.
FORM f4_layout CHANGING p_layout TYPE slis_vari.
DATA:
ls_layout_key TYPE salv_s_layout_key,
ls_layout_info TYPE salv_s_layout_info.
ls_layout_key-report = sy-repid.
ls_layout_info = cl_salv_layout_service=>f4_layouts( ls_layout_key ).
p_layout = ls_layout_info-layout.
ENDFORM.
Code: Alles auswählen.
Data:
lr_layout type ref to CL_SALV_LAYOUT.
* pr_salv ist dein CL_SALV_TABLE Referenz
lr_layout = pr_salv->get_layout( ).
* falls dein Reportparameter gefüllt ist, sendest du das vor der Displaymethode
* an deinen ALV
IF p_layout IS NOT INITIAL.
lr_layout->set_initial_layout( p_layout ).
ENDIF.
Folgende Benutzer bedankten sich beim Autor ST22 für den Beitrag (Insgesamt 2):
LD57 • Stefanouis
Code: Alles auswählen.
TYPES:BEGIN OF ty_test,
name2 TYPE name2,
ort01 TYPE ort01,
rbetr TYPE rbetr,
END OF ty_test.
PARAMETERS:p_layout TYPE slis_vari.
data: gt_outtab TYPE TABLE OF ty_test.
data: gr_alv TYPE REF TO cl_salv_table,
gr_columns TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column_table,
gr_layout TYPE REF TO cl_salv_layout.
INITIALIZATION.
if p_layout is NOT INITIAL.
PERFORM get_default_layout CHANGING p_layout.
endif.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
PERFORM f4_layout CHANGING p_layout.
select name2 ort01 rbetr from reguh into corresponding fields of table gt_outtab.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = gt_outtab
).
Data:
lr_layout type ref to CL_SALV_LAYOUT.
* pr_salv ist dein CL_SALV_TABLE Referenz
lr_layout = gr_alv->get_layout( ).
* falls dein Reportparameter gefüllt ist, sendest du das vor der Displaymethode
* an deinen ALV
IF p_layout IS NOT INITIAL.
lr_layout->set_initial_layout( p_layout ).
ENDIF.
* Einschalten der Funktionssymbole vom ALV-Grid.
gr_alv->get_functions( )->set_all( abap_true ).
" Ausgabe der Daten per ALV-Grid.
gr_alv->display( ).
FORM get_default_layout CHANGING p_layout TYPE slis_vari.
DATA:
ls_layout TYPE salv_s_layout_info,
ls_key TYPE salv_s_layout_key.
ls_key-report = sy-repid.
ls_layout = cl_salv_layout_service=>get_default_layout(
s_key = ls_key
).
p_layout = ls_layout-layout.
ENDFORM.
FORM f4_layout CHANGING p_layout TYPE slis_vari.
DATA:
ls_layout_key TYPE salv_s_layout_key,
ls_layout_info TYPE salv_s_layout_info.
ls_layout_key-report = sy-repid.
ls_layout_info = cl_salv_layout_service=>f4_layouts( ls_layout_key ).
p_layout = ls_layout_info-layout.
ENDFORM.
Du solltest dich mal mit Reporting-Ereignisblöcken beschäftigen.
Code: Alles auswählen.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
PERFORM f4_layout CHANGING p_layout.
START-OF-SELECTION. "<---neuer Ereignisblock
select name2 ort01 rbetr from reguh into corresponding fields of table gt_outtab.
cl_salv_table=>factory(
Code: Alles auswählen.
INITIALIZATION.
if p_layout is NOT INITIAL.
PERFORM get_default_layout CHANGING p_layout.
endif.