10-11-2007 10:59 AM
hi all,
When to use SELECT and END SELECT in the query.
regads,
Venkata Suresh Penke.
10-11-2007 11:02 AM
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.
10-11-2007 11:09 AM
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.
10-11-2007 11:04 AM
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
10-11-2007 11:07 AM
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
10-11-2007 11:22 AM
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
10-11-2007 11:27 AM
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
10-11-2007 11:35 AM
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
10-11-2007 12:16 PM
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>
10-11-2007 12:22 PM
> 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
10-11-2007 1:02 PM
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>
10-11-2007 3:34 PM
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