SAP ABAP - Do Loop


Advertisements

Unconditional loops repeatedly execute several statements without specifying any condition. The DO statement implements unconditional loops by executing a set of statement blocks several times unconditionally.

Syntax

The general format for the DO statement is as follows −

DO [n TIMES]. 
 
<statement block>.
  
ENDDO.

‘Times’ imposes a restriction on the number of loop passes, which is represented by ‘n’. The value of ‘n’ should not be negative or zero. If it is zero or negative, the statements in the loop are not executed.

Flow Diagram

Do While Loop

Example

Report YH_SEP_15.
  
Do 15 TIMES. 
 
Write: / 'Hello'.
  
ENDDO.

The above code produces the following output −

Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello

In this example, the system understands that the loop is to be processed 15 times.

sap_abap_loop_control.htm

Useful Video Courses


Video

SAPUI5 Online Training

25 Lectures 6 hours

Sanjo Thomas

Video

SAP Webi Online Training

Most Popular

26 Lectures 2 hours

Neha Gupta

Video

SAP Basis Online Training

30 Lectures 2.5 hours

Sumit Agarwal

Video

SAP C4C Online Training

30 Lectures 4 hours

Sumit Agarwal

Video

SAP MM Online Training

14 Lectures 1.5 hours

Neha Malik

Video

SAP WM Online Training

13 Lectures 1.5 hours

Neha Malik

Advertisements