Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Create element in node

Hi experts,

I need to create new dynamic element in exist node.

This is my coding:

DATA lo_nd_conti_display_table TYPE REF TO if_wd_context_node.

DATA lo_el_table TYPE REF TO if_wd_context_element.

lo_nd_conti_display_table = wd_context->get_child_node( name = wd_this->wdctx_item_basic_data ).

lo_el_table = lo_nd_conti_display_table->get_element( ).

lo_el_table = lo_nd_conti_display_table->create_element( ).

lo_el_table->set_attribute( name = 'ZZ_PROD_TEXT' value = '1' ).

But I have dump at last expression

UNCAUGHT_EXCEPTION

Could not find attribute ZZ_PROD_TEXT

Method: IF_WD_CONTEXT_NODE_INFO~GET_ATTRIBUTE of program CL_WDR_CONTEXT_NODE_INFO======CP

Method: IF_WD_CONTEXT_ELEMENT~SET_ATTRIBUTE of program CL_WDR_CONTEXT_ELEMENT========CP

Method: PST4LVVUE6CIE3YCDWZCWO0T62P3 of program /1BCWDY/PH5AZ8WQT1P84GS6R3OK==CP

Method: IF_WDR_VIEW_DELEGATE~WD_DO_MODIFY_VIEW of program /1BCWDY/PH5AZ8WQT1P84GS6R3OK==CP

Method: DO_MODIFY_VIEW of program CL_WDR_DELEGATING_VIEW========CP

Method: MODIFY_VIEW of program CL_WDR_VIEW===================CP

Method: DO_MODIFY_VIEW of program CL_WDR_CLIENT_COMPONENT=======CP

Method: DO_MODIFY_VIEW of program CL_WDR_CLIENT_COMPONENT=======CP

Method: DO_MODIFY_VIEW of program CL_WDR_CLIENT_COMPONENT=======CP

Method: DO_MODIFY_VIEW of program CL_WDR_CLIENT_COMPONENT=======CP

Can you please help me?

BR

Evgeniy

Former Member
Former Member replied

In that case you coding is not correct.

lo_el_table->set_attribute( name = 'ZZ_PROD_TEXT' value = '1' ).

You need to get the node info and use add attribute method like below.

For Dynamically creating Attribute

DATA : 
     rootnode_info TYPE REF TO if_wd_context_node_info,
     dyn_node_info TYPE REF TO if_wd_context_node_info,
     dyn_node TYPE REF TO if_wd_context_node,
     dyn_attr_info TYPE wdr_context_attribute_info.

dyn_attr_info-name = 'ZZ_PROD_TEXT'. 
dyn_attr_info-DEFAULT_VALUE = '1'. 
dyn_attr_info-type_name = 'PROD_NAME' . Data Element(CHAR20) ( Type Of Attribute )

rootnode_info = wd_context->get_node_info( ).
CALL METHOD rootnode_info->add_attribute
EXPORTING
attribute_info = dyn_attr_info.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question