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

Former Member
0 Likes
1,157

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.

8 REPLIES 8
Read only

Former Member
0 Likes
991
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

Read only

Former Member
0 Likes
991

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

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
991

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.

Read only

Former Member
0 Likes
991

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

Read only

Former Member
0 Likes
991

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

Read only

Former Member
0 Likes
991

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

Read only

Former Member
0 Likes
991

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.

Read only

0 Likes
991

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