2009 Mar 10 2:44 PM
hi
i am creating my alv report using method cl_salv_table =>factory.
i want to color the report lines in red
how can i do that??
i only found how to color a column
thanks
2009 Mar 10 3:13 PM
Hi,
Check the below code:
TYPE-POOLS: icon, col.
type for internal table
TYPES: BEGIN OF t_marc.
INCLUDE STRUCTURE marc.
internal table for cell color information
TYPES : it_colors TYPE lvc_t_scol,
END OF t_marc.
DATA: it_marc TYPE TABLE OF t_marc.
DATA: wa_marc LIKE LINE OF it_marc.
DATA: wa_colors LIKE LINE OF wa_marc-it_colors.
DATA: gr_alv TYPE REF TO cl_salv_table.
DATA: lr_columns TYPE REF TO cl_salv_columns_table.
SELECT-OPTIONS: s_mat FOR wa_marc-matnr MEMORY ID car.
START-OF-SELECTION.
retrieve data into internal table
SELECT * FROM marc
INTO CORRESPONDING FIELDS OF TABLE it_marc
WHERE matnr IN s_mat.
LOOP AT it_marc INTO wa_marc.
IF wa_marc-werks = '1000'.
CLEAR wa_colors.
wa_colors-fname = 'WERKS'.
wa_colors-color-col = col_negative.
wa_colors-color-int = 1.
APPEND wa_colors TO wa_marc-it_colors.
ENDIF.
MODIFY it_marc FROM wa_marc TRANSPORTING it_colors.
ENDLOOP.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = it_marc.
lr_columns = gr_alv->get_columns( ).
lr_columns->set_color_column( value = 'IT_COLORS' ).
display ALV
gr_alv->display( ).
(OR)
check this link
http://www.sapfans.com/forums/viewtopic.php?t=52107
Regards,
Shalini
Edited by: shalini reddy on Mar 10, 2009 4:13 PM
2009 Mar 10 2:51 PM
2009 Mar 10 2:52 PM
Hi,
add a color(4) field to your internal table. in the layout give your layout structure color parameter as below.
gs_layout-info_fieldname = 'COLOR'.
at user command just give a value to the color field of your internal table like gt_main-color = 'C510'.
this should work.
regards,
Murat Kaya
2009 Mar 10 3:13 PM
Hi,
Check the below code:
TYPE-POOLS: icon, col.
type for internal table
TYPES: BEGIN OF t_marc.
INCLUDE STRUCTURE marc.
internal table for cell color information
TYPES : it_colors TYPE lvc_t_scol,
END OF t_marc.
DATA: it_marc TYPE TABLE OF t_marc.
DATA: wa_marc LIKE LINE OF it_marc.
DATA: wa_colors LIKE LINE OF wa_marc-it_colors.
DATA: gr_alv TYPE REF TO cl_salv_table.
DATA: lr_columns TYPE REF TO cl_salv_columns_table.
SELECT-OPTIONS: s_mat FOR wa_marc-matnr MEMORY ID car.
START-OF-SELECTION.
retrieve data into internal table
SELECT * FROM marc
INTO CORRESPONDING FIELDS OF TABLE it_marc
WHERE matnr IN s_mat.
LOOP AT it_marc INTO wa_marc.
IF wa_marc-werks = '1000'.
CLEAR wa_colors.
wa_colors-fname = 'WERKS'.
wa_colors-color-col = col_negative.
wa_colors-color-int = 1.
APPEND wa_colors TO wa_marc-it_colors.
ENDIF.
MODIFY it_marc FROM wa_marc TRANSPORTING it_colors.
ENDLOOP.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = it_marc.
lr_columns = gr_alv->get_columns( ).
lr_columns->set_color_column( value = 'IT_COLORS' ).
display ALV
gr_alv->display( ).
(OR)
check this link
http://www.sapfans.com/forums/viewtopic.php?t=52107
Regards,
Shalini
Edited by: shalini reddy on Mar 10, 2009 4:13 PM