‎2005 Sep 28 5:56 PM
Hi,
I am using the following select statement inside the loop. But I asked to replace the select statement using Read instead of select. How can I write the following query using read ?
SELECT SINGLE CRHD~ARBPL
FROM AFKO
INNER JOIN V_QAPO ON V_QAPOAUFPL = AFKOAUFPL
INNER JOIN CRHD ON CRHDOBJID = V_QAPOARBID
INTO XARBPL
WHERE AFKO~AUFNR = CAUFVD_TAB-AUFNR
AND V_QAPO~VORNR = IAFVC-VORNR.
Points will be surely awarded.
Thanks,
Tushar.
‎2005 Sep 28 9:08 PM
READ is used for reading lines of an internal table, not a database. I'm a little confused why you are being told to "read" the database using the "READ" statement. You are selecting a SINGLE record, there for you will not be filling an internal table when retrieving from the database, therefore there is no need to READ the internal table. Can you give some more details?
Regards,
Rich Heilman
‎2005 Sep 28 9:16 PM
Tushar - this is why it's a bad idea to post the same question twice. You should close this or the other thread.
Rob
‎2005 Sep 28 9:22 PM
from what i understand..
select data into internal tables first.
and inside the loop , instead of hitting database for every loop pass just read the internal table with a key equal to any field of the int. table u r looping at.
this increases performance...
for example.
instead of :
loop at itab1.
select single * from mara into mara where matnr = itab1-matnr.
endloop.
do:
if not itab1[] is initial.
select * from mara into table itab2
for all entries in itab1
where matnr = itab1-matnr.
endif.
loop at itab1.
read table itab2 with key matnr = itab1-matnr.
**process
endloop.
‎2005 Sep 28 9:38 PM
Tushar,
This is a duplicate posting. Please close one of them.
I am not sure how big are the tables. I am presuming that if the internal table is too large then the select even with single will be a performance killer.
In that case it is better to take out that select statment inside the loop and keep that out, then read that internal table inside the loop.
As per my knowledge, if the internal table is large, a select single is also an expensive statement in side a loop.
Thanks,