cancel
Showing results for 
Search instead for 
Did you mean: 

Getting a dynamically created NODE

Former Member
0 Kudos

Hi,

I have been reading all the posts related to dynamic WebDynpro to develop a client solution.

I have a problem where I am unable to make a dynamically created table editable. After help from colleagues, it turns out that everything is ok, I just need to populate the table with an initial line. In order to do this I need to bind the table. In order to bind the table I need a reference of its dynamically created NODE.

I see solutions here on SCN, but all of them assume that the dynamically created NODE can be referenced. When I try to obtain mine, it is empty/doesn't exist, although the corresponding NODE_INFO does exist.

I have a statically declared node to store dynamic tables in at runtime.

It is represented by l_ref_dynamic_tab_node/l_ref_dynamic_tab_node_info.

Here is how my code looks, I am certain I am doing something incorrectly:

*-- parent nodes/node_info

  l_ref_parent_node_info          = l_ref_comp_context->get_node_info( ).                                     "get parent node

  l_ref_dynamic_tab_node_info = l_ref_parent_node_info->get_child_node( l_con_dynamic_tab ). "metadata for dynamic table node

  l_ref_dynamic_tab_node        = wd_context->get_child_node( l_con_dynamic_tab ).                   "dynamic table node

*-- add new child node to the DYNAMIC_TAB context node

             l_ref_dynamic_tab_node_info->add_new_child_node( name = l_sav_field_id

                 static_element_rtti = wd_assist->get_dynamic_table_struc( l_sav_table )

                         is_multiple = abap_true

                           is_static = abap_true ).   "used abap_false too, no difference


*-- get reference of NODE

              l_ref_dyn_tables_node = l_ref_dynamic_tab_node->get_child_node( l_sav_field_id ).  "this comes back empty

*-- bind the table

             l_ref_dyn_tables_node->bind_table( new_items = <fs_table_ref> ).

Any help with how to obtain a reference of the NODE is much appreciated!

Hamish

Accepted Solutions (1)

Accepted Solutions (1)

harsha_jalakam
Active Contributor
0 Kudos

Hi Hamish,

Just Try to give name of the dynamic node name as string. Probably you might have declared it as string and have given it no value.Just try giving it as string with value and can you please check.

  l_ref_dynamic_tab_node_info->add_new_child_node( name = 'l_sav_field_id'

                 static_element_rtti = wd_assist->get_dynamic_table_struc( l_sav_table )

                         is_multiple = abap_true

                           is_static = abap_true ).   "used abap_false too, no difference


*-- get reference of NODE

              l_ref_dyn_tables_node = l_ref_dynamic_tab_node->get_child_node( 'l_sav_field_id' ).


Regards,

Harsha 

Former Member
0 Kudos

Hi Harsha, thanks for the response. I just solved it with the help of a colleague by accessing it via the parent node's lead selection.

the code for anyone in the same boat as me:

*-- add new child node to the DYNAMIC_TAB context node

             l_ref_dynamic_tab_node_info->add_new_child_node( name = l_sav_field_id

                 static_element_rtti = wd_assist->get_dynamic_table_struc( l_sav_table )

                         is_multiple = abap_true

                           is_static = abap_false ).


*-- provide enough editable lines...

             DO 20 TIMES.

               APPEND INITIAL LINE TO <fs_table_ref> ASSIGNING <fs_struc_ref>.

               WHILE sy-subrc EQ 0.

                 ASSIGN COMPONENT sy-index OF STRUCTURE <fs_struc_ref> TO <fs_field_ref>.

                 IF <fs_field_ref> IS ASSIGNED.

                   <fs_field_ref> = ' '.

                 ENDIF.

               ENDWHILE.

             ENDDO.


*-- get instance of child table node/node_info

             l_ref_lead_selection ?= l_ref_dynamic_tab_node->get_lead_selection( ).

             l_ref_dyn_tables_node ?= l_ref_lead_selection->get_child_node( l_sav_field_id ).

             l_ref_dyn_tables_node_info = l_ref_dynamic_tab_node_info->get_child_node( l_sav_field_id ).

*-- bind the table

             IF NOT l_ref_dyn_tables_node IS INITIAL.

               l_ref_dyn_tables_node->bind_table( new_items = <fs_table_ref> ).

             ENDIF.

           ENDIF.

*-- get reference of the dynamic table's meta data

           l_ref_wd_table = cl_wd_table=>new_table( id = l_sav_field_id

                                      bind_data_source = l_sav_binding ) .


Answers (0)