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

Select query doubt ?

Former Member
0 Likes
480

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.

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
451

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

Read only

0 Likes
451

Tushar - this is why it's a bad idea to post the same question twice. You should close this or the other thread.

Rob

Read only

Former Member
0 Likes
451

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.

Read only

Former Member
0 Likes
451

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,