ALV-Layoutvariante im Selektionsbildschirm bei Klasse CL GUI ALV GRID
Aus SAP-Wiki
(Weitergeleitet von ALV-Layoutvariante im Selektionsbildschirm)
Zur Navigation springenZur Suche springen
In einer ALV-Layoutvariante können Einstellungen gespeichert werden wie
- Reihenfolge Ausgabe Felder
- Felder aus Anzeige ausblenden
- Filter
- Sortierung
- Layouteinstellungen
Die gewünschte Layoutvariante kann nach Anzeige der ALV-Liste gewählt werden - aber auch bereits im Selektionsbildschirm gewählt werden.
Selektionsbildschirm
Parameter: p_vari TYPE disvariant-variant.
Initialization
INITIALIZATION. PERFORM initialization changing p_vari.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR <FIELD>
*----------------------------------------------------------------------* * AT SELECTION-SCREEN ON VALUE-REQUEST FOR <field> *----------------------------------------------------------------------* AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari. PERFORM at_selection_screen_for_vari CHANGING p_vari.
Form INITIALIZATION
*&---------------------------------------------------------------------* *& Form INITIALIZATION *&---------------------------------------------------------------------* * Default Routinen *----------------------------------------------------------------------* FORM initialization changing pcv_vari type disvariant-variant. DATA: lv_report TYPE rsvar-report, ls_variant TYPE disvariant. * Defaultlayoutvariante ls_variant-report = sy-repid. ls_variant-handle = gv_handle_num1. CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET' "aus Tabelle LTDX EXPORTING i_save = 'A' CHANGING cs_variant = ls_variant EXCEPTIONS not_found = 2. IF sy-subrc = 0. pcv_vari = ls_variant-variant. ENDIF. ENDFORM. "INITIALIZATION
Form AT_SELECTION_SCREEN_FOR_VARI
*&---------------------------------------------------------------------* *& Form AT_SELECTION_SCREEN_FOR_VARI *&---------------------------------------------------------------------* * Liste aller Layoutvarianten wird angeboten und gewählt * Die Selektionsvarianten sind in der Tabelle LTDX gespeichrt *----------------------------------------------------------------------* FORM at_selection_screen_for_vari CHANGING pcv_vari TYPE disvariant-variant. DATA: ls_variant_in TYPE disvariant, ls_variant_out TYPE disvariant, lv_exit TYPE c. ls_variant_in-report = sy-repid. ls_variant_in-handle = gv_handle_num1. * Zeigt Liste aller Layoutvarianten an: Benutzervarianten und Standardvarianten CALL FUNCTION 'REUSE_ALV_VARIANT_F4' EXPORTING is_variant = ls_variant_in i_save = 'A' "Benutzer und Standardlayoutvarianten IMPORTING e_exit = lv_exit es_variant = ls_variant_out EXCEPTIONS not_found = 2. IF sy-subrc = 2. MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ELSE. IF lv_exit = space. pcv_vari = ls_variant_out-variant. ENDIF. ENDIF. ENDFORM. " AT_SELECTION_SCREEN_FOR_VARI
Form ALV_2000
*&---------------------------------------------------------------------* *& Form alv_2000 *&---------------------------------------------------------------------* * ALV-Output *----------------------------------------------------------------------* form alv_2000. **************** * Fill Variant * **************** ls_variant-report = sy-repid. ls_variant-handle = gv_handle_num1. ls_variant-variant = p_vari.
* Rufe die ALV-Liste auf CALL METHOD go_alv_cont1->set_table_for_first_display EXPORTING i_bypassing_buffer = 'X' "lv_bypassing_buffer i_save = 'A' "lv_save * i_default = 'X' is_layout = ls_layout * it_toolbar_excluding = lt_toolbar_excluding * is_variant = ls_variant CHANGING it_outtab = pct_list it_fieldcatalog = lt_fcat. endform.