‎2008 May 27 7:51 AM
is there anything wrong with this code
clear wa_bseg.
loop at t_final into wa_final.
loop at t_bseg1 into wa_bseg where belnr = wa_final-belnr
and gjahr = wa_final-gjahr.
*and zfbdt = wa_final-zfbdt.
if sy-subrc eq 0 .
wa_final1 = wa_final.
append wa_final1 to t_final1.
clear wa_final1.
endif.
clear wa_bseg.
endloop.
*clear wa_final.
endloop.
‎2008 May 27 7:53 AM
check this..
no need of if sy-subrc in side loop
clear wa_bseg.
loop at t_final into wa_final.
loop at t_bseg1 into wa_bseg where belnr = wa_final-belnr
and gjahr = wa_final-gjahr.
wa_final1 = wa_final.
append wa_final1 to t_final1.
clear wa_final1.
clear wa_bseg.
endloop.
clear wa_final.
endloop.
‎2008 May 27 7:57 AM
Hi ,
There is nothing wrong with the code but your code inside the second loop will get executed for no. of rows in outer internal table multiplied by no. of rows in inner internal table .
If you want to restrict means want to execute the inner loop code only once for each row .
Use exit in the inner loop .
‎2008 May 27 7:57 AM
hi
i think there is no problem with this code , just check weather sy-subrc value getting updated properly , depending based on internal loop.
but if data in both internal tables will be more then it's execution time will increase significantly.
‎2008 May 27 7:57 AM
hi,
if you have duplicate entries of belnr and gjahr in the internal table t_final, then there is a possibilty of appending the same data into t_final1. otherwise the code is perfectly fine. as Vijay rightly said, sy-subrc is not needed in loop. if u doign a read then it is required.
‎2008 May 27 7:57 AM
Hi,
I dont know your requirement, but after looking at the code, it looks like you want to find all the wa_final for which there is any entry in t_bseg1 table.
First of all the check of sy-subrc is not required.
If there exists 2 records in t_bseg1 which satisfies the above condition, the wa_final would be appended twice. This can be avoided by using "EXIT" stmt inside the inner loop.
Hope this helps you.
~ Ramanath.
‎2008 May 27 7:57 AM
hi
i think there is no problem with this code , just check weather sy-subrc value getting updated properly , depending based on internal loop.
but if data in both internal tables will be more then it's execution time will increase significantly.
‎2008 May 27 8:00 AM
U need to sort for the fields inside the
loop where ur putting where inserting further more for program performance .
‎2008 May 27 8:05 AM
Hi,
Instead of using loop within loop , use read statement within loop it will improve program performance.
try this below logic..
clear wa_bseg.
loop at t_final into wa_final.
read table t_bseg1 into wa_bseg with key belnr = wa_final-belnr
gjahr = wa_final-gjahr.
if sy-subrc eq 0 .
wa_final1 = wa_final.
append wa_final1 to t_final1.
endif.
clear: wa_bseg, wa_final1,wa_final.
endloop.
Regards,
N M Poojari.
Edited by: Nilambari Poojari on May 27, 2008 9:06 AM
‎2008 May 27 2:17 PM
A READ on a standard table won't significantly improve performance without the BINARY SEARCH addition.
Rob
‎2008 May 27 2:23 PM
You need to use the parallel cursor technique. SE30 has hints and tips. The code you are looking for is this.
I = 1.
LOOP AT ITAB1 INTO WA1.
LOOP AT ITAB2 INTO WA2 FROM I.
IF WA2-K <> WA1-K.
I = SY-TABIX.
EXIT.
ENDIF.
" ...
ENDLOOP.
ENDLOOP.
‎2008 May 27 2:30 PM
Hi,
1. I think there is one thing wrong according to me.
2. you are looping at the itab t_final
and inside the loop itself,
you are appending to the same internal table.
3. Instead you should take another internal table,
and move the field values
and append the records.
regards,
amit m.
‎2008 May 27 2:30 PM
Hi,
There is nothing wrong in your code, but rather using nested loop you can do as below :
loop at t_final into wa_final.
read t_bseg1 with key where belnr = wa_final-belnr
gjahr = wa_final-gjahr.
if sy-subrc eq 0 .
wa_final1 = wa_final.
append wa_final1 to t_final1.
clear : wa_final,
wa_final1.
endif.
endloop.
Thanks,
Sriram Ponna.