Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Loop through header and item internal table

Former Member
0 Likes
2,488

Hi,

My scenario will be like this, i have two internal tables which is populated based on certain conditions, now i have to call one bapi to update values that am going to store values in a tree structure say for eg mat01 is header and mat02 and mat03 are item values.

What is the efficient method to call that bapi one time for header creation and consequte times for item creation respectively.

shall i have to loop thro two internal tables i.e header and item?

suggestions are welcomed from the experts...

Thanks in advance...

Regards,

Babu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,304

HI,

Ensure that you have some relation between header and item..

sort it_vbap by vbeln.

loop at it_vbap.

at new vbeln.

read table it_vbak with key vbeln = it_vbap-vbeln.

endif.

at end of vbeln.

call bapi..

endat.

endloop.

Thanks

mahesh

Hi,

My scenario will be like this, i have two internal tables which is populated based on certain conditions, now i have to call one bapi to update values that am going to store values in a tree structure say for eg mat01 is header and mat02 and mat03 are item values.

What is the efficient method to call that bapi one time for header creation and consequte times for item creation respectively.

shall i have to loop thro two internal tables i.e header and item?

suggestions are welcomed from the experts...

Thanks in advance...

Regards,

Babu

3 REPLIES 3
Read only

Former Member
0 Likes
1,304

u need to loop first through header item and internally loop through the item level data which would be a efficient way of posting data into SAP.

Read only

Former Member
0 Likes
1,305

HI,

Ensure that you have some relation between header and item..

sort it_vbap by vbeln.

loop at it_vbap.

at new vbeln.

read table it_vbak with key vbeln = it_vbap-vbeln.

endif.

at end of vbeln.

call bapi..

endat.

endloop.

Thanks

mahesh

Read only

Former Member
0 Likes
1,304

Hi Babu

you can do something like that.


loop it_header.
*Call bapi to create header
  loop it_item where field_key = it_header-field_key.
*  Call bapi to create item   
  endloop.
endloop.

The important part is the where sentence in the second loop.

Regards

David N.