11-29-2007 9:54 AM
Hi Experts,
I have a requirement to use dynamic ALV with the color table.
The number of ALV columns depend on the Time Horizon selected
i.e 10Days will display 10 columns or 14Days will display 14 columns
How do you dynamically create an internal table with a deep structure?
The deep structure is required because I need the color table in the field catalog to color individual cells of the ALV!
Any ideas how to do this?
11-29-2007 11:52 AM
Well we might need some more explanation as to what you are trying to do... however the "color" table occurs once per row but can contain settings for several (all) columns in that row... and as for varying the number of columns, can we assume there is a maximum number you might need for your "horizon"..? If so, just define this max number in your ALV structure then just hide the ones you don't need before you display the ALV report.
Jonathan
11-29-2007 11:52 AM
Well we might need some more explanation as to what you are trying to do... however the "color" table occurs once per row but can contain settings for several (all) columns in that row... and as for varying the number of columns, can we assume there is a maximum number you might need for your "horizon"..? If so, just define this max number in your ALV structure then just hide the ones you don't need before you display the ALV report.
Jonathan
11-30-2007 8:20 AM
Hi Jonathan,
I am aware of the suggestion but I wonder if it is possible to create dynamic deep structures in abap.
When I define a dynamic work area of TYPE ANY and assign an internal table to one of it's columns the program short dumps with error type h cannot be assigned to type c.
Is there any other way?
11-29-2007 11:59 AM
Add a component COLOR_TYPE type LVC_T_SCOL to your structure.
data: it_color type type table of lvc_s_scol.
data: wa_color type lvc_s_scol.
if condition.
set color to green
move '5' to wa_color-color-col.
move '0' to wa_color-color-int.
move '0' to wa_color-color-inv.
or set to yellow
move '3' to wa_color-color-col.
move '1' to wa_color-color-int.
move '0' to wa_color-color-inv.
or set to red
move '6' to wa_color-color-col.
move '0' to wa_color-color-int.
move '0' to wa_color-color-inv.
append wa_color to it_color.
wa_alv_data-color_cell[] = it_color[].
clear wa_color.
endif