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: 

When to use SELECT and END SELECT in the query.

Former Member
0 Kudos

hi all,

When to use SELECT and END SELECT in the query.

regads,

Venkata Suresh Penke.

11 REPLIES 11

Former Member
0 Kudos

hi,

SELECT * FROM <TABLE> INTO <INT-TAB>

APPEND <INT-TAB>

ENDSELECT

vs.

SELECT * FROM <TABLE> INTO TABLE <INT-TAB>

It is usually faster to use the INTO TABLE version of a SELECT statement than to use APPEND statements

pleaseeward if useful.

0 Kudos

hi,

You can use SELECT INTO TABLE and avoid the SELECT...ENDSELECT.

Example:

SELECT * FROM <TABLE> INTO <INT-TAB>

APPEND <INT-TAB>

ENDSELECT

vs.

SELECT * FROM <TABLE> INTO TABLE <INT-TAB>

It is usually faster to use the INTO TABLE version of a SELECT statement than to use APPEND statements.

please reward if it is useful.

Former Member
0 Kudos

Hi,

It is very rare case.

Only when select upto rows is used at that time only

This is when you dont have all the primary keys in your condition

regards

SHiva

former_member235056
Active Contributor
0 Kudos

Dear friend,

select endselect is used only when u are required to select more than one record from one to other table,it basically defines loop.

pls reward points.

Regards,

Ameet

vijy_mukunthan
Active Contributor
0 Kudos

hi friend

if u use endselect it acts like a loop. Fetching of multiple records can be done by using the select and endselect statement. if ur using many records use select and endselect.

One important thing if ur using select-options u should not use endselect.

Rewards points if its helpful

Regards

vijay

Former Member
0 Kudos

Hi,

Use SELECT and END SELECT only when all the primary key in that table are unknown.

If you have all the primary keys, then use SELECT SINGLE.

Regards,

Zaheed

Former Member
0 Kudos

when it is nested select that time only you should use this SELECT...ENDSELECT .

Example :

*Select... endselect command

SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart

dmbtr mwart hwbas aufnr projk shkzg kokrs

FROM bseg

INTO wa_bseg.

APPEND wa_bseg TO it_bseg.

ENDSELECT.

Reward points if it is usefull ...

Girish

Former Member
0 Kudos

Hi

SELECT AND ENDSELECT will be used only when we have less number of record

it acts like an LOOP if there 1 lac records then the loop had to do for all the records then it will take much time

it will be used only when you have less number of data

SAP advises to don't use SELECT and ENDSELECT allways

<b>Rewardif useful</b>

former_member194613
Active Contributor
0 Kudos

> SAP advises to don't use SELECT and ENDSELECT allways

never heard of that!

SELECT ... ENDSELECT is perfect for buffered tables.

SELECT ... CHECK (cond) ENDSELECT can be useful, if the cond is very hard

and can not be put into the WHERE condition.

However, if the question is as simple,

SELECT ... ENDSELECT versus SELECT INTO TABLE then the second one is better.

Siegfried

varma_narayana
Active Contributor
0 Kudos

Hi Suresh..

When do we need to use SELECT .. ENDSELECT

Usually we will never use SELECT .. ENDSELECT as it gives very poor performance.

But whenever we read a single Record we will use it as an alternative for SELECT SINGLE in some scenarios.

Eg: When the Full primary key is not specified in the WHERE clause.

SELECT * FROM MARC INTO WA_MARC UP TO 1 ROWS WHERE MATNR = P_MATNR.

ENDSELECT.

And other scenario is when we perform AGGREGATE OPERATIONS.when the Result is only one row.

SELECT SUM( LABST ) FROM MARD INTO V_LABST UP TO 1 ROWS

WHERE MATNR = P_MATNR.

ENDSELECT.

Note: In The Above scenario we cannot use SELECT SINGLE..

<b>REWARD IF HELPFUL.</b>

Former Member
0 Kudos

HI SURESH,

U HAVE A DOUBT THAT WHETHER TO USE SELECT------ENDSELECT.

ACTUALLY U R NOT SUPPOSED TO USE

SELECT------- ENDSELECT

THIS WILL CAUSE A PERFORMANCE ISSUE..

UR QUERY PERFORMANCE WILL BE LOST.

SO WHENEVER U WANT TO USE THIS

GO LIKE THIS BASED ON REQUIREMENT

1. SELECT *

FROM MARA

INTO TABLE ITAB

WHERE "" SOME CONDITION""

2. SELECT SINGLE MATNR

FROM MARA

INTO ITAB

GO FOR THIS WHEN U HAVE TO SELECT SINGLE RECORD