cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic ALV columns in Web Dynpro ABAP

Former Member
0 Kudos

Hello masters:

Does anybody know how to build an ALV with dynamic columns in a WD4A?

I know how to make an ALV with a dynamic context node (dynamic DDIC structure), but it isn't the problem. First, I need to validate data entries, and then I will know how many fields I have to show.

I've been reading about interface IF_WD_CONTEXT_NODE_INFO. I think some of its methods can be useful to me. Can you help me to solve that?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Rodrigo,

There are two ways for it:

1) Creating an attribute dynamically under the Staticly defined node.

2) Creating a new node dynamically with your desired columns in it.

I am explaining the second process, Here it as follows:

1. Create a WDC, and use the component SALV_WD_TABLE.

2. Create a node in the context to store the defined strucutre name.

3. Read the node and set the structure name to that node from which you want to get the columns.

4. Use this structure name and create a new node dynamically.

5. Set the data to this dynamically created node.

6. Set this context node to ALV.

Here is the sample code:

  • To get the strcutre from where you want to fecth the fields.

tabname_node->get_attribute( Exporting name = 'TABLENAME'

Importing value = tablename ).

translate tablename to upper case.

*create sub node named TEST1 of structure (tablename)

cl_wd_dynamic_tool=>create_nodeinfo_from_struct(

parent_info = rootnode_info

node_name = tablename

structure_name = tablename

is_multiple = abap_true ).

DATA: stru_tab type ref to data.

field-symbols: <tab> type table.*Create Internal Table

create data stru_tab type table of (tablename).

assign stru_tab->* to <tab>.*Get table content

select * from (tablename) into corresponding fields of table <tab>.*get instance of new node

dyn_node = wd_context->get_child_node( name = tablename ).*Bind Internal table to context node.

dyn_node->bind_table( <tab> ).*instantiate alv component

data: l_ref_cmp_usage type ref to if_wd_component_usage.l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).

if l_ref_cmp_usage->has_active_component( ) is initial.

l_ref_cmp_usage->create_component( ).

endif.*pass context node to alv

data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .

l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).

l_ref_interfacecontroller->set_data( dyn_node ).

Hope it helps..

Good day!

Regards,

Shashikanth. D

Answers (3)

Answers (3)

Former Member
0 Kudos

Problem solved. Thank you masters for your suggestions.

Edited by: Rodrigo Arenas Arriola on Jan 8, 2009 2:07 AM

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Here is a link to a tutorial on SCN that shows how to create SE16 in WDA. It has some very dynamic processing in it:

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/bf20e84f-0901-0010-fe9e-91d10001...

Here is also a vidoe that shows some of the same techniques:

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/media/uuid/de7d34e7-0b01-0010-31ab-91cdc27dce...

Former Member
0 Kudos

Hi ,

Why dont you have a look into the saptechnical.com.. You can find the step by step procedure with screen shots in tutorial column for this concept.It will be very helpful for you to understand.

Regards,

Sana.