2007 Nov 06 6:52 AM
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.
2007 Nov 06 6:56 AM
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
2007 Nov 06 6:57 AM
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
2007 Nov 06 6:59 AM
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
2007 Nov 06 7:07 AM
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>
2007 Nov 06 7:11 AM
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..
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |