Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

passing values from one table to another

<Has nothing to do with ABAP Objects - moved to ABAP General. Please choose your forums more carefully in future>

Hi Experts,

I am using three tables in my program. From two table single field from each I need to pass into third table but before inserting the field values in third table i need to check if its present no need to insert else I need to insert. Even the two tables are not related at all. I used bellow code but I think its not efficient.. So plz any body help me and taking performance into an account.

select lifnr from tab1 into table it_tab1.

loop at it_tab1.

select zlifnr from tab3 into table it_tab3 where zlifnr = it_tab1-lifnr.

if sy-subrc = 0.

continue.

else.

tab3-zlifnr = tab1-lifnr.

insert tab3.

endif.

endloop.

select distinct sri from tab2 into table it_tab2.

loop at it_tab1.

select zsri from tab3 into table it_tab3 where zsri = it_tab2-sri.

if sy-subrc = 0.

continue.

else.

tab3-zsri = tab2-sri.

insert tab3.

endif.

endloop.

Is there any chance to combine both statements or quiry into one . plz help me.

Thanks

Basu

Edited by: Mike Pokraka on Sep 5, 2008 12:16 PM

Tags:

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question