cancel
Showing results for 
Search instead for 
Did you mean: 

Data in Dynamic columns of an ALV

anand_nidamanuru
Active Participant
0 Kudos

Hello All,

We have a requirement where we have to generate dynamic columns at run time based on user input.

However the columns are supposed to be added to a node that already is bound to a static structure.

So we added dynamic attributes to the node based on user input and we are using SET_DATA of ALV WD interface controller to bind the node to the DATA context of ALV.

But we are facing with the below issue.

1) The dynamic columns are generated properly. We are able to delete and create new dynamic columns and manipulate

2) The data in the node is added by calling BIND_TABLE method of NODE. The Table data that is passed is created by using RTTI with the components of both Static and dynamic columns.

3) But the data inside these dynamic columns is not visible in ALV output. All the dynamic columns have empty data

4) We checked the node data (Node->Mappee->elements collection->dynamic attributes), for the dynamic columns and the data is intact.

So we are not sure why the data is not being displayed in ALV.

Is this an issue with ALV, if the node has bound to a static structure and it has dynamic columns?

Or is there some method/option that I have to use?

Thanks,

Anand

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

This is a documented limitation of the ALV. It does not support Dynamic Attributes. From the online help:

Context Nodes

The ALV component requires a context node that can contain the data of the internal data table. This context node has the following properties:

● It has the cardinality 0..n.

● It only contains attributes and no subnodes: For each column of your internal data table, you create exactly one attribute of the same name and data type.

● All the attributes are static, not dynamic.

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/42/b9ea094f4a3118e10000000a1553f7/frameset.htm

Instead of using dynamic attributes, consider instead dynmically generating the entire context node. Using the RTTS you can build a dynamic type that is a combination of all the fields you need. You can then use this dynamic data type as the source of the context and all the attributes will be consider static.

data static_element_rtti type ref to CL_ABAP_STRUCTDESCR.
****Fill you RTTI however you like

*   Create dynamic sub node of with dynamic structure
    dyn_node_info = rootnode_info->add_new_child_node(
          name                         = l_name    " Web Dynpro: Name of Context Node
         static_element_rtti          = static_element_rtti  ).   " Runtime Type Services

anand_nidamanuru
Active Participant
0 Kudos

Thanks a lot Jung.

I tried to debug a bit of standard code for ALV and this is the conclusion I came to, but as this seem to work with Dynamic columns of Table UI element (in another application of ours), I was doubtful and not sure.

Many thanks for the reply.

I guess we dont have any other option apart from creating the entire node dynamically.

However we have to make change in a productive system which has this node bound to a static structure. So making this change is very difficult and high risk. Also already of users are live with the different ALV View layouts. We are not sure if this will affect the existing View Layouts. Can you please let me know if this will affect existing view layouts?

Below is the change that we are thinking of

1) Delete the existing node that is bound to static structure

2) Create this node dynamically (at the same level in the node hierarchy with the same name) with the RTTI type that include components from both static and dynamic fields.

Please let us know in this case if the View layouts that were based on previous static columns will still be applicable or they are lost.

Thanks,

Anand

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I've never tried to make such a design change after the application already had layouts. You would have to test to see what kind of impact the change will have on them in your system. Try and keep the node name and as many of the attribute names the same as possible. ALV Layouts are pretty flexible and adapt to changes pretty well under normal circumstances.