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

SELECT AND PERFORM

Former Member
0 Likes
841

PLZ SEND ME IF I WRITE SELECT AND PERFORM STMTS B/W LOOP AND END LOOP THEN WHAT HAPPENS.

PLZ SEND ME IF I WRITE SELECT AND PERFORM STMTS B/W LOOP AND END LOOP THEN WHAT HAPPENS.

5 REPLIES 5
Read only

Former Member
0 Likes
811

SELECT inside a loop shud be avoided..since it interacts with the database on every loop cycle..which is not gud for performance tuning..the interaction with the

database shud b as less as possible

However u r free to write any number of PERFORMS within a loop..

making sure dat der r not ant SELECTS within those performs

Hope dis helps..

Reward all helpful answers

Read only

Former Member
0 Likes
811

Hi

Nothing happens., It will create a performance issue

say the LOOPED ITAB having 1 lakh records,

and in that loop you used a select to some database table

so for that 1 lakh records over that table is get locked every time and consumes lot of time

so better fetch the data outside using for all entries into a itab and READ that itab in the loop and do it

Regards

Anji

Read only

Former Member
0 Likes
811

SAP has a 3-tier architecture.....wherein you have a presentation server(SAP GUI) , APPlication server (where abap programs are run) and the database server from where the data is fetched.

The select statements are sent to the database server. Loops are executed at the application server.

Thus if you have select statements inside loops, you will be repeatedly fetching data from the database server eachtime loop is executed (thereby affecting the performance of your program). better way is to first fetch all the required data in a single shot and then use it in the program.

regards,

Priyank

Message was edited by:

Priyank Jain

Read only

Former Member
0 Likes
811

Hi

NOTE : Don't use Select statement with in loop it causes number of hits on database, so it decrease the performance.

Suppose if interna table contain 1lack records

Now if use select with loop internal table (1 lacks records) then program should hit the database 1 lack times and retrieview data.

At this situation, use the for all entries to select the data corresponding internal table before the loop.

with in loop we can use READ statement to get records form itab.... which increase the performance.

and in the same case for perorm

<b>Reward if useful</b>

Read only

Former Member
0 Likes
811

Hi

Its a good Practice of Not using Select within the LOOP..ENDLOOP..

Only for the Performance Reasons...

To avoid this you can Use for All Entries for the table in whose LOOP ..ENDLOOP.. Select is being Used..

Within LOOP ...ENDLOOP u can use Read Statement to fetch records obtained by For All Entries..

Hope it clears to some extent..

Praveen..