‎2006 Nov 22 8:29 AM
Hi,
I have one query in select statement.
Suppose I have to select only LAND1 field from LFA1 table.
Anybody will suggest me what I have to do?
Is it fine
select land1 from lfa1 into gs_lfa1 where lifnr in s_lifnr.
or select single land1 from lfa1 into gs_lfa1 where lifnr in s_lifnr.
plz tell me the difference also.
‎2006 Nov 22 8:30 AM
select lifnr land1 from lfa1 into table gt_lfa1 where lifnr in s_lifnr.u r using select option for lifnr .it means requirment is u ahve put more than one vendor also..collect all the land1 according to given lifnr into a internal table.
and when ever u need used read statment to fetch it.
kishan negi
‎2006 Nov 22 8:31 AM
select single is the best one. if u a riffering only on lifnr,
if you use select option ... use select land1 form lfa1 into table it_land1 where lifnr in s_lifnr.
Message was edited by:
Naresh Reddy
‎2006 Nov 22 8:32 AM
Hi Salil,
If you want to select only one record then select single is the better option.
select single land1 from lfa1 into gs_lfa1 where lifnr in s_lifnr.
‎2006 Nov 22 8:33 AM
select land1 from lfa1 into gs_lfa1 where lifnr in s_lifnr.
--Since you specify ranges in your WHERE condition. The SELECT query may return one or more records. Hence you must either specify INTO TABLE or use ENDSELECT.
select single land1 from lfa1 into gs_lfa1 where lifnr in s_lifnr.
--This will return the first record in the selection condition into the variable gs_lfa1.
Refer ABAP Wiki for more info.
Regards
Wenceslaus
‎2006 Nov 22 8:34 AM
Salil,
from ur both selcts you are going to get only a single land1.
in ur where condition, u r selecting on select-option so it can contain many records..
so declare IT and get values into IT..
SELECT lifnr
name1
FROM lfa1
INTO table it_lifnr
WHERE lifnr in s_lifnr.
Message was edited by:
Anupama Reddy
‎2006 Nov 22 8:38 AM
hi,
select land1 from lfa1 into gs_lfa1 where lifnr in s_lifnr.
this statement retrieves multiple records from lfa1 depending on the range u entereed in s_lifnr,
select single land1 from lfa1 into gs_lfa1 where lifnr in s_lifnr.
this statement selects the first record from the database satisfying the selection criteria.
hope this helps,
keerthi
‎2006 Nov 22 9:09 AM
Hi,
while debugging i found that it will not picking the record for my selection.
but if i use into corresponding fields in my select query it will work. Is it fine for performance point of view??
suppose i have parameter option.
select land1 from lfa1 into corresponding fields of gs_lfa1 where lifnr in p_lifnr.
is it fine??
if any alternative is available then plz let me know.
‎2006 Nov 22 9:39 AM
Avoid using INTO CORRESPONDING...
What is the type of gs_lfa1
If you are using parameters:
PARAMETERS p_lifnr LIKE lfa1-lifnr.
DATA g_land LIKE <b>lfa1-land1</b>.
SELECT SINGLE land1 FROM lfa1 INTO g_land WHERE lifnr EQ p_lifnr.Regards
Wenceslaus