‎2008 Mar 10 8:59 AM
hi all,
hope all r doing fine?
anyway i have a query which is mentioned below:-
select field1,.....fieldn
from <dbtable1>
into corresponding fields of table itab
where <condition>.
select field1,...fieldn
from <dbtable2>
appending corresponding fields of table itab
where <condition>.
the above two select stmts retrieve same set of fields from two different database tables into same internal table itab..
now my question is ...........is any other way to change 2nd select statement without using appending correspondin fields
but the functionality should remain the same as it is after changing..................
bcos appending corresponding is causing performance problem in data retrieval.
thanx alot in advance.
for sure points will be given for all the helpful answers
Jack
‎2008 Mar 10 9:27 AM
Hi,
You can use like that:
select field1,.....fieldn
from <dbtable1>
into corresponding fields of table itab1
where <condition>.
select field1,...fieldn
from <dbtable2>
appending corresponding fields of table itab2
where <condition>.
now u use:
loop at itab2 into w_itab2.
read table itab1 into w_itab1 with key w_itab1-<primary field> = w_itab2-<Primary field>.
if sy-subrc = 0.
append w_final into i_final.
else continue.
endif.
endloop.
*i_final table having all data ( i.e itab2 & itab1 data)
‎2008 Mar 10 9:04 AM
Hi,
You can First Select all the Data into the Internal Table,
and then you can have the Loop..EndLoop Statement
inside that you can place the read table statement and append the data to the Internal table.
HTH
Regards,
Dhruv Shah
‎2008 Mar 10 9:10 AM
Hi ,
First point don't use
INTO CORRESPONDING FIELDS OF TABLE ITAB.
Use INTO TABLE ITAB when your extracting fields and internal table fields are same.
2.
select field1,.....fieldn
from <dbtable1>
into table itab1
where <condition>.
select field1,...fieldn
from <dbtable2>
INTO table itab2
where <condition>.
LOOP AT ITAB2.
MOVE LINES OF TABLE ITAB2 TO ITAB1.
APPEND ITAB1
CLEAR ITAB1.
ENDLOOP.
FREE ITAB2.
‎2008 Mar 10 9:27 AM
Hi,
You can use like that:
select field1,.....fieldn
from <dbtable1>
into corresponding fields of table itab1
where <condition>.
select field1,...fieldn
from <dbtable2>
appending corresponding fields of table itab2
where <condition>.
now u use:
loop at itab2 into w_itab2.
read table itab1 into w_itab1 with key w_itab1-<primary field> = w_itab2-<Primary field>.
if sy-subrc = 0.
append w_final into i_final.
else continue.
endif.
endloop.
*i_final table having all data ( i.e itab2 & itab1 data)
‎2008 Mar 10 9:38 AM
Don't use 'into corresponding fields' ..
select field1,.....fieldn
from <dbtable1>
into table itab
where <condition>.
select field1,...fieldn
from <dbtable2>
into table itab1
where <condition>.
loop at itab1.
itab = itab1. <-- since both itab and itab1 have the same structure
append itab.
clear itab.
endloop.
‎2008 Mar 11 11:37 AM
Hi,
1. Avoid using 'into corresponding fields of'. Instead declare internal table in the same order as that of database selection.
2. After first select query move it to an temporary internal table and do the second select query. If u need all data (from 2 select queries) in the same internal table, append it later.
Reward if helpful.
Regards,
Ramya