Code: Alles auswählen.
*Datendeklaration für ALV-Ausgabe
DATA: gt_fieldcat TYPE lvc_t_fcat,
gs_fieldcat LIKE LINE OF gt_fieldcat.
DATA: cl_container TYPE REF TO cl_gui_custom_container,
cl_grid_alv TYPE REF TO cl_gui_alv_grid.
*Tabelle für ALV_AUSGABGE inkl. gleichnamiger STRUKTUR
DATA: gt_alv_output TYPE TABLE OF zmalvtest_st, "Tabelle
gs_alv_output TYPE zmalvtest_st.
Code: Alles auswählen.
REPORT zbwtest NO STANDARD PAGE HEADING.
TYPE-POOLS: slis.
TYPES: BEGIN OF type_ausgabe,
vbeln TYPE vbak-vbeln, "Inventurbeleg
auart TYPE vbak-auart, "Position
kunnr TYPE vbak-kunnr, "Materialnummer
color TYPE slis_t_specialcol_alv,
END OF type_ausgabe.
DATA:
tab_ausgabe TYPE STANDARD TABLE OF type_ausgabe,
wa_ausgabe TYPE type_ausgabe,
wa_color TYPE LINE OF slis_t_specialcol_alv.
*==================================================
*ALV-GRID Deklarationen
*==================================================
DATA:
alv_gt_fieldcat TYPE slis_t_fieldcat_alv,
alv_ls_fieldcat TYPE slis_fieldcat_alv,
alv_ls_layout TYPE slis_layout_alv.
***********************
INITIALIZATION.
***********************
REFRESH alv_gt_fieldcat.
CLEAR alv_ls_fieldcat.
alv_ls_fieldcat-fieldname = 'KUNNR'.
alv_ls_fieldcat-ref_tabname = 'VBAK'.
APPEND alv_ls_fieldcat TO alv_gt_fieldcat.
CLEAR alv_ls_fieldcat.
alv_ls_fieldcat-fieldname = 'VBELN'.
alv_ls_fieldcat-ref_tabname = 'VBAK'.
APPEND alv_ls_fieldcat TO alv_gt_fieldcat.
***********************
START-OF-SELECTION.
***********************
SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE tab_ausgabe.
READ TABLE tab_ausgabe INTO wa_ausgabe INDEX 5.
wa_color-fieldname = 'KUNNR'.
wa_color-color-col = '6'.
APPEND wa_color TO wa_ausgabe-color.
wa_color-fieldname = 'VBELN'.
wa_color-color-col = '5'.
APPEND wa_color TO wa_ausgabe-color.
MODIFY tab_ausgabe FROM wa_ausgabe INDEX 5.
***********************
END-OF-SELECTION.
***********************
alv_ls_layout-coltab_fieldname = 'COLOR'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = alv_ls_layout
it_fieldcat = alv_gt_fieldcat
i_save = 'A'
TABLES
t_outtab = tab_ausgabe
EXCEPTIONS
program_error = 1
OTHERS = 2.