Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic ALV + deep structure

Former Member
0 Kudos

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?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

3 REPLIES 3

Former Member
0 Kudos

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

0 Kudos

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?

Former Member
0 Kudos

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