Code: Alles auswählen.
TYPES: BEGIN OF ty_filialstamm,
bukrs TYPE bukrs, " Buchungskreis (ZMM_WERKMAT)
ekorg TYPE ekorg, " Einkaufsorganisation
vkorg TYPE vkoiv, " Verkaufsorganisation
werks TYPE werks_d, " Werk
name1 TYPE name1, " Name (T001W)
stras TYPE stras, " Strasse (T001W)
pstlz TYPE pstlz, " PZL (T001W)
ort01 TYPE ort01, " Ort (T001W)
land1 TYPE land1, " Land (T001W)
END OF ty_filialstamm.
* Datentabellen
DATA: gt_filialstamm TYPE STANDARD TABLE OF ty_filialstamm.
* Workareas
DATA: wa_filialstamm TYPE ty_filialstamm.
* alv Listausgabe
DATA: go_alv TYPE REF TO cl_salv_table,
go_column TYPE REF TO cl_salv_column_table,
go_columns TYPE REF TO cl_salv_columns_table,
go_functions TYPE REF TO cl_salv_functions_list, " toolbar
go_display TYPE REF TO cl_salv_display_settings,
go_layout TYPE REF TO cl_salv_layout,
go_selections TYPE REF TO cl_salv_selections, " multiselect
go_sort TYPE REF TO cl_salv_sorts, " von Anfang an sortiert ausgeben
go_events TYPE REF TO cl_salv_events_table, " Events
go_event_handler TYPE REF TO lcl_handle_events,
gx_salv_msg TYPE REF TO cx_salv_msg, " exceptions
gx_salv_not_found TYPE REF TO cx_salv_not_found,
gx_salv_existing TYPE REF TO cx_salv_existing,
gx_salv_data_error TYPE REF TO cx_salv_data_error,
gs_layoutkey TYPE salv_s_layout_key.
Code: Alles auswählen.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = go_alv
CHANGING
t_table = gt_filialstamm ).
CATCH cx_salv_msg INTO gx_salv_msg.
MESSAGE 'Die Listenausgabe konnte nicht generiert werden' TYPE 'E'.
ENDTRY.
* Eigene Überschriften setzen
go_columns = go_alv->get_columns( ).
PERFORM alv_columntitles.
* Zeilen der Liste farblich unterscheiden
go_display = go_alv->get_display_settings( ).
go_display->set_striped_pattern( abap_true ).
* Spaltenbreite optimieren
TRY.
go_columns->set_optimize( 'X' ).
CATCH cx_salv_data_error INTO gx_salv_data_error.
ENDTRY.
* Funktionstasten (Sortieren, Filtern, Excel-Export etc.)
go_functions = go_alv->get_functions( ).
go_functions->set_all( abap_true ).
* Dem Benutzer erlauben, eigene Anzeigevarianten zu speichern
go_layout = go_alv->get_layout( ).
gs_layoutkey-report = sy-repid.
go_layout->set_key( gs_layoutkey ).
go_layout->set_default( abap_true ).
go_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
* Dem Benutzer erlauben, mehrere Zellen/Zeilen/Spalten zu selektieren
go_selections = go_alv->get_selections( ).
CALL METHOD go_selections->set_selection_mode
EXPORTING
value = if_salv_c_selection_mode=>multiple.
* Titel
go_display = go_alv->get_display_settings( ).
go_display->set_list_header( 'Stammdaten aller Filialen im selektierten Bereich' ).
* Eigenes Menü (GUI-Status)
CALL METHOD go_alv->set_screen_status(
EXPORTING
report = sy-repid
pfstatus = 'STANDARD'
set_functions = go_alv->c_functions_all ).
* Tabelle direkt nach mehreren Spalten sortiert ausgeben (damit auch gleiche Spalteninhalte zusammenfügen)
PERFORM sort_alv.
go_alv->display( ).
Code: Alles auswählen.
*----------------------------------------------------------------------*
* Form sort_alv
*----------------------------------------------------------------------*
* ALV nach mehreren Spalten sortieren und diese gruppieren
*----------------------------------------------------------------------*
FORM sort_alv.
CALL METHOD go_alv->get_sorts
RECEIVING
value = go_sort.
TRY.
CALL METHOD go_sort->add_sort
EXPORTING
columnname = 'BUKRS'
position = '1'
sequence = if_salv_c_sort=>sort_up.
* subtotal = IF_SALV_C_BOOL_SAP=>FALSE
* group = IF_SALV_C_SORT=>GROUP_NONE
* obligatory = IF_SALV_C_BOOL_SAP=>FALSE.
CATCH cx_salv_not_found.
CATCH cx_salv_existing.
CATCH cx_salv_data_error.
ENDTRY.
TRY.
CALL METHOD go_sort->add_sort
EXPORTING
columnname = 'EKORG'
position = '2'
sequence = if_salv_c_sort=>sort_up.
* subtotal = IF_SALV_C_BOOL_SAP=>FALSE
* group = IF_SALV_C_SORT=>GROUP_NONE
* obligatory = IF_SALV_C_BOOL_SAP=>FALSE.
CATCH cx_salv_not_found.
CATCH cx_salv_existing.
CATCH cx_salv_data_error.
ENDTRY.
TRY.
CALL METHOD go_sort->add_sort
EXPORTING
columnname = 'VKORG'
position = '3'
sequence = if_salv_c_sort=>sort_up.
* subtotal = IF_SALV_C_BOOL_SAP=>FALSE
* group = IF_SALV_C_SORT=>GROUP_NONE
* obligatory = IF_SALV_C_BOOL_SAP=>FALSE.
CATCH cx_salv_not_found.
CATCH cx_salv_existing.
CATCH cx_salv_data_error.
ENDTRY.
ENDFORM. "sort_alv