Code: Alles auswählen.
CLASS cl_event_handler DEFINITION.
PUBLIC SECTION.
...
METHODS handle_data_changed_param " Prüfungen bei Datenänderung auf Dynpro 2000
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
...
ENDCLASS. "cl_event_handler DEFINITION
Code: Alles auswählen.
METHOD handle_data_changed_param.
DATA: ls_cell TYPE lvc_s_modi.
* Über verifizierte geänderte Zeilen loopen (die Zeilen, deren Werte mit ihren Datentypen kompatibel sind)
LOOP AT er_data_changed->mt_good_cells INTO ls_cell.
... " Prüfungen
ENDLOOP.
ENDMETHOD. "handle_data_changed_param
Code: Alles auswählen.
wa_fcat-tabname = 'T_SELEKTION'.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-col_pos = '1'.
wa_fcat-outputlen = '12'.
wa_fcat-scrtext_s = 'Material'.
wa_fcat-scrtext_m = 'Material'.
wa_fcat-scrtext_l = 'Material'.
wa_fcat-reptext = 'Material'.
wa_fcat-ref_table = 'EKPO'.
APPEND wa_fcat TO gt_fcat_param.
CLEAR wa_fcat.
wa_fcat-tabname = 'T_SELEKTION'.
wa_fcat-fieldname = 'MENGE'.
wa_fcat-col_pos = '2'.
wa_fcat-no_zero = 'X'.
wa_fcat-outputlen = '8'.
wa_fcat-scrtext_s = 'Menge'.
wa_fcat-scrtext_m = 'Menge'.
wa_fcat-scrtext_l = 'Menge'.
wa_fcat-reptext = 'Menge'.
wa_fcat-ref_table = 'EKPO'.
APPEND wa_fcat TO gt_fcat_param.
Code: Alles auswählen.
* Tabellentypen
TYPES: BEGIN OF ty_selektion,
matnr TYPE matnr, " EKPO - Materialnummer
...
menge TYPE bstmg, " EKPO - Menge
END OF ty_selektion.
* interne Tabellen
DATA: t_selektion TYPE STANDARD TABLE OF ty_selektion.
Code: Alles auswählen.
FORM alv_param_init.
DATA: ls_layout TYPE lvc_s_layo,
* lt_exclude TYPE ui_functions,
* ls_exclude TYPE ui_func,
ls_variant TYPE disvariant.
* nur ausführen, wenn das ALV noch nicht existiert (notwendig, falls man vom Folgedynpro zurückklickt)
IF go_cont_param IS INITIAL.
* Dynpro Status zuordnen
SET PF-STATUS 'STATUS'.
* Custom Container erstellen
CREATE OBJECT go_cont_param
EXPORTING
container_name = 'PARAM_2000'.
* Grid dem Container zuordnen
CREATE OBJECT go_grid_param
EXPORTING
i_parent = go_cont_param.
* Event Handlers erstellen
CREATE OBJECT go_event_handler.
SET HANDLER go_event_handler->handle_toolbar_param FOR go_grid_param.
SET HANDLER go_event_handler->handle_context_menu_param FOR go_grid_param.
SET HANDLER go_event_handler->handle_data_changed_param FOR go_grid_param.
* SET HANDLER go_event_handler->handle_user_command FOR go_grid_param.
* Titel
ls_layout-grid_title = 'XYZ'.
* Mehrfachselektionen
ls_layout-sel_mode = 'A'.
* Alle Spalten editierbar machen
ls_layout-edit = 'X'.
* Layout-Variante des Users laden
ls_variant-report = sy-repid.
ls_variant-username = sy-uname.
* Fieldcatalogue erstellen
PERFORM fcat_param_erstellen.
* Grid erstellen
CALL METHOD go_grid_param->set_table_for_first_display
EXPORTING
is_layout = ls_layout
is_variant = ls_variant
* it_toolbar_excluding = ls_exclude
i_save = 'A'
CHANGING
it_fieldcatalog = gt_fcat_param
it_outtab = t_selektion.
* Editierbare Zeilen aktivieren
CALL METHOD go_grid_param->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
* Enter als Möglichkeit registrieren, data_changed zu rufen
CALL METHOD go_grid_param->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
ENDIF.
ENDFORM. "alv_param_init
Code: Alles auswählen.
wa_fcat-ref_table = 'MARA'. " NICHT EKPO