‎2007 Jun 06 11:36 PM
hello friends,
for the first time my select statement is asking for end select .
why, and when to keep endselect.
thank you.
‎2007 Jun 06 11:51 PM
You should write...
SELECT FIELD1 FIELD2
INTO TABLE MY_TAB
FROM MARA.
And...never use SELECT-ENDSELECT....In 5 years of ABAP programming I only needed twice....So avoid it anytime you can -;)
Greetings,
Blag.
‎2007 Jun 06 11:39 PM
Hey saritha
Select...endselect is like a loop on the database table.
Also if u have specified 'upto n rows' in your select query , it will ask you for an endselect.
can you please copy paste your code here so that we can have a look.
Cheers
shivika
‎2007 Jun 06 11:39 PM
Hi Saritha,
Give ur select statement. I am definite that you have missed INTO in your select statement.
Thanks
Aneesh.
‎2007 Jun 06 11:51 PM
You should write...
SELECT FIELD1 FIELD2
INTO TABLE MY_TAB
FROM MARA.
And...never use SELECT-ENDSELECT....In 5 years of ABAP programming I only needed twice....So avoid it anytime you can -;)
Greetings,
Blag.
‎2007 Jun 07 12:44 AM
do not use select endselect and it will be performance issue.
Simple example
<b>Select endselect example.</b>
tables : mara.
data : i_mara like mara occurs 0 with header line.
start-of-selection.
select * from mara into i_mara.
write:/ i_mara-matnr.
endselect.
<b>normal select query</b>
tables : mara.
data : i_mara like mara occurs 0 with header line.
start-of-selection.
select * from mara into <b>table</b> i_mara.
loop at i_mara.
write:/ i_mara-matnr.
endloop.
‎2007 Jun 07 1:16 AM
Hi Saritha,
U need to use ENDSELECT when you are looping through the database table ie Fetching more than one entries from the table without using the fetch technique.
For eg.
______
PARAMETERS pa_matnr LIKE mara-matnr.
DATA: wa_mara LIKE mara.
SELECT * FROM mara INTO wa_mara WHERE matnr = pa_matnr.
WRITE:/ wa_matnr-matnr.
ENDSELECT.
‎2007 Jun 07 2:22 AM
i think if you can paste your select query it will be better to analyze.
but i think you are not spaecifying into table itab. if table word is not there it will ask for endselect. only into will fetch 1 record at a time. so you have to loop it for fetching all the record by select..endselect loop. Or if you want asingle row use select single then it will not ask for endselect.
select matnr into <b>table</b> imara from mara where..." no endselect.
select matnr into imara from mara where..." with endselect.
append itab.
endselect.
or select single matnr into imara from mara where..." without endselect but single row.
regards
shiba dutta
‎2007 Jun 07 3:32 AM
Do this it will won't ask .
TABLES : <Table name>
Reward points.
Regards,
SaiRam
‎2007 Jun 07 4:20 AM
Hi Saritha,
SELECT-ENDSELECT, as our friends have specified, is like a loop in a database table. If you fire a query like the following one:
SELECT * FROM MARA INTO WA_MARA.
<--logic-->
ENDSELECT.Here, the runtime environment does not know how many records are there in MARA. It hits the database table, fetch one record, perform the logic, and goes back to find another record. So unless and until you specify a 'SINGLE' or 'INTO TABLE OF', you'll have to use ENDSELECT. The former explicitly specifies that there is only one record coming, and hence a loop is needless, while the latter hits the table and selects all the matching records at one go.
Its always better to go for SELECT..INTO TABLE OF...as it minimizes database hits.
Regards
Anil Madhavan
‎2007 Jun 07 5:35 AM
Hi,
you need only to specify endselect when using select up to n rows.
Else, it affects performance.
Regards,
Sooness.
‎2007 Jun 07 6:36 AM
Hi Saritha,
<b> It is not advisible to use end select.</b>
So the solution is either if you are
1> selecting a single line of values from the data base tables then use "SINGLE" i.e select single field_name1 field_name2 field_namen from table_name into int_table.
2> Else if you are selecting multiple rows then use INTO table int_table.
This should solve the problem.
Reward Points if useful.
Thanks,
Tej..
‎2007 Jun 07 6:38 AM
Hi,
bcoz u have not give into clause in your select stmt.
Wheever u r not giving into options its must to give endselect. its like loop at DBTAB.
Jogdand
‎2007 Jun 07 6:49 AM
hi saritha,
y should write select statement like this to avoid this problem,
select * from <database table> <b>into table</b> <itab> where condition.
because if u dont write <b>table</b> keyword in the select statement then it selects one record from database and fills work area of internal table then append statement can move that record to internal table body from work area,
for this it asks abt end select.
if u write <b>table</b> keyword in select statement then u can avoid this.
u just try this then it dont ask for endslect.
regards,
seshu.
‎2007 Jun 07 7:06 AM
Hi Saritha,
u need to give the ENDSELECT with SELECT query when ur fetching tha data into work area of the table instead of directly into table.
in this case u need to end the SELECT query with ENDSELECT.
But this will decrease the performance.
Instead of using this directly fetch the data into table instead of work area.
HERE I WILL GIVE U TWO EXAMPLES
SELECT * FROM <table> INTO w_table WHERE <condition>.
ENDSELECT.
NEVER USE THIS INSTEAD.
SELECT * FROM <table> INTO TABLE it_table WHERE <condition>
Reward points if it is helpful,
Thanks,
KRISHNA PRASAD .K