Code: Alles auswählen.
REPORT.
************************************************************************
* DATEN DEFINITION *
************************************************************************
TYPE-POOLS: slis.
TYPES:
* Type für Datentabelle
BEGIN OF t_data,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
spras TYPE makt-spras,
END OF t_data,
* Type für ALV-Ausgabetabelle
BEGIN OF t_alv,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
spras TYPE makt-spras,
dd_handle TYPE int4,
END OF t_alv.
DATA:
* Tabelle/Arbeitsbreich für den Feldkatalog des ALV
gt_fieldcatalog TYPE lvc_t_fcat,
gw_fieldcatalog TYPE lvc_s_fcat,
* Tabelle/Arbeitsbereich für DropDownListWerte
gt_ddval TYPE lvc_t_drop,
gw_ddval TYPE lvc_s_drop,
* Tabelle/Arbeitsbereich für Events
gt_events TYPE slis_t_event,
gw_events TYPE slis_alv_event,
* Tabelle/Arbeitsbereich für Daten
gt_data TYPE TABLE OF t_data,
gw_data TYPE t_data,
* Tabelle/Arbeitsbereich für ALV-Ausgabe-Tabelle
gt_alv TYPE TABLE OF t_alv,
gw_alv TYPE t_alv,
* Programmname
g_repid TYPE sy-repid VALUE sy-repid.
************************************************************************
* SELECTION SCREEN *
************************************************************************
SELECT-OPTIONS: s_matnr FOR gw_data-matnr DEFAULT '4711'.
************************************************************************
* START-OF-SELECTION *
************************************************************************
START-OF-SELECTION.
* Daten beschaffen
SELECT matnr maktx spras
INTO TABLE gt_data
FROM makt
WHERE matnr IN s_matnr
AND spras EQ 'DE'.
* Daten übernehemen
LOOP AT gt_data INTO gw_data.
MOVE-CORRESPONDING gw_data TO gw_alv.
APPEND gw_alv TO gt_alv.
ENDLOOP.
* Feldkatalog erstellen
PERFORM creat_fieldcat.
* Wertetabelle für Dropdownbox füllen.
PERFORM creat_dropdown_values.
* Tabelle mit Event-Exits erstellen
PERFORM creat_event_exits.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = g_repid
it_fieldcat_lvc = gt_fieldcatalog
it_events = gt_events
TABLES
t_outtab = gt_alv.
*---------------------------------------------------------------------*
* Form creat_fieldcat
*---------------------------------------------------------------------*
FORM creat_fieldcat.
CLEAR gw_fieldcatalog.
gw_fieldcatalog-fieldname = 'MATNR'.
gw_fieldcatalog-ref_field = 'MATNR'.
gw_fieldcatalog-ref_table = 'MAKT'.
APPEND gw_fieldcatalog TO gt_fieldcatalog.
CLEAR gw_fieldcatalog.
gw_fieldcatalog-fieldname = 'MAKTX'.
gw_fieldcatalog-ref_field = 'MAKTX'.
gw_fieldcatalog-ref_table = 'MAKT'.
APPEND gw_fieldcatalog TO gt_fieldcatalog.
CLEAR gw_fieldcatalog.
gw_fieldcatalog-fieldname = 'SPRAS'.
gw_fieldcatalog-OUTPUTLEN = '7'.
gw_fieldcatalog-dd_outlen = '7'.
gw_fieldcatalog-intlen = '2'.
gw_fieldcatalog-inttype = 'C'.
gw_fieldcatalog-coltext = 'Sprache'.
gw_fieldcatalog-tooltip = 'Sprache'.
gw_fieldcatalog-seltext = 'Sprache'.
gw_fieldcatalog-drdn_field = 'DD_HANDLE'.
APPEND gw_fieldcatalog TO gt_fieldcatalog.
ENDFORM. " creat_fieldcat
*---------------------------------------------------------------------*
* Form creat_dropdown_values
*---------------------------------------------------------------------*
FORM creat_dropdown_values.
DATA: l_spras TYPE makt-spras,
l_count TYPE i.
* Es werden nur die Sprachen angeboten, für die das Material einen
* gepflegten Kurztext hat.
LOOP AT gt_alv INTO gw_alv.
ADD 1 TO l_count.
* alle Sprachen hohlen
SELECT spras
INTO l_spras
FROM makt
WHERE matnr = gw_alv-matnr.
* Daten in DropDownListe übernhemen.
CLEAR gw_ddval.
gw_ddval-handle = l_count.
gw_ddval-value = l_spras.
APPEND gw_ddval TO gt_ddval.
ENDSELECT.
* Leere Zeile in Drop-Down-Liste
CLEAR gw_ddval.
gw_ddval-handle = l_count.
gw_ddval-value = ' '.
APPEND gw_ddval TO gt_ddval.
* Den Handel der Ausgabetablle mitgeben
gw_alv-dd_handle = l_count.
MODIFY gt_alv FROM gw_alv.
ENDLOOP.
ENDFORM. " creat_dropdown_values
*---------------------------------------------------------------------*
* Form creat_event_exits
*---------------------------------------------------------------------*
FORM creat_event_exits .
gw_events-name = 'CALLER_EXIT'.
gw_events-form = 'CALLER_EXIT'.
APPEND gw_events TO gt_events.
ENDFORM. " creat_event_exits
*---------------------------------------------------------------------*
* Form PF_STATUS_SET
*---------------------------------------------------------------------*
FORM caller_exit USING ls_data TYPE slis_data_caller_exit.
* Referenz auf ALV-Objekt
DATA: l_ref_alv TYPE REF TO cl_gui_alv_grid.
* Referenz auf ALV hohlen
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_ref_alv.
* Die Dropdown-Values dem Grid übergeben
CALL METHOD l_ref_alv->set_drop_down_table
EXPORTING
it_drop_down = gt_ddval.
ENDFORM. "CALLER_EXIT