Code: Alles auswählen.
* Tabellentypen
TYPES: BEGIN OF ty_itab,
matnr TYPE matnr,
menge TYPE bstmg,
werks TYPE ewerk,
END OF ty_itab.
* interne Tabellen
DATA: t_selektion TYPE STANDARD TABLE OF ty_selektion.
* ALV Variablen
DATA: go_grid_param TYPE REF TO cl_gui_alv_grid,
go_grid_ausgabe TYPE REF TO cl_gui_alv_grid,
go_cont_param TYPE REF TO cl_gui_custom_container,
go_cont_ausgabe TYPE REF TO cl_gui_custom_container,
gt_fcat_param TYPE lvc_t_fcat,
gt_fcat_ausgabe TYPE lvc_t_fcat,
save_ok LIKE sy-ucomm,
ok_code LIKE sy-ucomm.
* Klassen Variablen
CLASS cl_event_handler DEFINITION DEFERRED.
DATA go_event_handler TYPE REF TO cl_event_handler.
Code: Alles auswählen.
FORM alv_param_init.
DATA: ls_layout TYPE lvc_s_layo,
ls_variant TYPE disvariant,
ls_stable TYPE lvc_s_stbl.
* 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_change_finish_param FOR go_grid_param.
* Titel
ls_layout-grid_title = text(001).
* Mehrfachselektionen
ls_layout-sel_mode = 'A'.
* Alle Spalten editierbar machen
ls_layout-edit = 'X'.
ls_layout-val_data = '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
i_save = 'A'
CHANGING
it_fieldcatalog = gt_fcat_param
it_outtab = t_itab.
* 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.
* Wenn es ALV bereits gibt, dann aktualisieren
ELSE.
ls_stable = 'XX'.
CALL METHOD go_grid_param->refresh_table_display(
EXPORTING
is_stable = ls_stable ).
ENDIF.
ENDFORM. "alv_param_init
Code: Alles auswählen.
FORM user_command_2000.
* Falls der Benutzer etwas geändert hat ohne es vorher zu bestätigen
* wird zuerst data_changed gerufen, bevor die Eingabe verarbeitet wird
CALL METHOD go_grid_param->check_changed_data.
save_ok = ok_code.
CLEAR ok_code.
* Verarbeiten der Benutzereingabe
CASE save_ok.
* Programm verlassen, wenn entsprechende Buttons gedrückt wurden
WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
LEAVE PROGRAM.
* Bei entsprechendem Buttondruck Daten aus dem Zwischenspeicher in ALV einfügen
WHEN '2000'.
PERFORM tab_param_einfuegen.
* Bei entsprechendem Buttondruck das nächste Dynpro öffnen
WHEN '3000'.
...
ENDCASE.
ENDFORM. "user_command_2000
Code: Alles auswählen.
FORM tab_param_einfuegen.
TYPES: BEGIN OF ty_clipdata,
data TYPE c LENGTH 500,
END OF ty_clipdata.
CONSTANTS: h_split TYPE c VALUE cl_bcs_convert=>gc_tab. " # Zeichen
DATA: t_clipdata TYPE STANDARD TABLE OF ty_clipdata,
wa_clipdata TYPE ty_clipdata,
t_clipzeile TYPE STANDARD TABLE OF ty_clipdata,
wa_clipzeile TYPE ty_clipdata.
FIELD-SYMBOLS: <fs_itab> TYPE ty_itab,
<fs_feld> TYPE ANY.
DATA: ls_stable TYPE lvc_s_stbl.
CLEAR: wa_clipdata, wa_clipzeile.
cl_gui_frontend_services=>clipboard_import(
IMPORTING
data = t_clipdata
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4 ).
IF sy-subrc <> 0.
MESSAGE 'Error beim Importieren der Daten aus dem Zwischenspeicher.' TYPE 'E'.
EXIT.
ENDIF.
LOOP AT t_clipdata INTO wa_clipdata.
SPLIT wa_clipdata AT h_split INTO TABLE t_clipzeile.
APPEND INITIAL LINE TO t_itab ASSIGNING <fs_itab>.
LOOP AT t_clipzeile INTO wa_clipzeile.
ASSIGN COMPONENT sy-tabix OF STRUCTURE <fs_itab> TO <fs_feld>.
IF sy-subrc = 0.
<fs_feld> = wa_clipzeile-data.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM. "tab_param_einfuegen