2006 Oct 23 12:56 PM
How to code for this requirement.
In OO ALV, My final internal table has color_line field.
I need to color a two particuler row in the output.
I am using this logic, but it doesnt work.
LOOP AT GT_BPSTAB INTO WA_BPSTAB.
clear LV_COUNTER.
CASE LV_COUNTER.
WHEN '12 '.
*IF LV_COUNTER = 12.
*FORMAT COLOR COL_KEY INTENSIFIED ON.
WA_BPSTAB-COLOR_LINE = 'C610'.
MODIFY GT_BPSTAB FROM WA_BPSTAB.
**MOVE WA_BPSTAB TO GT_BPSTAB.
*ENDIF.
WHEN '13'.
*IF LV_COUNTER = 13.
*FORMAT COLOR COL_KEY INTENSIFIED ON.
WA_BPSTAB-COLOR_LINE = 'C910'.
MODIFY GT_BPSTAB FROM WA_BPSTAB .
*ENDIF.
ENDCASE.
ENDLOOP.
MOVE 'COLOR_LINE' TO LS_LAYOUT-INFO_FNAME.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'gt_STRUCT'
I_SAVE = X_SAVE
I_DEFAULT = LV_DEF
IS_LAYOUT = LS_LAYOUT
CHANGING
IT_OUTTAB = GT_BPSTAB[]
IT_FIELDCATALOG = GT_FIELDCATALOG[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4
.
2006 Oct 23 1:33 PM
Jonathan,
to colorize ALV, do as follows:
Include a field of type
SLIS_T_SPECIALCOL_ALV
uin your display table.
set the name of this field to parameter LAYOUT-coltab_fieldname
Use this form to colorize fields. If Field name is left space, the whole row will be colored:
<pre>
&----
*& Form alv_color
&----
set field color - last wins
----
form alv_color using pv_fieldname type fieldname
pv_color type c
pv_intensify type i
pv_inverse type i
changing pt_colors type slis_t_specialcol_alv."#EC CALLED
field-symbols:
<color> type line of slis_t_specialcol_alv.
data:
ls_colors type line of slis_t_specialcol_alv.
read table pt_colors assigning <color> with key
fieldname = pv_fieldname
binary search.
if sy-subrc = 0.
<color>-color-col = pv_color.
<color>-color-int = pv_intensify.
<color>-color-inv = pv_inverse.
else.
ls_colors-fieldname = pv_fieldname.
ls_colors-color-col = pv_color.
ls_colors-color-int = pv_intensify.
ls_colors-color-inv = pv_inverse.
insert ls_colors into pt_colors index sy-tabix.
endif." sy-subrc = 0.
endform. "alv_color
</pre>
Hope this helps - let me know.
Regards,
Clemens
2006 Oct 23 1:40 PM
Hello,
in your coding:
> LOOP AT GT_BPSTAB INTO WA_BPSTAB.
> clear LV_COUNTER.
> CASE LV_COUNTER.
> WHEN '12 '.
...
you do a clear on lv_counter and then you do a case on this lv_counter. But lv_counter is initial after a clear!?
So the case-structure will not work!
Hope this helps,
Michael