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 at is giving problem

Former Member
0 Likes
740

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.

6 REPLIES 6
Read only

Former Member
0 Likes
722

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.

Read only

Former Member
0 Likes
722

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

Read only

former_member404244
Active Contributor
0 Likes
722

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

Read only

Former Member
0 Likes
722

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.

Read only

Former Member
0 Likes
722

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

Read only

Former Member
0 Likes
722

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'.