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

34 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
  17. Hi,i found lot of information from your blog,its really useful for me.Thanks for sharing..
    Final Year Projects for BE in Chennai | Final Year Projects for BE in Velachery

    ReplyDelete
  18. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work.
    Image Processing Project Center in Chennai | Image Processing Projects in Velachery

    ReplyDelete
  19. Your blog is really amazing with useful information you are shared.Thank you so much for sharing such an wonderful article with us..keep updating....
    Mobile Computing Project Center in Chennai | Mobile Computing Projects in Velachery

    ReplyDelete
  20. Impressive blog with lovely information. really very useful article for us thanks for sharing such a wonderful blog...keep updating..
    Power System Project Center in Chennai | Power System Project Center in Velachery

    ReplyDelete
  21. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Cloud Computing Project Center in Chennai | Cloud Computing Project Center in Velachery

    ReplyDelete
  22. This an awesome blog with helpful content, I m really impressed with your article, such great & useful knowledge post
    Embedded Project Center in Chennai | Embedded Project Center in Velachery

    ReplyDelete
  23. Your Blog is really Nice and Informative..Thanks for sharing such a interesting article..keep updating..I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work.

    Java Project Center in Chennai | Java Project Center in Velachery

    ReplyDelete
  24. Excellent post. I have read your blog it's very interesting and informative.Thanks for sharing such nice article, keep on up dating such good articles.
    Android Project Center in Chennai | Android Project Center in Velachery

    ReplyDelete
  25. Nice and good article.. it is very useful for me to learn and understand easily.. thanks for sharing your valuable information and time.. please keep updating.
    Cloud Computing Project Center in Chennai | Cloud Computing Project Center in Velachery

    ReplyDelete
  26. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    Final Year Project Center for BE in Chennai | Final Year Projects for BE in Velachery

    ReplyDelete