cancel
Showing results for 
Search instead for 
Did you mean: 

Fetching rows recursively.

Former Member
0 Kudos

Hi all,

I want to fetch the complete rows or elements of a table whose data is populated recursively.

I have wriiting the following code

lo_nd_cn_output_data = wd_context->get_child_node( name = wd_this->wdctx_cn_output_data ).

  lo_nd_cn_output_data->get_static_attributes_table( IMPORTING table = lt_cn_output_data ).

the context is as follows:

CN_OUTPUT_DATA

RN_OUTPUT_DATA

here RN_OUTPUT_DATA is the recursive node haning repeated node as CN_OUTPUT_DATA.

I am getting only the data at the CN_OUTPUT_DATA level.

Please help me in fetching the data under the recursive node.

Thanks and Regards,

Shilpa Dhawan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello shilpa,

retrieving elements of recursive node will be similar to retrieving the elements of any child node except that you should check if it is a leaf or not. I assume you have an attribute isLeaf to check if the node is a leaf or not. and you want to put all the elements in an internal table.

Create a method to fetch the elements of the recursive node recursively and add them to the internal table in the following way:

accept an import parameter of type IF_WD_CONTEXT_ELEMENT and have an internal table of elements as export paramter.

in the method implementation, check if that element is leaf by checking the value of isLeaf attribute

if its leaf, you can exit from the method. Otherwise, if its not leaf, get the node reference of RN_OUTPUT_DATA using get_child_node() and get all the elements of this child node using get_elements() and add it to an internal table and loop through the elements and call this same method passing the element reference. add the output of this call to the internal table.

In a different method, first get all elements of the node CN_OUTPUT_DATA using get_elements() method and all those to an internal table

Then loop through those elements and in each loop, pass the element reference to the above method and append the internal table returned to this internal table. Thus you will have all the elements.

I know explaining in words might not be clear to you. But i cant give the code right now. If the above mentioned procedure is not clear, let me know. I will try to give code snippet.

Hope this helps!

Regards,

Srilatha