cancel
Showing results for 
Search instead for 
Did you mean: 

context node does not contain any elements

Former Member
0 Kudos

Hi Masters,

I create a node dynamically from structure using CL_WD_DEMO_DYN_MODEL->create_nodeinfo_from_struct method. my code as

nd_field_info = nd_field->get_node_info( ).

wd_this->zwd_assist->create_nodeinfo_from_struct( EXPORTING

parent_info = nd_field_info

structure_name = dotablename

is_multiple = abap_true ).

When am set the data to context then it gives the error like node does not contain any elements, but i verified the attributes using nodeinfo then all attributes will be displayed, but when value inserting time it throws error.

Waiting for Your Response...

Advance Thankyou

Regards,

Sathya

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi sathya ,

the method you using is absolute , the replacement for the methos is if_wd_context_node_info->add_new_child_node

pls refer the sample code to create a dynamic Node .

DATA: pa0001  TYPE REF TO cl_abap_structdescr,
           comp_tab     TYPE cl_abap_structdescr=>component_table,
           struct_type     TYPE REF TO cl_abap_structdescr,

          ls_pa0001   ?= cl_abap_typedescr=>describe_by_name('P0001').
          comp_tab      = p0001->get_components( ).
          struct_type   = cl_abap_structdescr=>create( comp_tab ).

  struct_type = cl_abap_structdescr=>create( comp_tab ).

* now the nodeinfo is created
  node_info = wd_context->get_node_info( ).
  node_info = node_info->add_new_child_node(
    name                         = 'MY_NODE'
    IS_MANDATORY                 = ABAP_true
    IS_MULTIPLE                  = ABAP_true
    STATIC_ELEMENT_RTTI          = struct_type
    IS_STATIC                    = ABAP_false
       ).

refer DEMODYNAMIC component for dynamic creation of node

regards

Chinnaiya P

Edited by: chinnaiya pandiyan on Dec 15, 2010 2:07 PM

Former Member
0 Kudos

Hi

Thanqu for response in short time.As your code my problem is solved. Can u explain following code.


 ls_pa0001   ?= cl_abap_typedescr=>describe_by_name('P0001').
 comp_tab      = p0001->get_components( ).
 struct_type   = cl_abap_structdescr=>create( comp_tab ).

Former Member
0 Kudos

Hi sathya ,

pls look into the below sdn wiki link . you can get better understanding what the runtime time type service class do

[http://wiki.sdn.sap.com/wiki/display/ABAP/RuntimeTypeServices%28RTTS%29|http://wiki.sdn.sap.com/wiki/display/ABAP/RuntimeTypeServices%28RTTS%29]

there are lot of post regarding thin in SDN

Regards

Chinnaiya P

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

it seems to be the issue of the cardinality. Your node is having attributes but the cardinality might me set to 0:n or 0:1 by default that's why node does not have any element Please make it 1:1 or 1:n as per your requirement.

You need to set IS_MANDATORY = ABAP_TRUE

now if is multiple is true, cardinality is 1:n and if is multiple is false then cardinality is 1:1