Skip to Content
0
Former Member
Oct 29, 2009 at 10:28 AM

Access Subnode

19 Views

Hi

I have create a Node TP which has a sub node general with an attribute BU_GROUP.

Plus on the layout I have created a fields of type Drop down by Key and is binded with the field BU_GROUP.

Now I have to set value to this field. I have added the following code, but its restrns with an error message of TAXPAYER.TP.GENERAL Node not found while running.

Code is TYPES : BEGIN OF sty_grp,

bu_group TYPE tb001-bu_group,

END OF sty_grp.

DATA: git_data TYPE STANDARD TABLE OF sty_grp,

gwa_data LIKE LINE OF git_data.

DATA lo_node_info TYPE REF TO if_wd_context_node_info.

DATA value1 TYPE wdy_key_value.

DATA set TYPE wdy_key_value_table.

DATA lo_nd_general TYPE REF TO if_wd_context_node.

DATA lo_el_general TYPE REF TO if_wd_context_element.

DATA ls_general TYPE wd_this->Element_general.

DATA lv_bu_group TYPE wd_this->Element_general-bu_group.

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

lo_nd_general = wd_context->path_get_node( path = `TP.GENERAL` ).

  • @TODO handle non existant child

  • IF lo_nd_general IS INITIAL.

  • ENDIF.

  • get element via lead selection

lo_el_general = lo_nd_general->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_general IS INITIAL.

ENDIF.

  • get single attribute

lo_el_general->get_attribute(

EXPORTING

name = `BU_GROUP`

IMPORTING

value = lv_bu_group ).

SELECT bu_group FROM tb001 INto TABLE git_data.

LOOP AT git_data INTO gwa_data.

move gwa_data-bu_group to value1-key.

move gwa_data-bu_group to value1-value.

APPEND value1 to set.

endloop.

lo_nd_general = wd_context->get_child_node( name = 'TP.GENERAL' ).

lo_node_info = lo_nd_general->get_node_info( ).

lo_node_info->SET_ATTRIBUTE_VALUE_SET( name = 'BU_GROUP' value_set = set ).

Please help

Rgrds

Shakti