cancel
Showing results for 
Search instead for 
Did you mean: 

Create element in node

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Does this node item_basic_data has the attribute ZZ_PROD_TEXT ?

Former Member
0 Kudos

Hi Baskaran,

Node item_basic_data doesn't has the attribute ZZ_PROD_TEXT . but I want to create it dinamically.

BR

Evgeniy

Former Member
0 Kudos

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.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

try using that code in the WDDOMODIFYVIEW method of the view in which you want to create the nodes dynamically.

Also if you want that node to be created/inserted into the view when it is displayed for the first time during runtime you can

insert the appropriate code into the WDDOINIT method of that view.

Edited by: Adithya K Ramesh on May 23, 2011 10:43 AM

Former Member
0 Kudos

Evgeniy

Is ths attribute already defined on the node?

I think not.

First you will have to define the all the attributes you need

Then you create a new element

regards

yuval

former_member184578
Active Contributor
0 Kudos

Hi.,

This is not the right way to create element dynamically.,

Check this wiki ., [Create UI elements Dynamically in WDA|http://wiki.sdn.sap.com/wiki/display/WDABAP/CreatingUIElementsDynamicallyinAbapWebdynpro+Application]

hope this helps u.,

Thanks & Regards

Kiran

Former Member
0 Kudos

Hi,

it is very helpful link, but there is node with static structure and I need to change structure of the node dinamically

BR

Evgeniy