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

Nested LOOP

Former Member
0 Likes
1,771

Hi Experts,

1) Are Nested LOOPS acceptable in coding? if Yes, How much extent ?

2) in LOOP...ENDLOOP, Can we use Select Single Statements?

3) If we can use appox. 6 nested loops how much performance was affected?

4) In LOOP..ENDLOOP.... Can we use MOVE-CORRESPONDING statements

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,536

Hi Siva,

Here are the replies.


1) Nested loops are not accepted in the coding by if you are not able to get hte solution then you need to put one loop inside other but this is also a bad coding.

2) Yes you can use select single inside loop endloop. but the good practice is fetch all the data from the tables and use the Read statement instead of Select single.

3) Dude performance will be degraded in 2 nested loops . and you are using 6 nested loops then the system will go down with the performance.

4) MOVE-CORRESPONDING  is not a good practice instead of this you can directly assign the field name value.

Thanks,

Chidanand

9 REPLIES 9
Read only

Former Member
0 Likes
1,536

so how was the interview??

pk

Read only

0 Likes
1,536

HI Krishna,

This is not in interview questions..

I need to done Code walk through for program. He developed the program in that fashion.. Now i need to give the report.

Read only

0 Likes
1,536

Hi Siva,

All that you have written are usually best avioded in any report which can have loads of data to process.

But even then at times it may be unavoidab;e to use such loops.

My personal experience has been that at times loads of read table cost more than select singles.

Try and run the report in SE30 and you will have a fairly good idea to suggest changes if need be.

Regards,

Read only

Former Member
0 Likes
1,537

Hi Siva,

Here are the replies.


1) Nested loops are not accepted in the coding by if you are not able to get hte solution then you need to put one loop inside other but this is also a bad coding.

2) Yes you can use select single inside loop endloop. but the good practice is fetch all the data from the tables and use the Read statement instead of Select single.

3) Dude performance will be degraded in 2 nested loops . and you are using 6 nested loops then the system will go down with the performance.

4) MOVE-CORRESPONDING  is not a good practice instead of this you can directly assign the field name value.

Thanks,

Chidanand

Read only

Former Member
0 Likes
1,536

1) Are Nested LOOPS acceptable in coding? if Yes, How much extent

ans yes but performance point of view in decrease performance.

2) in LOOP...ENDLOOP, Can we use Select Single Statements?

Ans Genelly we not use select statement within the loop. it increas the time of execution

3) If we can use appox. 6 nested loops how much performance was affected?

yes: but it decrease the performance of program.

4) In LOOP..ENDLOOP.... Can we use MOVE-CORRESPONDING statements

ans yes but move is better than move-correspondoin.

Read only

Former Member
0 Likes
1,536

1) Nested loops are not accepted in the coding by if you are not able to get hte solution then you need to put one loop inside other but this is also a bad coding. You can use but performance point of view in decrease performance

2) Yes you can use select single inside loop endloop. but the good practice is retrieve all the data from the database tables and use the Read statement instead of Select single.

Genelly we not use select statement within the loop. it increase the time of execution.

3) If you use 2 nested loops, it will decrease the performance and you are using 6 nested loops then the system will go down with the performance.

4) MOVE-CORRESPONDING is not a good practice instead of this you can directly assign the field name value or but move is better than move-correspondoing.

Read only

Former Member
0 Likes
1,536

Hi,

If you use Nested loops you will face performance issues. But no restriction.

Use read statement in loops inted of select single.

Declare filed symbols and use intend of MOVE-CORRESPONDING.

Regards

Durga

Read only

Former Member
0 Likes
1,536

Hi,

1) Nested loops are not acceptable in coding.

But use that only if you have no other option but to use it.

2) In loop and endloop you can use select statement.

But this degrades the performance in a great way.

Try to fetch data in advance in an internal table and then read that internal table inside of the loop statement.

3)Only 2 loop statement is enough for performance degradation. 6 loops are a big deal.

The rate of performance degradation depends upon the amount of selected data.

If in the first statement it is looping for 50 times and in second for 60 times,

then total looping will be forr 50*60 = 3000 times.

So you can think.

4)In lopp-endloop move corresponding can be used, but better is to avoid them.

Try to assign directly and then append to an internal table.

Thanks & regards

Jayati

Read only

Former Member
0 Likes
1,536

Thanks All