Question:
Hi,
We are using the function module 'REUSE_ALV_GRID_DISPLAY' to generate the report in ALV format. The user wants to display the report columns with different colors.
Is there anyone who has the same experience doing the requirement mentioned above. In addition, the user also wants to highlight in color red a particular cell.
Thanks
Answer:
Use the same logic in the code below.
REPORT z_alv_colour.
TABLES: t001w.
*
TYPE-POOLS: slis.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
DATA: gs_layout TYPE slis_layout_alv.
DATA: farb1 TYPE slis_specialcol_alv.
*
DATA: BEGIN OF itab OCCURS 10,
werks LIKE t001w-werks,
name1 LIKE t001w-name1,
farb TYPE slis_t_specialcol_alv,
END OF itab.
*
REFRESH gt_fieldcat.
REFRESH itab.
*
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-ref_tabname = 'T001W'.
wa_fieldcat-emphasize = 'C2'.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-ref_tabname = 'T001W'.
wa_fieldcat-emphasize = 'C2'.
APPEND wa_fieldcat TO gt_fieldcat.
*
CLEAR gs_layout.
gs_layout-coltab_fieldname = 'FARB'.
*
SELECT * FROM t001w UP TO 5 ROWS.
CLEAR itab.
MOVE-CORRESPONDING t001w TO itab.
CLEAR farb1.
farb1-fieldname = 'WERKS'.
farb1-color-col = 2.
APPEND farb1 TO itab-farb.
farb1-fieldname = 'NAME1'.
farb1-color-col = 2.
APPEND farb1 TO itab-farb.
IF sy-dbcnt EQ 3 OR sy-dbcnt EQ 5.
CLEAR itab-farb.
CLEAR farb1.
farb1-fieldname = 'WERKS'.
farb1-color-col = 6.
APPEND farb1 TO itab-farb.
farb1-fieldname = 'NAME1'.
farb1-color-col = 5.
APPEND farb1 TO itab-farb.
ENDIF.
APPEND itab.
ENDSELECT.
*
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = gs_layout
it_fieldcat = gt_fieldcat
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
_________________
Cheers,
syd
Answer:
Thanks!
I've used the logic, AYOS!!!
Answer:
Woohooo!!
Congratulations, Dario...
And now, the time to edit the subject of your post has come, add [solved] to it... and register here, it's for free!!
_________________
Brief History of the Tuly Idiots
Bad advices, wrong answers, bigotism
sapfans GD
Ad by Viiiiiic