cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic ALV - adding structure components at runtime to static structure

Former Member
0 Kudos

Hi,

I new to WD ABAP.....my requirement is as follows-

To bind to ALV, I am using abap structure but at runtime new fields need to be added to that structure and pass it to ALV.

I am using static Context node for ALV.

Please help me how to do this.

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ,

Try to create a dynamic internal table using RTTS functions. Then the data can be linked to the ALV using SET_DATA function from the ALV Interface controller.

Ranganathan.

Former Member
0 Kudos

Thanks for your quick response.

It would be great if you have sample code of how to to it.

Former Member
0 Kudos

Hi,

I don't have the full code for it.. But the logic for it is.

1. Use the class CL_ABAP_STRUCTDESCR=>CREATE( ) to create the dynamic structure. Need to pass the structure information to the method in type cl_abap_structdescr=>component_table.

2. Get the reference to the top node using wd_context->get_node_info( ).

3. Add a dynamic new child node to the root node using add_new_child_node( ) with the reference of the root node.

4. Get the reference of the of the child node using get_child_node( ).

5. Use the set_data method of the ALV Interface to set the data to the ALV.

Ranganathan.

Former Member
0 Kudos

I am getting following error - Note

The following error text was processed in the system CR1 : Access via 'NULL' object reference not possible.

The error occurred on the application server scrd0001_CR1_00 and in the work process 0 .

The termination type was: RABAX_STATE

The ABAP call stack was:

Method: IF_SALV_WD_COMP_TABLE_IF~SET_DATA of program CL_SALV_WD_C_TABLE============CP

Method: SET_DATA of program /1BCWDY/9O4XR05B41WQE8TOXIJ8==CP

Method: WDDOINIT of program /1BCWDY/9O4XR05B41WQE8TOXIJ8==CP

Method: IF_WDR_COMPONENT_DELEGATE~WD_DO_INIT of program /1BCWDY/9O4XR05B41WQE8TOXIJ8==CP

Method: DO_INIT of program CL_WDR_DELEGATING_COMPONENT===CP

Method: INIT_CONTROLLER of program CL_WDR_CONTROLLER=============CP

Method: INIT_CONTROLLER of program CL_WDR_COMPONENT==============CP

Method: INIT of program CL_WDR_CONTROLLER=============CP

Method: INIT of program CL_WDR_CLIENT_COMPONENT=======CP

Method: IF_WDR_COMPONENT_FACTORY~CREATE_COMPONENT of program CL_WDR_CLIENT_COMPONENT=======CP

Steps I am doing -

1. create the dynamic structure

2. Get the reference of the of the child node using get_child_node( ).

3. lr_node->bind_table( <table> )

4. Instantiate ALV component

5. lo_INTERFACECONTROLLER = wd_this->wd_cpifc_usage_alv( ).

lo_interfacecontroller->set_data( r_node_data = lr_node ).

Please help.