Code: Alles auswählen.
[u]Top-Include
[/u]
tables: table,
lfa1,
kna1,
sscrfields.
select-options: s_lifnr for table-lifnr,
s_kunnr for table-kunnr.
data gt_table type table of table
data gr_table type ref to cl_salv_table.
data gr_functions type ref to cl_salv_functions.
data gr_columns type ref to cl_salv_columns_table.
data gr_column type ref to cl_salv_column_table.
data gr_display type ref to cl_salv_display_settings.
data ls_textfield LIKE smp_dyntxt.
“Button “Anlegen auf dem 1. Selection Screen””
SELECTION-SCREEN FUNCTION KEY 1.
INITIALIZATION.
ls_textfield-icon_id = '@17@'.
ls_textfield-icon_text = 'Daten Anlegen'.
ls_textfield-quickinfo = 'Daten Anlegen'.
sscrfields-functxt_01 = ls_textfield.
data ok_code type sy-ucomm.
[u]
Events[/u]
START-OF-SELECTION.
PERFORM select_data.
END-OF-SELECTION.
PERFORM display_data.
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'FC01'.
CALL SELECTION-SCREEN 8000 STARTING AT 10 10.
WHEN 'FC02'.
WHEN 'FC03'.
ENDCASE.
form select_data.
select * into corresponding fields of table gt_table from table
where lifnr in s_lifnr
and kunnr in s_kunnr.
if sy-subrc <> 0.
message text-001 type 'I'.
endif.
endform.
[u]Form[/u]
form display_data.
* Instanz der Klasse cl_salv_table erzeugen
try.
cl_salv_table=>factory(
importing r_salv_table = gr_table
changing t_table = gt_table ).
catch cx_salv_msg.
endtry.
* Funktionstasten (Sortieren, Filtern, Excel-Export etc.)
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
* optimale Spaltenbreite
gr_columns = gr_table->get_columns( ).
gr_columns->set_optimize( abap_true ).
* Titel und/oder Streifenmuster
gr_display = gr_table->get_display_settings( ).
gr_display->set_list_header( value = 'Daten anlegen in ZMF0015' ).
gr_display->set_striped_pattern( abap_true ).
try.
* Spalte "Mandant" holen
gr_column ?= gr_columns->get_column( 'MANDT' ).
* Spalte "Mandant" ausblenden
gr_column->set_visible( abap_false ).
* Den Namen für die Spalte LIFNR vergeben
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'LIFNR' ).
gr_column->set_long_text( 'Lieferant/Kunde' ).
gr_column->set_medium_text( '' ).
gr_column->set_short_text( '' ).
* Den Namen für die Spalte LINAM vergeben
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'LINAM' ).
gr_column->set_long_text( 'Lieferantenname' ).
gr_column->set_medium_text( '' ).
gr_column->set_short_text( '' ).
* Den Namen für die Spalte KUNNR vergeben
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'KUNNR' ).
gr_column->set_long_text( 'Lieferant/Kunde' ).
gr_column->set_medium_text( '' ).
gr_column->set_short_text( '' ).
* Den Namen für die Spalte KUNAM vergeben
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'KUNAM' ).
gr_column->set_long_text( 'Kundenname' ).
gr_column->set_medium_text( '' ).
gr_column->set_short_text( '' ).
catch cx_salv_not_found.
endtry.
* Liste anzeigen
gr_table->display( ).
endform.
[u]PBO[/u]
MODULE zstatus_8000 OUTPUT.
SET PF-STATUS 'ZSTATUS_8000'.
* Titel setzen
SET TITLEBAR 'TITLE_2000'.
ENDMODULE.
[u]PAI[/u]
MODULE zuser_command_8000 INPUT.
clear ok_code.
ok_code = sy-ucomm.
case ok_code.
* when 'EXIT'.
* clear ok_code.
* leave to screen 0.
*
* when 'BACK'.
* clear ok_code.
* leave to screen 0.
when 'CANCEL'.
clear ok_code.
leave to screen 0.
endcase.
ENDMODULE.
Folgende Benutzer bedankten sich beim Autor DeathAndPain für den Beitrag:
ManMan