Application Development and Automation 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: 
Read only

difference b/w select endselect & select

Former Member
0 Likes
933

Hi ,

What is the difference in

Select...

...

endselect .

&

Select ....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
852

SELECT * from MARA.

Append MARA to i_MARA.

ENDSELECT.

Above statement will execute 100 times if MARA has 100 records & i_mara will have all 100 records

SELECT * from MARA

into table i_mara.

Above statement will execute only once & fetch all the 100 records in i_mara.

6 REPLIES 6
Read only

gopi_narendra
Active Contributor
0 Likes
852

select endselect is just like a select with in a loop.

see the below examples

using select endselect

select * from vbak.

append vbak to it_vbak.

endselect.

alternative of using select endselect

select * from vbak into table it_vbak.

Hope it is clear

Regards

Gopi

Read only

Former Member
0 Likes
853

SELECT * from MARA.

Append MARA to i_MARA.

ENDSELECT.

Above statement will execute 100 times if MARA has 100 records & i_mara will have all 100 records

SELECT * from MARA

into table i_mara.

Above statement will execute only once & fetch all the 100 records in i_mara.

Read only

Former Member
0 Likes
852

Basically both have the same output. However their usage is different.

select - endselect -> this is used when you do not specify all the primary ckeys of the table in WHERE clause.

select single -> This is used when you specify all the primary keys of table in the WHERE clause of the query.

I hope this solves your doubt.

Reward points if helpful

Read only

Former Member
0 Likes
852

HI,

select.

...

endselect

this fetches the data from the dbtab in a loop 1 by 1.this locks the table for the particular time period.

select * from bdtab into table.

here it fetches the record in 1 shot and need not lock the table.

hence select is faster than select...endselect

thanks

vivekanand

Read only

Former Member
0 Likes
852

hi,

in this select statement no need to give end select as it is populating all the data to table itab_mara.

select matnr ernam from mara into corresponding fields of table itab_mara

where matnr = marc-matnr.

2. this select statement becomes a loop so we have to specify endselect.

select matnr ernam from mara into corresponding fields of itab_mara

where matnr = marc-matnr.

endselect.

Reward with points if helpful.

Message was edited by:

Vinutha YV

Read only

Former Member
0 Likes
852

hi,

select ........... end select just acts like a loop and it fetches all records from database table and places into internal table. in select statement there are different types as

1. select single * .................. -


fetches only one record from database table based on where condition

2. select matnr,pernr,...................... -


fetches no .of fields from different tables [with help of views or joins].............

3. select * from .............. into table itab -


fecthes all fields from database table into internal table in a single time.

4. select matnr, pernr ................... into d_matnr, d_pernr..........----


fetches fields of databse tables into individual fields .

with select statement we can use into corresponding option also.

if helpful reward some points.

with regards,

Suresh aluri.