08-01-2012 7:50 AM
Hi All,
I am BW Consultant and i have written Functio Module extraction using the ABAP Code. Please find the below ABAP Code.
I am using Z table Z175 and BSEG table and moving the data to final internal table.
In Z175, Billing document field is there. It contains more than 1 data for a single billing document and
BSEG table will also have more than 1 data for a single billing document.
Using the Condition Z175-VBELN = BSEG-BELNR i am pulling the data for other fields such as GL Account, Group Account and other details.
I have written the code as loop inside the Loop. Because of this, it is affecting the performance.
Can you please help me on modifying the attached code.
Thanks.
Moderator Message: Search the internet with search terms viz., Parallel cursor for LOOPs, Nested loop optimisation using SORTED TABLEs. Personally i use the latter.
Message was edited by: Suhas Saha
08-01-2012 8:07 AM
Hi,
There is no use of us seeing your attached code, because as you have mentioned, you are usilng a custom table and we will not know the fields of the custom table.
Anyways a small advice, it is the developer who should judge for himself if a loop inside loop is really necessary, in many cases it is.
Wherever it is necessary, us it, if you think that is the best solution. One more thing that you can do is to use parallel cursor while using loop inside loop. Parallel cusrsor is a technique of looping through the inner loop as few times as possible.
loop at lt_outer into ls_outer.
lv_index = sy-tabix.
loop at lt_inner into ls_inner from lv_index.
endloop.
endloop.
it can also be achieved by a where clause.
loop at lt_outer into ls_outer.
loop at lt_inner into ls_inner
where field eq ls_outer-field.
loop.
loop.
Hope it helps you. Thank you.
Regards,
Kartik
08-01-2012 9:32 AM
Hi Jalina,
Kindly go through following link this will surly help you to improve your performance of nested loop.
http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+Code+for+Parallel+Cursor+-+Loop+Processing
Regards,
Pushkar.