cancel
Showing results for 
Search instead for 
Did you mean: 

reading attribute values from a dynamically created node

Former Member
0 Kudos

hi experts,

i have created a node CHECKBOX with no attributes in it. i did not add any attributes. in wdmodify method, i have used add_attribute() method of if_wd_context_node_info to add attributes. all the attributes are of type string. the number of attributes changes each time based on some logic

now i need to read the values of the attributes in another method using code wizard. code wizard generated the below code

DATA lo_nd_checkbox TYPE REF TO if_wd_context_node.

DATA lo_el_checkbox TYPE REF TO if_wd_context_element.

DATA ls_checkbox TYPE wd_this->element_checkbox.

  • navigate from <CONTEXT> to <CHECKBOX> via lead selection

lo_nd_checkbox = wd_context->get_child_node( name = wd_this->wdctx_checkbox ).

  • get element via lead selection

lo_el_checkbox = lo_nd_checkbox->get_element( ).

  • get all declared attributes

lo_el_checkbox->get_static_attributes(

IMPORTING

static_attributes = ls_checkbox ).

this is giving me a synntax error saying "Type "ELEMENT_CHECKBOX" is unknown". the error is coming because attributes are created dynamically. how do i access the values of the attributes ?

thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Sorry, forgot to paste the link in last message.

[url]http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/80a3de18-ee00-2d10-bfb3-946d7e00fd91[url]

Thanks & Regards,

Mz

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Get the structure of your dynamic node by using the below code-

DATA lr_struct TYPE REF TO cl_abap_structdescr.

lr_struct = lo_nd_info->get_static_attributes_type( ).

CREATE DATA ls_data TYPE HANDLE lr_struct.

ASSIGN ls_data->* TO <fs_line>.

CREATE DATA lt_data LIKE TABLE OF <fs_line>.

ASSIGN lt_data->* TO <fs_itab>.

then use get_static_attributes_node method to retrieve the data from the dynamic node.

You can also refer to my article on dynamic context below-

http://www.divulgesap.com/blog.php?p=MTIx

Regards,

Lak

Former Member
0 Kudos

Hi Sudhakar,

You may check this article of mine

Cheers

Mz

Former Member
0 Kudos

Is your method in which you are reading attributes is called somewhere else except after that piece of code in domodifyview in whih you are creating attributes, if not then it will not work as domodifyview is the last method to be called in event processing.

You have to read from your attributes in same domodifyview method after you are creating the attributes.

personally, creating dynamic attributes, nodes, UI elements is not a clean way of coding and especially in domodifyview as it is called everytime you do something, if dynamic nature is required try to place your code somewhere else.

Regards

Manas Dua