Video Lesson 4.10: ABAP Loops

Video Lesson 4.10: ABAP Loops

This lesson shows how to create loops in ABAP to iterate through a process.

Loops

In a loop, a statement block is executed several times in succession. There are four kinds of loops in ABAP:

  • Unconditional loops using the DO statement.
  • Conditional loops using the WHILE statement.
  • Loops through internal tables and extract data sets using the LOOP statement.
  • Loops through datasets from database tables using the SELECT statement.

Unconditional Loops

  • To process a statement block several times unconditionally, use the following control structure:
  • DO [n TIMES] ...
      [statement_block]
    ENDDO.
  • Use the TIMES addition to restrict the number of loop passes to n.
  • If you do not specify any additions, the statement block is repeated until it reaches a termination statement such as EXIT or STOP.