Code: Alles auswählen.
* Event 'DATA_CHANGED' registrieren
wa_events_lvc-name = 'DATA_CHANGED'.
wa_events_lvc-form = 'DO_DATA_CHANGED'.
APPEND wa_events_lvc TO it_events_lvc.
Code: Alles auswählen.
* Grid-Settings einstellen
wa_grid_settings_lvc-edt_cll_cb = 'X'.
Code: Alles auswählen.
FORM do_data_changed USING data_changed TYPE REF TO
cl_alv_changed_data_protocol.
Code: Alles auswählen.
*----------------------------------------------------------------------*
* FORM DO_DATA_CHANGED
*----------------------------------------------------------------------*
* Auf Dateneingabe reagieren
* !!! Dynamischer Aufruf vom ALV. Keine Parameterübergabe
* !!! ==> direkter Zugriff auf benötigte Werte des Hauptprogramms
*----------------------------------------------------------------------*
* -->
* <--
*----------------------------------------------------------------------*
FORM do_data_changed USING data_changed TYPE REF TO
cl_alv_changed_data_protocol.
DATA: wa_alv TYPE lin_output_alv_lvc.
DATA: wa_mod_cell TYPE lvc_s_modi.
DATA: h_check_int TYPE i.
* wenn keine Datenänderung => FORM verlassen
CHECK NOT data_changed->mt_mod_cells IS INITIAL.
* Eingabe auf Integer prüfen
READ TABLE data_changed->mt_mod_cells INTO wa_mod_cell
INDEX 1 TRANSPORTING value.
CATCH SYSTEM-EXCEPTIONS convt_no_number = 901.
COMPUTE h_check_int = wa_mod_cell-value.
ENDCATCH.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* geänderte Zeile ermitteln
READ TABLE data_changed->mt_mod_cells INTO wa_mod_cell
INDEX 1 TRANSPORTING row_id.
* Werte der einzelnen Spalten holen
CALL METHOD data_changed->get_cell_value
EXPORTING i_row_id = wa_mod_cell-row_id
i_fieldname = 'EKORG'
IMPORTING e_value = wa_alv-ekorg.
CALL METHOD data_changed->get_cell_value
EXPORTING i_row_id = wa_mod_cell-row_id
i_fieldname = 'PVERH'
IMPORTING e_value = wa_alv-pverh.
CALL METHOD data_changed->get_cell_value
EXPORTING i_row_id = wa_mod_cell-row_id
i_fieldname = 'PROQU'
IMPORTING e_value = wa_alv-proqu.
CALL METHOD data_changed->get_cell_value
EXPORTING i_row_id = wa_mod_cell-row_id
i_fieldname = 'LIETR'
IMPORTING e_value = wa_alv-lietr.
CALL METHOD data_changed->get_cell_value
EXPORTING i_row_id = wa_mod_cell-row_id
i_fieldname = 'SERVI'
IMPORTING e_value = wa_alv-servi.
* Berechnung
PERFORM set_ges_pkt CHANGING wa_alv.
* neuen Wert in die Zeile schreiben
CALL METHOD data_changed->modify_cell
EXPORTING i_row_id = wa_mod_cell-row_id
i_fieldname = 'GESPKT'
i_value = wa_alv-gespkt.
ENDFORM. "DO_DATA_CHANGED