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

diffrence between select endselect and select.

Former Member
0 Likes
2,116

Hi all,

Could you tell me please that what is the difference between select and  endselect.

1-  select a b c from table xy into itab where a = 1.

2 select a b c from table xy into itab where a = 2.

   endselect.

Moderator message: FAQ, please search for information before posting.

Message was edited by: Thomas Zloch

3 REPLIES 3
Read only

former_member206439
Contributor
0 Likes
1,415

Select

Endselect

it work's like a Loop and Endloop.

Where as Select will retrive all the values at once.

Read only

alex_campbell
Contributor
0 Likes
1,415

As Naresh stated, SELECT ... ENDSELECT works like LOOP ... ENDLOOP, whereas SELECT retrieves all values at once. There are some important considerations though.

- In your examples, statement 1 will not compile. When using the Select statement without EndSelect, you need to either specify SELECT SINGLE ... INTO ... (meaning that only one record from the database will be returned, and it will be populated into the structure you provide) or, you need to specify SELECT ... INTO TABLE ... (meaning that all records are returned, and populated into the internal table you provide.) You can also use APPENDING TABLE instead of INTO TABLE if you don't want to overwrite the internal table.

- SELECT ... ENDSELECT uses a database cursor to interate through the rows that match your query. Because of this, you cannot use the COMMIT WORK or ROLLBACK WORK statements, because they would close the database cursor.

In general I think using the SELECT without the ENDSELECT is the better practice. I never use SELECT ... ENDSELECT in my code.

Read only

Former Member
0 Likes
1,415

Select * into ITAB is faster. Select Endselect is slower.

Also, Select Endselect locks table for the entire processing time. Hence, it is better to use Select Into ITAB.

You can go to SE30 -> Utilities -> Tips and Tricks for more details.