Application Development 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: 

select

Former Member
0 Kudos

hi to all

how to write an select statement without an into class

can we write like this

select single land1 from kna1

where kunnr = kna1-kunnr.

thanks in advance.

kiran

7 REPLIES 7

Former Member
0 Kudos

Hi,

you can write.

Thank you,

Ramu N.

abdul_hakim
Active Contributor
0 Kudos

hi

use the below code.

<b>tables kna1.

parameters p_kunnr like kna1-kunnr.

select single * from kna1 where kunnr = p_kunnr.</b>

Cheers,

Abdul Hakim

Mark all useful answers...

venkata_ramisetti
Active Contributor
0 Kudos

Hi,

It is possible to write a SELECT without INTO clause.

1) If you want to fecth single record...

SELECT * FROM KAN1 WHERE KUNNR = KNA1-KUNNR.

X_KNA1-KUNNR = KNA1-KUNNR.

X_KNA1-NAME1 = KNA1-NAME1.

2) If you want to fecth multiple records...

SELECT * FROM KNA1 WHERE KUNNR IN S_KUNNR. "(S_KUNNR is select option)

ITAB-KUNNR = KNA1-KUNNR.

ITAB-NAME1 = KNA1-NAME1.

APPEND ITAN. CLEAR ITAB.

ENDSELECT.

Thanks,

Ramakrishna

Former Member
0 Kudos

You can't write:


select single land1 from kna1
  where kunnr = kna1-kunnr.

But you can write either:


TABLES: kna1.

select single * from kna1
  where kunnr = kna1-kunnr.

or:


tables: kna1.
data:   country like kna1-land1.

select single land1 from kna1
  into country
  where kunnr = kna1-kunnr.

Rob

0 Kudos

hi friend ,

i m beginer in abap and want to write my first program with select statement . if possible ,please guide me.

Clemenss
Active Contributor
0 Kudos

Hi Kiran,

when selecting anything, you want a result. This result is passed to the field given with INTO. If you don't write INTO, you have an implicit INTO. Examples are already given with TABLES statement:

SELECT * FROM KNA1

is interpreted as SELECT {all field names of KNA1} INTO KNA1 FROM KNA1.

SELECT COUNT( * ) FROM KNA1 WHERE ...

will put the number of records matching the WHERE clause into system field SY_DBCNT.

It is just the simplified way of writing ommitting the implicit INTO SY-DBCNT clause.

Conclusion:

You can not write

select single land1 from kna1

where kunnr = kna1-kunnr.

even if you have a structure field with the name KNA1. This field can be defined with the (outdated) TABLES: KNA1 statement because the field land1 is different from the (implicit) target areas KNA1.

Regards,

Clemens

Regards,

Clemens

former_member201264
Active Contributor
0 Kudos

hi

I agree all above, and know that if we use " * from" , then it will crate buffer and store the selected data in the buffer tempararily.

regards

sreeni