Code: Alles auswählen.
MODULE alv_grid_0100 OUTPUT.
IF go_custom IS INITIAL.
CREATE OBJECT go_custom
EXPORTING
container_name = 'CSTM_CTRL'.
" Name of the dynpro CustCtrl name to link this container to
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
IF go_alv IS INITIAL.
CREATE OBJECT go_alv
EXPORTING
* i_shellstyle = 0
* i_lifetime =
i_parent = go_custom " Parent-Container
i_appl_events = ' ' " alle Events registrieren
* i_parentdbg =
* i_applogparent = go_cstm_ctrl_fm " Container für das Fehler-Log
* i_graphicsparent =
* i_name =
* i_fcat_complete = SPACE
* EXCEPTIONS
* error_cntl_create = 1
* error_cntl_init = 2
* error_cntl_link = 3
* error_dp_create = 4
* others = 5
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Settings for grid...
lcl_settings=>set_fcat( CHANGING ct_fcat = gt_fcat ).
lcl_settings=>set_layout( CHANGING cs_layout = gs_layout ).
lcl_settings=>set_sort( CHANGING ct_sort = gt_sort ) .
lcl_settings=>set_toolbar( CHANGING ct_toolbar = gt_toolbar_excl ).
* Edit-Mode aktiv setzen
CALL METHOD go_alv->set_ready_for_input
EXPORTING i_ready_for_input = 1.
** Ereignisbehandler registrieren
SET HANDLER lcl_event_handler=>handle_data_changed FOR go_alv.
**§3.Optionally register ENTER to raise event DATA_CHANGED.
CALL METHOD go_alv->register_edit_event
EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter.
* ALV darstellen
CALL METHOD go_alv->set_table_for_first_display
EXPORTING
i_buffer_active = 'X'
i_bypassing_buffer = 'X'
* i_structure_name = " Strukturname der int. Ausgabetabelle
* is_variant =
i_save = 'A'
"U = nur benutzerspezif. Varianten abspeicherbar
i_default = 'X'
" Benutzer darf Variante als Default kennzeichnen
is_layout = gs_layout
* is_print =
* it_special_groups =
it_toolbar_excluding = gt_toolbar_excl
CHANGING
it_outtab = gt_pos_daten
it_fieldcatalog = gt_fcat
it_sort = gt_sort
* it_filter =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSE. " IF go_custom IS NOT INITIAL.
go_alv->refresh_table_display( ).
ENDIF.
ENDMODULE. " ALV_GRID_0100 OUTPUT
Code: Alles auswählen.
METHOD handle_data_changed.
" FOR EVENT data_changed + Drücken d. ENTER-Taste
DATA: ls_mod_cells LIKE LINE OF er_data_changed->mt_mod_cells,
lv_msg TYPE bapireturn1,
lv_temp TYPE string,
lv_matnr TYPE matnr.
" auf Vorhandensein des Materials prüfen
READ TABLE er_data_changed->mt_mod_cells INTO ls_mod_cells INDEX 1.
IF ls_mod_cells-fieldname EQ 'MATNR_BEIST'.
PERFORM check_mat_vorhanden_evt
USING er_data_changed->mt_mod_cells
CHANGING lv_msg.
IF lv_msg IS NOT INITIAL.
" Material nicht gefunden -> FM an User
lv_temp = lv_msg-message.
gv_error = abap_true.
TRY .
CALL METHOD er_data_changed->add_protocol_entry
EXPORTING
i_msgid = lv_msg-id
i_msgty = lv_msg-type
i_msgno = lv_msg-number
i_msgv1 = lv_temp
* i_msgv2 =
* i_msgv3 =
* i_msgv4 =
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id
" Welche Zeile der Anzeige hat den Fehler
i_tabix = ls_mod_cells-tabix
.
CATCH cx_root.
ENDTRY.
ELSE.
" Material vorhanden -> jetzt weitere Daten laden
lv_matnr = ls_mod_cells-value.
PERFORM hole_materialdaten USING lv_matnr
ls_mod_cells-row_id.
ENDIF.
ENDIF.
ENDMETHOD.
Code: Alles auswählen.
FORM do_check.
" Daten aus ALV rüberholen ..
go_alv->check_changed_data( ).
" .. zuerst leer gelassene Zeilen entfernen ...
PERFORM delete_leere_zeilen.
" Prüfung auf Vollständigkeit der restl. Zeilen
PERFORM check_alv_komlett_gefuellt.
" jetzt richtige Prüfung
PERFORM check_beistell_posn.
ENDFORM.