Programming

Example to apply DO statement in ABAP/4

You will apply this statement when you want to loop data with non-condition loops.

Example 1: Simple Loop

DO.
WRITE:/ sy-index.
IF sy-index = 4.
    EXIT.
ENDIF.
ENDDO.

The output is


1
2
3
4

Example 2: Loops with n times

DO 4 TIMES.
WRITE:/ sy-index.
ENDDO.

The output is same as example 1.

Example 3: Nested Loops

Basic Structure of HTML

HTML language has 2 elements; content and tag. Basic tag in HTML file are:

  • ...
    This tag is a indicator for start point and end point of HTML file. is nessesary declared at first line and is declared at end line of file.
  • ...
    This tag response about header definition of web page by using tag .... tag will show title of page in title bar of browser.</li> <li><BODY>...</BODY><br> This tag response about body content that you want to show in your web.  </li> </ul> <p><strong><u>Example file</u></strong></p> </div> <div class="links"> <ul class="links inline"> <li class="first blog_usernames_blog"><a href="/blog/thitima" title="Read thitima's latest blog entries." class="blog_usernames_blog">thitima's blog</a></li> <li class="comment_add">Add new comment</li> <li class="node_read_more"><a href="/basic-structure-of-html" title="Read the rest of this posting." class="node_read_more">Read more</a></li> <li class="last statistics_counter"><span class="statistics_counter">1035 reads</span></li> </ul> </div> </div> <div class="node" id="node-175"> <h2 class="title"><a href="/difference-between-continue-check-and-exit-statement-in-abap-4">Difference between CONTINUE, CHECK and EXIT statement in ABAP/4</a></h2> <div class="meta with-taxonomy"> <div class="submitted"> Posted January 20th, 2006 by <a href="/user/thitima" title="View user profile.">thitima</a> </div> <div class="taxonomy"> <ul class="links inline"> <li class="first taxonomy_term_4"><a href="/taxonomy/term/4" rel="tag" title="" class="taxonomy_term_4">ABAP/4</a></li> <li class="taxonomy_term_21"><a href="/english" rel="tag" title="" class="taxonomy_term_21">English</a></li> <li class="taxonomy_term_1"><a href="/taxonomy/term/1" rel="tag" title="" class="taxonomy_term_1">IT</a></li> <li class="taxonomy_term_2"><a href="/taxonomy/term/2" rel="tag" title="" class="taxonomy_term_2 active">Programming</a></li> <li class="last taxonomy_term_35"><a href="/topic/it/software/sap-r-3" rel="tag" title="" class="taxonomy_term_35">SAP R/3</a></li> </ul> </div> </div> <div class="content"> <ul> <li> <strong>CONTINUE<br></strong>When you apply this statement, system will pass a current loop. System  ignores any statements after CONTINUE statement and start to the next loop.</li> </ul> <blockquote> <blockquote> <p><strong><u>Example</u></strong></p> <pre>DO 4 TIMES.<br> WRITE:/ sy-index.<br> IF sy-index <= 2.<br> CONTINUE.<br><br> ENDIF.<br> WRITE: ’After’.<br>ENDDO.</pre> </blockquote> </blockquote> <blockquote> <blockquote> <p>The output is</p> <pre>1 <br>2 <br>3  After<br>4  After</pre> </blockquote> </blockquote> <ul> <li> <strong>CHECK</strong><br> This statement will apply if you want to check condition before go to next statement. If the result of checking is ’TRUE’, system will go to next step as normally. If the result of checking is ’FALSE’, system will operate look like CONTINUE statement.</li> </ul> <blockquote> <blockquote> <p><strong><u>Example</u></strong></p> </blockquote> </blockquote> </div> <div class="links"> <ul class="links inline"> <li class="first blog_usernames_blog"><a href="/blog/thitima" title="Read thitima's latest blog entries." class="blog_usernames_blog">thitima's blog</a></li> <li class="comment_add">Add new comment</li> <li class="node_read_more"><a href="/difference-between-continue-check-and-exit-statement-in-abap-4" title="Read the rest of this posting." class="node_read_more">Read more</a></li> <li class="last statistics_counter"><span class="statistics_counter">7025 reads</span></li> </ul> </div> </div> <div class="node" id="node-174"> <h2 class="title"><a href="/example-to-apply-while-statement-in-abap-4">Example to apply WHILE statement in ABAP/4</a></h2> <div class="meta with-taxonomy"> <div class="submitted"> Posted January 20th, 2006 by <a href="/user/thitima" title="View user profile.">thitima</a> </div> <div class="taxonomy"> <ul class="links inline"> <li class="first taxonomy_term_4"><a href="/taxonomy/term/4" rel="tag" title="" class="taxonomy_term_4">ABAP/4</a></li> <li class="taxonomy_term_21"><a href="/english" rel="tag" title="" class="taxonomy_term_21">English</a></li> <li class="taxonomy_term_1"><a href="/taxonomy/term/1" rel="tag" title="" class="taxonomy_term_1">IT</a></li> <li class="taxonomy_term_2"><a href="/taxonomy/term/2" rel="tag" title="" class="taxonomy_term_2 active">Programming</a></li> <li class="last taxonomy_term_35"><a href="/topic/it/software/sap-r-3" rel="tag" title="" class="taxonomy_term_35">SAP R/3</a></li> </ul> </div> </div> <div class="content"> <p>You will apply this statement when you want to loop data with condition loops.</p> <p><strong><u>Example 1:</u></strong> Simple Loop</p> <blockquote> <pre>DATA: lv_int TYPE I VALUE 1.<br>WHILE lv_int <= 4.<br> WRITE:/ lv_int.<br> lv_int = lv_int + 1.<br><br><br><br><br>ENDWHILE.</pre> </blockquote> <blockquote> <p>The output is </p> <pre>1<br>2<br>3<br>4</pre> </blockquote> <p dir="ltr"><strong><u>Example 3:</u></strong> Nested Loops</p> <blockquote> <pre>DATA: lv_int TYPE I VALUE 1,<br> lv_int2 TYPE I.<br><br>WHILE lv_int <= 4.<br> WRITE:/ lv_int.<br> lv_int2 = 1.<br> WHILE lv_int2 <= 2.<br> WRITE: lv_int2.<br> lv_int2 = lv_int2 + 1.<br> ENDWHILE.<br> lv_int = lv_int + 1.<br><br><br><br><br>ENDWHILE.</pre> </blockquote> <blockquote> <p>The output is </p> </blockquote> </div> <div class="links"> <ul class="links inline"> <li class="first blog_usernames_blog"><a href="/blog/thitima" title="Read thitima's latest blog entries." class="blog_usernames_blog">thitima's blog</a></li> <li class="comment_add">Add new comment</li> <li class="node_read_more"><a href="/example-to-apply-while-statement-in-abap-4" title="Read the rest of this posting." class="node_read_more">Read more</a></li> <li class="last statistics_counter"><span class="statistics_counter">1930 reads</span></li> </ul> </div> </div> <div class="node" id="node-169"> <h2 class="title"><a href="/select-where-select-check-in-abap-4">Select...Where & Select...Check in ABAP/4</a></h2> <div class="meta with-taxonomy"> <div class="submitted"> Posted January 19th, 2006 by <a href="/user/thitima" title="View user profile.">thitima</a> </div> <div class="taxonomy"> <ul class="links inline"> <li class="first taxonomy_term_4"><a href="/taxonomy/term/4" rel="tag" title="" class="taxonomy_term_4">ABAP/4</a></li> <li class="taxonomy_term_21"><a href="/english" rel="tag" title="" class="taxonomy_term_21">English</a></li> <li class="taxonomy_term_2"><a href="/taxonomy/term/2" rel="tag" title="" class="taxonomy_term_2 active">Programming</a></li> <li class="taxonomy_term_35"><a href="/topic/it/software/sap-r-3" rel="tag" title="" class="taxonomy_term_35">SAP R/3</a></li> <li class="last taxonomy_term_27"><a href="/taxonomy/term/27" rel="tag" title="" class="taxonomy_term_27">Tips and Tricks</a></li> </ul> </div> </div> <div class="content"> <p>Select...Where</p> <blockquote> <pre><br>SELECT * FORM SPFLI<br> WHERE CARRID = ’LH’.<br> ...<br> ...<br> ...<br>ENDSELECT.</pre> </blockquote> <p>Select...Check</p> <blockquote> <pre>SELECT * FORM SPFLI.<br> CHECK SPFLI-CARRID = ’LH’.<br> ...<br> ...<br> ...<br>ENDSELECT.</pre> </blockquote>In above logic, Select...Where is better than Select...Check because the database can then user an index and system resource load is considerably less. </div> <div class="links"> <ul class="links inline"> <li class="first blog_usernames_blog"><a href="/blog/thitima" title="Read thitima's latest blog entries." class="blog_usernames_blog">thitima's blog</a></li> <li class="comment_add">Add new comment</li> <li class="last statistics_counter"><span class="statistics_counter">955 reads</span></li> </ul> </div> </div> <div class="node" id="node-168"> <h2 class="title"><a href="/select-into-table-select-append-in-abap-4">SELECT...INTO TABLE & SELECT...APPEND in ABAP/4</a></h2> <div class="meta with-taxonomy"> <div class="submitted"> Posted January 19th, 2006 by <a href="/user/thitima" title="View user profile.">thitima</a> </div> <div class="taxonomy"> <ul class="links inline"> <li class="first taxonomy_term_4"><a href="/taxonomy/term/4" rel="tag" title="" class="taxonomy_term_4">ABAP/4</a></li> <li class="taxonomy_term_21"><a href="/english" rel="tag" title="" class="taxonomy_term_21">English</a></li> <li class="taxonomy_term_2"><a href="/taxonomy/term/2" rel="tag" title="" class="taxonomy_term_2 active">Programming</a></li> <li class="taxonomy_term_35"><a href="/topic/it/software/sap-r-3" rel="tag" title="" class="taxonomy_term_35">SAP R/3</a></li> <li class="last taxonomy_term_27"><a href="/taxonomy/term/27" rel="tag" title="" class="taxonomy_term_27">Tips and Tricks</a></li> </ul> </div> </div> <div class="content"> <p>Select...Into Table</p> <blockquote> <pre><br>DATA: itab LIKE SPFLI OCCURS 0 WITH HEADER LINE.<br>SELECT * FORM SPFLI INTO TABLE itab.</pre> </blockquote> <p>Select...Append</p> <blockquote> <pre>DATA: itab LIKE SPFLI OCCURS 0 WITH HEADER LINE.<br>SELECT * FORM SPFLI INTO itab.<br> APPEND itab.<br>ENDSELECT.</pre> </blockquote>In above logic, Select...Into Table is faster than Select...Append. </div> <div class="links"> <ul class="links inline"> <li class="first blog_usernames_blog"><a href="/blog/thitima" title="Read thitima's latest blog entries." class="blog_usernames_blog">thitima's blog</a></li> <li class="comment_add">Add new comment</li> <li class="last statistics_counter"><span class="statistics_counter">4135 reads</span></li> </ul> </div> </div> <div class="pager"> <a href="/taxonomy/term/2" class="pager-first active" title="Go to first page">« first</a><a href="/taxonomy/term/2?page=36" class="pager-previous active" title="Go to previous page">‹ previous</a><span class="pager-list"><span class="pager-ellipsis">…</span><a href="/taxonomy/term/2?page=33" class="pager-previous active" title="Go to page 34">34</a><a href="/taxonomy/term/2?page=34" class="pager-previous active" title="Go to page 35">35</a><a href="/taxonomy/term/2?page=35" class="pager-previous active" title="Go to page 36">36</a><a href="/taxonomy/term/2?page=36" class="pager-previous active" title="Go to page 37">37</a><strong class="pager-current">38</strong><a href="/taxonomy/term/2?page=38" class="pager-next active" title="Go to page 39">39</a><a href="/taxonomy/term/2?page=39" class="pager-next active" title="Go to page 40">40</a><a href="/taxonomy/term/2?page=40" class="pager-next active" title="Go to page 41">41</a><a href="/taxonomy/term/2?page=41" class="pager-next active" title="Go to page 42">42</a><span class="pager-ellipsis">…</span></span><a href="/taxonomy/term/2?page=38" class="pager-next active" title="Go to next page">next ›</a><a href="/taxonomy/term/2?page=46" class="pager-last active" title="Go to last page">last »</a> </div> <div class="block block-block" id="block-block-17"> <div class="blockinner"> <div class="content"> <center> </center> </div> </div> </div> </div> <div id="sidebar-right" class="sidebar"> <div class="block block-block" id="block-block-19"> <div class="blockinner"> <div class="content"> </div> </div> </div> <div class="block block-adsense" id="block-adsense-0"> <div class="blockinner"> <div class="content"> <div class="adsense"> </div> </div> </div> </div> <div class="block block-user" id="block-user-0"> <div class="blockinner"> <h2 class="title">User login</h2> <div class="content"> </div> </div> </div> <div class="block block-comment" id="block-comment-0"> <div class="blockinner"> <h2 class="title">Recent comments</h2> <div class="content"> <div class="item-list"> <ul> <li> <a href="/pyjamas-gwt-clone-in-python#comment-6198">Pyjamas 0.3 Released</a><br> 2 years 30 weeks ago</li> <li> <a href="/living-with-centipede#comment-5122">ผมว่าใช้ี</a><br> 2 years 35 weeks ago</li> <li> <a href="/product/drupal-thai#comment-5064">Drupal is big thing!</a><br> 2 years 36 weeks ago</li> <li> <a href="/box-command-in-sapscript#comment-5003">Adding a box to an existing form</a><br> 2 years 36 weeks ago</li> <li> <a href="/how-to-convert-mp3-to-aac-using-ffmpeg#comment-4963">just a question, how to</a><br> 2 years 36 weeks ago</li> <li> <a href="/box-command-in-sapscript#comment-4867">add a horizontal line after every data in Script</a><br> 2 years 39 weeks ago</li> <li> <a href="/product/drupal-thai#comment-4866">I'm just getting into using</a><br> 2 years 39 weeks ago</li> <li> <a href="/how-to-debugging-sapscript-form#comment-4613">how to create simple sap script i need the steps with snap shot</a><br> 2 years 39 weeks ago</li> <li> <a href="/node/370#comment-4444">แต้งค่า........</a><br> 2 years 39 weeks ago</li> <li> <a href="/how-to-initial-value-of-select-options-in-abap-4#comment-4432">Hi, I tried to execute the</a><br> 2 years 39 weeks ago</li> </ul> </div> </div> </div> </div> <div class="block block-forum" id="block-forum-0"> <div class="blockinner"> <h2 class="title">Active forum topics</h2> <div class="content"> <div class="item-list"> <ul> <li><a href="/node/1162">insight real estate el dorado hills</a></li> <li><a href="/node/1161">site</a></li> <li><a href="/node/1160">Çatlak Kremi</a></li> <li><a href="/node/1159">american home mortgage and bankruptcy</a></li> <li><a href="/node/1158">Erotik Ürünler</a></li> </ul> </div> <div class="more-link"> <a href="/forum" title="Read the latest forum topics.">more</a> </div> </div> </div> </div> <div class="block block-user" id="block-user-1"> <div class="blockinner"> <h2 class="title">Navigation</h2> <div class="content"> <ul class="menu"> <li class="collapsed"><a href="/node/add">Create content</a></li> <li class="leaf"><a href="/tracker">Recent posts</a></li> </ul> </div> </div> </div> <div class="block block-user" id="block-user-3"> <div class="blockinner"> <h2 class="title">Who's online</h2> <div class="content"> There are currently <em>0 users</em> and <em>34 guests</em> online. </div> </div> </div> <div class="block block-node" id="block-node-0"> <div class="blockinner"> <h2 class="title">Syndicate</h2> <div class="content"> <img src="/misc/feed.png" alt="Syndicate content" title="Syndicate content" width="16" height="16"> </div> </div> </div> </div> </div> <div id="sidebar-left" class="sidebar"> <div class="block block-block" id="block-block-21"> <div class="blockinner"> <div class="content"> <a style="color: #999" href="http://www.lijit.com" id="lijit_wijit_pvs_link" name="lijit_wijit_pvs_link">Lijit Search</a> </div> </div> </div> <div class="block block-tagadelic" id="block-tagadelic-3"> <div class="blockinner"> <h2 class="title">tags in Topic</h2> <div class="content"> <a href="/taxonomy/term/2" class="tagadelic level4 active">Programming</a> <a href="/taxonomy/term/27" class="tagadelic level4">Tips and Tricks</a> <a href="/topic/it/software/linux" class="tagadelic level4">Linux</a> <a href="/taxonomy/term/6" class="tagadelic level4">Software</a> <a href="/taxonomy/term/1" class="tagadelic level4">IT</a> <a href="/taxonomy/term/7" class="tagadelic level3">Drupal</a> <a href="/taxonomy/term/26" class="tagadelic level3">Announcement</a> <a href="/taxonomy/term/4" class="tagadelic level3">ABAP/4</a> <a href="/taxonomy/term/24" class="tagadelic level3">Development</a> <a href="/taxonomy/term/23" class="tagadelic level2">Search Engine</a> <a href="/taxonomy/term/5" class="tagadelic level2">General</a> <a href="/topic/it/software/sap-r-3" class="tagadelic level2">SAP R/3</a> <a href="/taxonomy/term/3" class="tagadelic level2">Python</a> <a href="/topic/it/security" class="tagadelic level2">Security</a> <a href="/taxonomy/term/25" class="tagadelic level2">Bug</a> <a href="/topic/it/software/freebsd" class="tagadelic level2">*NIX</a> <a href="/taxonomy/term/17" class="tagadelic level2">Recreation</a> <a href="/topic/it/programming/php" class="tagadelic level2">PHP</a> <a href="/taxonomy/term/31" class="tagadelic level1">HPC</a> <a href="/taxonomy/term/20" class="tagadelic level1">Movie</a> <a href="/taxonomy/term/13" class="tagadelic level1">BTQueue</a> <a href="/topic/it/programming/codenone" class="tagadelic level1">Codenone</a> <a href="/taxonomy/term/34" class="tagadelic level1">Cluster Computing</a> <a href="/taxonomy/term/32" class="tagadelic level1">Grid Computing</a> <a href="/topic/it/programming/html" class="tagadelic level1">HTML</a> </div> </div> </div> <div class="block block-block" id="block-block-20"> <div class="blockinner"> <h2 class="title">Recent posts</h2> <div class="content"> <div class="item-list"> <ul> <li><a href="/node/1162">insight real estate el dorado hills</a></li> <li><a href="/node/1161">site</a></li> <li><a href="/node/1160">Çatlak Kremi</a></li> <li><a href="/node/1159">american home mortgage and bankruptcy</a></li> <li><a href="/node/1158">Erotik Ürünler</a></li> </ul> </div> <div class="more-link"> <a href="/node" title="Read the latest entries.">more</a> </div> </div> </div> </div> </div> </div> <div id="footer"> Look! Read! Ask! © 2006-2007 howforge.com <a href="http://creativecommons.org/licenses/by/2.5/">Some rights reserved</a>. </div> </div> </body> </html>