cancel
Showing results for 
Search instead for 
Did you mean: 

looping through context node elements

Former Member
0 Kudos
629

Hi All,

I am new to webdynpro abap and have a query regarding:

How to loop through the context node elements, so that i can modify each element attributes during runtime.

Please send some link or sample code which shows how to do this.

Thanks & regards,

Sujit

Accepted Solutions (1)

Accepted Solutions (1)

Pramanan
Active Participant
0 Kudos

Dear Sujit,

Consider a node Advances having any number of context attributes.Below is the code sinippet to access the node.

data lo_nd_advances type ref to if_wd_context_node. <declaration for the node>

data lo_el_advances type ref to if_wd_context_element.<declaration for the elements in the node>

data lt_advances type wd_this->elements_advances. <internal table declaration - for internal table put elements>

data ls_advances type wd_this->element_advances. <work area declaration - for work area put element>

<Assign the context node Advances to lo_nd_advances>

lo_nd_advances = wd_context->get_child_node( name = wd_this->wdctx_advances ).

Assign context attributes of context node advances to lo_el_advances

lo_el_advances = lo_nd_advances->get_element( ).

import the Advance node values to the internal table lt_advances

call method lo_nd_advances->get_static_attributes_table(

importing

table = lt_advances ).

loop the internal table

loop at lt_advances into ls_advances.

<statements>

endloop.

Note: i have bolded the difference between internal table and work area in the declaration.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

toread the element attributes,you should read the node and this can be done through code wizard.

Regards,

anand

Former Member
0 Kudos

Hi...the below code snippet should help me

DATA : l_node TYPE REF TO if_wd_context_node,

lt_flight type if_view1=>elements_flights_node,

L_NODE = wd_context->get_child_node( 'FLIGHTS_NODE' ).

l_node->get_static_attributes_table( IMPORTING TABLE = LT_FLIGHT ).

now you can loop through lt_flight as u normally do.

good luck !

arjun_thakur
Active Contributor
0 Kudos

Hi Sujit,

You can read any node with the help of code wizard. It will give you all the values in an internal table. You can use them accordingly. To get code wizard: just press CTRL+F7 in any of your method, a pop up window will appear, just check the radio button which says read node, press f4, and select the node and press enter, the code will be automatically generated and you'll get all the values.

I hope it helps.

Regards

Arjun

Former Member
0 Kudos

hi

there is no difference from ABAP as such ..