Start of Content Area

Background documentation Reference Path to Deeper Context Nodes  Locate the document in its SAP Library structure

If you require access to a node that is a few levels below the root node in the context tree structure, there are two possibilities. The graphic below depicts the structure situation of the context again. The context node to process with the program is SubNode_21.

This graphic is explained in the accompanying text

 

1st Variant

You can repeat the process outlined in Direct Reference to a Context Node step by step until you 'reach' the required node.

 

 

method EXAMPLE .  

 

data: l_node                     type ref to IF_WD_CONTEXT_NODE,

      l_snode_11    type ref to IF_WD_CONTEXT_NODE,

      L_snode_21    type ref to IF_WD_CONTEXT_NODE.

 

 

l_node     = wd_context->get_child_node( wd_this->wdctx_node_1 ).

l_snode_11 = l_node->get_child_node( wd_this->wdctx_subnode_11 ).

l_snode_21 = l_snode_11->get_child_node( wd_this->wdctx_subnode_21 ).

. . . . . . . . .

 

endmethod.

   

 

2nd Variant

You can use the PATH_GET_NODE method to reference the required subnode.

 

 

method EXAMPLE .  

 

data:    l_snode_21    type ref to IF_WD_CONTEXT_NODE.

 

l_snode_21 = wd_context->path_get_node( 'NODE_1.SUBNODE_11.SUBNODE_21' ).

. . . . . . . . .

 

endmethod.

   

 

This formulation can be varied depending on which attribute in the method is already known at the time of the call of PATH_GET_NODE.

 

 

method EXAMPLE .  

 

data: l_node                     type ref to IF_WD_CONTEXT_NODE,

           l_snode_21    type ref to IF_WD_CONTEXT_NODE.

 

. . . . . . . . .

 

l_snode_21 = l_node->path_get_node( 'SUBNODE_11.SUBNODE_21' ).

. . . . . . . . .

 

endmethod.

   

 

Caution You cannot formulate the use of the PATH_GET_NODE using constants. You must make sure that you get the node name exactly right, since errors are not picked up by the syntax check.

 

 

End of Content Area