on 06-14-2012 11:12 PM
Hello experts
I'm working with nodes with have nested nodes because i have a header-detail tables.
When I try to fill the father table node with the internal table wich has the subtable, it fills the node but does not fills the nested node:
lo_nd_header->bind_table( lt_header ) " Does not fill the nested table nodes
So i need to fill the header node and then make a cycle to fill the subnode for each header record, something like this:
lo_nd_header->bind_table( lt_header )
LOOP AT lt_header INTO ls_header
lo_nd_detail = lo_nd_header->get_child_node( name = 'DETAIL' index = sy-tabix )
lo_nd_detail->bind_table( ls_header-detail ) " ls_header-detail is a table
ENDLOOP
My doubt is if there is a way to fill a node including its nested table nodes in one step without need to make a cycle.
I guess is not possible because how can we get the child node if there is not created yet the corresponding header node record; but i'm trying to check it because if we have a 3 levels nested tables i think then we need to have nested LOOPs , something like this:
lo_nd_header->bind_table( lt_header )
LOOP AT lt_header INTO ls_header
lo_nd_detail = lo_nd_header->get_child_node( name = 'DETAIL' index = sy-tabix )
lo_nd_detail->bind_table( ls_header-detail )
LOOP AT ls_header-detail INTO ls_detail
lo_nd_subdetail = lo_nd_detail->get_child_node( name = 'SUBDETAIL' index = sy-tabix )
lo_nd_subdetail->bind_table( ls_detail-subdetail )
ENDLOOP
ENDLOOP
Regards
Frank
Hi Frank,
The approach you are following is correct, and (unfortunately) the only way. The reason for it is the very thing you stated: a child (sub node) cannot be created, when the parent (node) is not present.
There is a minor variant to this approach, though, wherein you can follow a create_element-bind_element iteration. But here too, you can't escape the nested loops.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Chengalarayulu, i got the variance in the code you provided by using lo_el_header and lo_el_detail.
Thanks Abhijeet, i got we need to use nested LOOPs ; could you explain please that variant with create_element-bind_element iteration ?
I'm trying to explore these codes because in fact i'm going to use 4 level nested nodes so i will need to use 3 nested LOOPs.
Best Regards
Frank
Hi Frank,
The variant is simple. Follow these steps:
The idea is, loop less. This way, you will append the entire record just once, as against the existing procedure, where you bind once and then rebind a part in step. As I said, the variant is minor and more of performance improvement rather than process improvement.
Frank,
try with the below snippet. still the problem exists, just use the direct types for sub nodes( ls_header-detail & ls_detail-subdetail) and try.
LOOP AT lt_header INTO ls_header.
lo_el_header = lo_nd_header->get_element( index = sy-tabix ).
lo_nd_detail = lo_el_header->get_child_node( name = 'DETAIL' ).
lo_nd_detail->bind_table( new_items = ls_header-detail set_initial_elements = abap_true ).
LOOP AT ls_header-detail INTO ls_detail
lo_el_detail = lo_nd_detail->get_element( index = sy-tabix ).
lo_nd_subdetail = lo_el_detail->get_child_node( name = 'SUBDETAIL' ).
lo_nd_subdetail->bind_table( new_items = ls_detail-subdetail
set_initial_elements = abap_true ).
ENDLOOP
ENDLOOP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.