2008 Jun 25 2:36 PM
hi
i am creating an alv report using factory method, i want to color every line (row ) in the report which contains "E" in the coloumn 'TYPE' in RED
how do i do that ?
i am trying to do it for the last 2 days without any help.
Thanx Ami.
2008 Jun 25 2:41 PM
apply the given tips in bold....yesterday I have given this...
2008 Jun 25 3:04 PM
Hello,
I'm not sure what the factory method is, but if you're using a function module you need to set a fieldcat that points the column to the col_pos eg:
w_fieldcat-col_pos = 1.
w_fieldcat-fieldname = 'COL'.
append w_fieldcat to t_fieldcat.
I won't give you any more pointers incase this has nothing to do with the alv function module.
Kind regards
Ash Thomas
Sap Consultants
2008 Jun 25 3:10 PM
Hi,
Declare the final internal table which you want to display with clrtab TYPE slis_t_specialcol_alv.
Manipulate the final internal table and when the column TYPE is filled with 'E' then modify the above structure with
REFRESH gk_final_new-clrtab.
gk_color-color-col = 6.
gk_color-color-int = 1.
gk_color-color-inv = 0.
gk_color-nokeycol = gc_x. "Also paint key columns
APPEND gk_color TO gk_final_new-clrtab.
CLEAR gk_color.
<REMOVED BY MODERATOR>
Thanx
Sumanth
Edited by: Alvaro Tejada Galindo on Jun 25, 2008 3:48 PM
2008 Jun 25 4:33 PM
try this code
REPORT ZAMIT_TEST2.
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: so_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 so_mat.
LOOP AT it_marc INTO wa_marc.
IF wa_marc-werks = '1060'.
CLEAR wa_colors.
wa_colors-fname = ''.
wa_colors-color-col = col_positive.
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( ).
Hope this will work....
<REMOVED BY MODERATOR>
Edited by: Amitava De on Jun 25, 2008 9:04 PM
Edited by: Alvaro Tejada Galindo on Jun 25, 2008 3:48 PM
2008 Jun 25 8:56 PM
Hi,
REPORT ZWA_ALV_COLORS .
tables : BKPF.
types : begin of ty_BKPF,
belnr like BKPF-belnr,
bukrs like BKPF-bukrs,
counter(4) type n,
color_line(4) type c, " Line color
color_cell type lvc_t_scol, " Cell color
end of ty_BKPF.
* Structures
data : wa_BKPF type ty_BKPF,
wa_fieldcat type lvc_s_fcat,
is_layout type lvc_s_layo,
wa_color type lvc_s_scol.
* Internal table
data : it_BKPF type standard table of ty_BKPF,
it_fieldcat type standard table of lvc_s_fcat,
it_color type table of lvc_s_scol.
* Variables
data : okcode like sy-ucomm,
w_alv_grid type ref to cl_gui_alv_grid,
w_docking_container type ref to cl_gui_docking_container.
parameters : p_column as checkbox DEFAULT 'X',
p_line as checkbox DEFAULT 'X',
p_cell as checkbox DEFAULT 'X'.
at selection-screen output.
perform get_data.
perform fill_catalog.
if w_docking_container is initial.
perform create_objects.
endif.
*&--------------------------------------------------------------*
*& Form create_objects
*&--------------------------------------------------------------*
form create_objects.
create object w_docking_container
exporting
ratio = 40
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
create object w_alv_grid
exporting
i_parent = w_docking_container.
* Field that identify color line in internal table
move 'COLOR_LINE' to is_layout-info_fname.
* Field that identify cell color in inetrnal table
move 'COLOR_CELL' to is_layout-ctab_fname.
call method w_alv_grid->set_table_for_first_display
exporting
is_layout = is_layout
changing
it_outtab = it_BKPF
it_fieldcatalog = it_fieldcat
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
endform.
*&--------------------------------------------------------------*
*& Form get_data
*&--------------------------------------------------------------*
form get_data.
"Check this code for colour
select * from BKPF up to 50 rows.
clear : wa_BKPF-color_line, wa_BKPF-color_cell.
move-corresponding BKPF to wa_BKPF.
add 1 to wa_BKPF-counter.
if wa_BKPF-COUNTER = '2' AND p_line = 'X'.
* Color line
move 'C610' to wa_BKPF-color_line.
elseif wa_BKPF-counter = '0004'
and p_cell = 'X'.
* Color cell
move 'BELNR' to wa_color-fname.
move '1' to wa_color-color-col.
move '1' to wa_color-color-int.
move '1' to wa_color-color-inv.
append wa_color to it_color.
wa_BKPF-color_cell[] = it_color[].
endif.
append wa_BKPF to it_BKPF.
endselect.
endform.
*&--------------------------------------------------------------*
*& Form fill_catalog
*&--------------------------------------------------------------*
form fill_catalog.
*****************************************************************
* Colour code : *
* Colour is a 4-char field where : *
* - 1st char = C (color property) *
* - 2nd char = color code (from 0 to 7) *
* 0 = background color *
* 1 = blue *
* 2 = gray *
* 3 = yellow *
* 4 = blue/gray *
* 5 = green *
* 6 = red *
* 7 = orange *
* - 3rd char = intensified (0=off, 1=on) *
* - 4th char = inverse display (0=off, 1=on) *
* *
* Colour overwriting priority : *
* 1. Line *
* 2. Cell *
* 3. Column *
*****************************************************************
data : w_position type i value '1'.
"In field catalog filling coulour
clear wa_fieldcat.
move w_position to wa_fieldcat-col_pos.
move 'BELNR' to wa_fieldcat-fieldname.
move 'BKPF' to wa_fieldcat-ref_table.
move 'BELNR' to wa_fieldcat-ref_field.
append wa_fieldcat to it_fieldcat.
add 1 to w_position.
clear wa_fieldcat.
move w_position to wa_fieldcat-col_pos.
move 'BUKRS' to wa_fieldcat-fieldname.
move 'BKPF' to wa_fieldcat-ref_table.
move 'BUKRS' to wa_fieldcat-ref_field.
* Color column
if p_column = 'X'.
move 'C510' to wa_fieldcat-emphasize.
endif.
append wa_fieldcat to it_fieldcat.
add 1 to w_position.
clear wa_fieldcat.
move w_position to wa_fieldcat-col_pos.
move 'COUNTER' to wa_fieldcat-fieldname.
move 'N' to wa_fieldcat-inttype.
move '4' to wa_fieldcat-intlen.
move 'Counter' to wa_fieldcat-coltext.
append wa_fieldcat to it_fieldcat.
add 1 to w_position.
* clear wa_fieldcat.
* move w_position to wa_fieldcat-col_pos.
* move 'FREE_TEXT' to wa_fieldcat-fieldname.
* move 'C' to wa_fieldcat-inttype.
* move '20' to wa_fieldcat-intlen.
* move 'Text' to wa_fieldcat-coltext.
* append wa_fieldcat to it_fieldcat.
ENDFORM.
Thanks
Vikranth