‎2007 Oct 18 8:12 AM
Hello experts.
my statement is like this.
sort itab_final by matnr.
sort it_out by matnr.
loop at itab_final.
loop at it_out where matnr = itab-final-matnr.
if sy-subrc eq 0.
-
-
endif.
endloop.
clear it_out.
endloop.
In it_out i am having 2 records ie 2 materials 110 and 120. in the first loop execution 110 is matnr. it is there in both the itab_final and it_out.
After executing this statement ,
loop at it_out where matnr = itab-final-matnr.
i am getting the record into the header for material 110. but the sy-subrc is showing value 4. in the next loop for material 120 , the sy-subrc is equal to zero. so please tell me why it so happening like this. How to correct this.
Thanks for all the replies.
‎2007 Oct 18 8:15 AM
What is the need of checking the sy-subrc inside the loop.
anyhow the control get inside the loop only if the record is present.
‎2007 Oct 18 8:17 AM
C loop inside inside a loop is a big NO
Better try doin dis...
sort itab_final by matnr.
sort it_out by matnr.
loop at itab_final.
<b>read table it_out with key matnr = itab-final-matnr.</b>if sy-subrc eq 0.
-
-
endif.
endloop.
clear it_out.
endloop.
This will solve ur query..
Reward points if it does
Regards
‎2007 Oct 18 8:19 AM
Hi,
Instead of going for nested loop why don't u use read statement.
loop at itab_final.
Read table it_out with key matnr = itab-final-matnr.
if sy-subrc eq 0.
-
-
endif.
clear : it_out,
itab_final.
endloop.
Reward if helpful.
Regards,
Nagaraj
‎2007 Oct 18 8:19 AM
hi,
put like this..
loop at it_out
loop at it_final where matnr = it_out-matnr.
if sy-subrc eq 0.
.....
....
clear it_final.
endloop
clear it_out.
Endloop.
‎2007 Oct 18 8:20 AM
Hi,
I too faced similar problem.Remove the statement:
if sy-subrc eq 0.
endif.
It will work.
Hope this helps.
Reward if helpful.
Regards,
Sipra
‎2007 Oct 18 8:20 AM
Hi,
Use read statement
sort itab_final by matnr.
sort it_out by matnr.
loop at itab_final.
read table it_out with key matnr = itab-final-matnr.
if sy-subrc eq 0.
-
-
endif.
clear it_out.
endloop.
Thanks!
Brunda
'Reward if useful'.