‎2006 Mar 24 9:07 AM
Hello friends,
Just woundring if someone advise me something better
Actually I have a loop and inside a loop I am seleting something ( one field ). So I am using following:
Loop at lt_lfa1 into ts_lfa1.
SELECT lifnr FROM lfb1
INTO lv_lifnr
WHERE lifnr EQ ts_lfa1-lifnr
AND ....
.
Endloop.
Okey, as I am not selecting result in a table instead a field, i get error, that I have to provide endselect statement ( which I dont want ( due to performance reason). so the only solution I know is to use statement :
INTO CORRESPONDING FIELDS OF TABLE bla bla.. ( to avoid select endselect stuff). but as I am selecting only 1 field its also not convinient that I create a new internal table, ... so do any one here knows, how to not use select-endselect while selecting only one field ?
Many thanks
‎2006 Mar 24 9:10 AM
use SELECT SINGLE
SELECT SINGLE lifnr FROM lfb1
INTO lv_lifnr
WHERE lifnr EQ ts_lfa1-lifnr
AND ....Message was edited by: Sekhar
‎2006 Mar 24 9:10 AM
Hi shah,
U can use
Loop at lt_lfa1 into ts_lfa1.
Select single lifnr FROM lfb1
INTO lv_lifnr
WHERE lifnr EQ ts_lfa1-lifnr
AND ....
Endloop.
thanks,
priya
‎2006 Mar 24 9:12 AM
hi shah,
Use <b>Select Single</b> Statement or Select * from dbtable in to table itab2 <b>for all entries</b> of itab..
Regards,
Santosh
‎2006 Mar 24 9:15 AM
thx for your replies:
Oh that was much simple, actually I am new to ABAP world , well point awared on the basis of first come, first serve!
Many thanks again
‎2006 Mar 24 9:11 AM
Hello ,
The following code should work correctly.
DATA LT_LIFNR TYPE LIFNR OCCURS 0 WITH HEADER LINE.
SELECT LIFNR
FROM LFB1
INTO TABLE LT_LIFNR
FOR ALL ENTRIES IN LT_LFA1 WHERE LIFNR = LT_LFA1-LIFNR.
LOOP AT LT_LIFNR.
WRITE : / LT_LIFNR.
ENDLOOP.Please do let me nkow if it worked. You just need to assign the points to this answer....:-)
‎2006 Mar 24 9:19 AM
Hi Shah,
Actually I have a loop and inside a loop I am seleting something ( one field ). So I am using following:
I would suggest if you could avoid using a Select inside a loop due to performance reason. I would suggest you to make use of read statement using Binary search inside a loop.
<b>Again scenario dependendent.</b>
Suggestion steps:
1) Select the record into an internal table before loop , say itab using Array fetch.
2) Sort ur itab
3) Use Loop at lt_lfa1 into ts_lfa1.
4) In that loop used read statement along with binary search .
Using the above steps you can get read of inface Select and Endselect also.
Other wise
you can use select single inside the loop to avoid endselect , if ur reqmt. is like that only
Let me know if that helps or still if u have any doubts.
Cheers
Sunny
Rewrd points, if found helpful
‎2006 Mar 24 9:34 AM
Hello sunny,
thx for ur input, humm..intresting senario, which you have provide, will later give it a try, and will let you know, at the moment, have to move on to my current problem
regards/
‎2006 Mar 27 7:40 AM
Hi,
Using a select statement inside a loop reduces the performance and increases the run time and the frequency of Database access .
Try this code .
select lifnr into table lt_lfb1
from lfb1
where key element is not null.
Loop at lt_lfa1 into ts_lfa1.
read table lt_lfb1 into ts_lfb1 with key lifnr eq ts_lfa1-lifnr
if sy-subrc ne 0.
clear ts_lfb1 .
endif.
endloop.
‎2006 Mar 27 3:02 PM