Code: Alles auswählen.
REPORT zbeispiel_alv_farbe
NO STANDARD PAGE HEADING.
TYPE-POOLS: slis.
TYPES: BEGIN OF type_ausgabe,
iblnr TYPE ikpf-iblnr, "Inventurbeleg
zeili TYPE iseg-zeili, "Position
matnr TYPE mard-matnr, "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 = 'IBLNR'.
alv_ls_fieldcat-ref_tabname = 'IKPF'.
APPEND alv_ls_fieldcat TO alv_gt_fieldcat.
CLEAR alv_ls_fieldcat.
alv_ls_fieldcat-fieldname = 'ZEILI'.
alv_ls_fieldcat-ref_tabname = 'ISEG'.
APPEND alv_ls_fieldcat TO alv_gt_fieldcat.
***********************
START-OF-SELECTION.
***********************
SELECT * FROM iseg INTO CORRESPONDING FIELDS OF TABLE tab_ausgabe.
READ TABLE tab_ausgabe INTO wa_ausgabe INDEX 5.
wa_color-fieldname = 'IBLNR'.
wa_color-color-col = '6'.
APPEND wa_color TO wa_ausgabe-color.
wa_color-fieldname = 'ZEILI'.
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.