cancel
Showing results for 
Search instead for 
Did you mean: 

Adding the atttributes to a node at runtime

former_member282968
Contributor
0 Kudos

I want to display an alv report for which the structure is binded with the node.

Now i have a requirement where i have to add some fields to that node dynamically in different scenarios. Please let me know how to about it.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Along the same lines as Chris said, you can have a look at demo WD component DEMODYNAMIC present in package SWDP_DEMO. In this component assistance class you will find the code for dynamic adding attributes to a node.

Answers (1)

Answers (1)

ChrisPaine
Active Contributor
0 Kudos

First check if you can get away with just hiding/making visible some fields. This is much easier to do and also easier to understand when it comes to supporting your development.

Otherwise, I believe you will have dynamically create the entire node - using the IF_WD_CONTEXT_NODE_INFO method ADD_ATTRIBUTE results in dynamic attributes, which I think the ALV does not process.

Thomas Jung has once (at least) discussed how to do this:

You need to generate an RTTI Structure type using the cl_abap_structdescr=>create. You have to build up the internal table parameter p_components (type CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE) for the individual components of the structure.

So far none of this is really WDA specific. Just normal RTTS stuff to build a dynamic data object.

You cna then use the node info method ADD_NEW_CHILD_NODE. Use the static_element_rtti parameter to pass in the dynamic structure definition you just created.

former_member282968
Contributor
0 Kudos

Thanks Chris for the suggestion