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

read table

Former Member
0 Likes
565

I have the following query

loop at int_tab1 into wa_tab1

read table tab2 with key tab2-field1 = wa_tab1-field2

Now for the record fetched above I want to do the following

move tab2-field2 to tab3-field3.

        • How can I capture the record from read statement

endloop

6 REPLIES 6
Read only

Former Member
0 Likes
540

loop at int_tab1 into wa_tab1

read table tab2 with key tab2-field1 = wa_tab1-field2.

if sy-subrc = 0.

tab3-field3 = tab2-field2.

<....>

append tab3.

endif.

endloop

Read only

Former Member
0 Likes
540

loop at int_tab1 into wa_tab1.

read table tab2 with key tab2-field1 = wa_tab1-field2

if sy-subrc = 0.

write tab2-field2 to tab3-field3.

*or ... tab3-field3 = tab2-field2.

append tab3.

endif.

endloop.

Read only

Former Member
0 Likes
540

hi check this..

loop at int_tab1 into wa_tab1 .

read table tab2 with key field1 = wa_tab1-field2

tab3-field3 = itab2-field1.

append itab3.

endloop

regards,

venkat

Read only

Former Member
0 Likes
540

HI,

do this way ..


loop at int_tab1 into wa_tab1
   read table tab2 with key tab2-field1 = wa_tab1-field2.
   if sy-subrc = 0.
      move tab2-field2 to tab3-field3.
      append tab3.
      clear tab3.
  endif.
endloop 

Read only

anub
Participant
0 Likes
540

Hi,

If your output requirement is such that you can fill the output table even though tab2-field2 is empty then you can proceed as given below.

loop at int_tab1 into wa_tab1

read table tab2 with key tab2-field1 = wa_tab1-field2

if sy-subrc = 0.

tab3-field3 = tab2-field2.

endif.

append tab3.

clear tab2.

endloop.

if the requirement is such that you need to proceed further only if tab2-field2 is filled then you can proceed as given below

loop at int_tab1 into wa_tab1

read table tab2 with key tab2-field1 = wa_tab1-field2

if sy-subrc = 0.

tab3-field3 = tab2-field2.

append tab3.

clear tab2.

endif.

clear tab2.

endloop.

Reward if useful.

Regards,

Anu.

Read only

Former Member
0 Likes
540

Hi,

loop at int_tab1 into wa_tab1

read table tab2 with key tab2-field1 = wa_tab1-field2.

if sy-subrc = 0.

tab3-field3 = tab2-field2.

<....>

append tab3.

endif.

endloop

Reward points