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: 

END SELECT

Former Member
0 Kudos

Hi,

when after SELECT clause ENDSELECT is used?

1 ACCEPTED SOLUTION

former_member189059
Active Contributor
0 Kudos

ENDSELECT is used when the selection involves more than one row and the output is into a single structure

eg:

select * from mara into corresponding fields of mara_wa.

append mara_wa to it_mara.

endselect.

cases where endselect is not used would be where you enter data directly into the table such as

select * from mara into corresponding fields of <b>table</b> it_mara.

or selecting a single record

select <b>single </b>* from mara into corresponding fields of mara_wa.

or selecting a count

select count(*) from mara into i_number.

6 REPLIES 6

former_member189059
Active Contributor
0 Kudos

ENDSELECT is used when the selection involves more than one row and the output is into a single structure

eg:

select * from mara into corresponding fields of mara_wa.

append mara_wa to it_mara.

endselect.

cases where endselect is not used would be where you enter data directly into the table such as

select * from mara into corresponding fields of <b>table</b> it_mara.

or selecting a single record

select <b>single </b>* from mara into corresponding fields of mara_wa.

or selecting a count

select count(*) from mara into i_number.

Former Member
0 Kudos

HI,

in case of 1)select single ..... 2)select.......into [corresponding-fields of] table itab.

we should not use endselect.

in all other cases we have to use endselect.

rgds,

bharat.

Former Member
0 Kudos

Hi Debarshi..

If you are using select statement you need to use either one of the following statement..

1. select..... into tablename

0r

2. select.... endselect

Thanks

Gowrishankar

Former Member
0 Kudos

hi,

endselect statements has to be used when u write select statements for retieving data from database.but if u use a syntax like below

select lifnr land1 name1 ort01 sortl from lfa1

UP TO 50 ROWS into corresponding FIELDS OF TABLE itab.

there is no need of using endselect.

ie..if u use select single * or select * from <table> into table <itab>

there is no need of using endselect.otherwise u have to use it.

Prajith

Former Member
0 Kudos

Hi,

A SELECT command for which the INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE itab is inserted into an internal table, must be followed by ENDSELECT .

Or

For all other SELECT commands, ENDSELECT must be used unless a single line above the addition SINGLE is read after SELECT and unless the columns of the result set are statically specified and contain only aggregate functions without the specification of the addition GROUP BY.

Regards,

Himanshu

Former Member
0 Kudos

hi

ENDSELECT.

Effect

The ENDSELECT statement closes a loop started with SELECT.

A SELECT command for which the INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE itab is inserted into an internal table, must be followed by ENDSELECT if the addition PACKAGE SIZE is used.

For all other SELECT commands, ENDSELECT must be used unless a single line above the addition SINGLE is read after SELECT and unless the columns of the result set are statically specified and contain only aggregate functions without the specification of the addition GROUP BY.

regards

dinesh