Tuesday, 7 January 2014

Nested Do Loops in SAP ABAP

Nested Do Loops in SAP ABAP

DO loops can also be nested. If this is done, each nested loop will have its own sy-index created and monitored by the system. Be aware that when nesting many loops, it is im-portant to consider how much work the system is being asked to do.
Add to the WRITE statement from the previous section a small amount of text reading ‘Outer Loop cycle:’ before outputting the value of ‘a’. This will allow ‘a’ to be monitored.
Then, under the WRITE statement, add a new DO statement to create the inner loop cycle, as below, as well as adding the extra data variables. The main loop will execute 15 times, but within each of these loops, the nested loop will execute 10 times. The variable named ‘c’ will count how many times the loop has occurred. Around 150 loops will execute here.
While the SAP system will certainly be able to handle this instantly, you should bear in mind that if this number was significantly larger and included more intensive processing than simple counting, this could take much longer.
                                      
Nested Do Loops in SAP ABAP

Set a breakpoint and execute this code in debug mode, keeping an eye on the values of a, b, c and sy-index in the Fields mode. As the DO loop is entered, the sy-index field will be-gin counting. Here, the inner loop has just occurred for the 10th time, noted by the 10 in sy-index (and indeed the value of ‘b’).
        
Nested Do Loops in SAP ABAP

After the second full loop, sy-index and ‘a’ will display 2, ‘b’ will be 10 again (as its value is reset to 0 at the beginning of each loop) and ‘c’ will display 20 representing the number of calculations completed all together
      
Nested Do Loops in SAP ABAP

After the full 15 outer loops are completed, it will look like this
     
Nested Do Loops in SAP ABAP

The value of ‘a’ is then added to ‘c’ to give the total number of both outer and inner loops completed
     
Nested Do Loops in SAP ABAP


When the results are viewed in the output window, the last full loop will look like this
Nested Do Loops in SAP ABAP

23 comments:

  1. Thanks for your informative article on software testing. Your post helped me to understand the future and career prospects in software testing. Keep on updating your blog with such awesome article.
    Regards,
    Software testing training| testing training in Chennai| Software training institutes in Chennai

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Thanks for sharing this kind of information. iam so happy to read your blog. Thanks you so much.

    Android Training in chennai

    ReplyDelete
  4. A very helpful article for everyone. Good work.
    There are different modules for different enterprises depending on nature and size of the business.
    http://eonlinetraining.co/course/sap-sd-online-training/

    ReplyDelete
  5. Excellent blog, I wish to share your post with my folks circle. It’s really helped me a lot, so keep sharing post like this.
    Best Selenium Training Institute in Chennai|Selenium Training in Chennai|Selenium Training

    ReplyDelete
  6. This information is impressive; I am inspired by your post writing style & how continuously you describe this topic.


    Android Training in Chennai

    ReplyDelete
  7. Your Blog is nice and informative with excellent content..keep sharing your amazing post..
    Best Data Mining Project Center in Chennai | No.1 Data Mining Project Center in Velachery

    ReplyDelete
  8. I enjoy what you guys are usually up too. This sort of clever work and coverage! Keep up the wonderful works guys I’ve added you guys to my blog roll..,

    white label website builder

    mobile website builder

    ReplyDelete
  9. Awesome blog. I enjoyed reading your articles. This is truly a great read for me.
    Mobile Computing Project Center in Chennai | Mobile Computing Projects in Velachery

    ReplyDelete
  10. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...

    ReplyDelete
  11. Your Blog is really useful for me,thanks for sharing your amazing post.
    Data Mining Project Center in Chennai | Data Mining Projects in Velachery

    ReplyDelete
  12. Your Blog is very awesome with useful information.keep updating such an wonderful post with us..
    No.1 Power System Project Center in Chennai | No.1 Power System Projects in Velachery

    ReplyDelete
  13. Awesome blog. I enjoyed reading your articles. This is truly a great read for me.
    Cloud Computing Project Center in Chennai | Cloud Computing Projects in Velachery

    ReplyDelete
  14. I am happy to read your blog,its really useful for me,thanks for sharing this wonderful post.
    Electrical Project Center in Chennai | Electrical Projects in Velachery

    ReplyDelete
  15. Really wonderful blog.Thanks for sharing such an informative post to our knowledge...
    Best Final Year Projects for BE in Chennai | Final Year Projects for BE in Velachery

    ReplyDelete
  16. Great article..keep updating..
    Great article..keep updating..

    ReplyDelete