SAP StackFICOHRMMSDPMPSABAPNetWeaverTablesTcodes ☰MENU

DO and WHILE loops in ABAP

DO and WHILE statements are used for creating loops in ABAP programming. There are mainly four types of loops in ABAP programs, they are

Here we are going to learn about the loops with DO and WHILE statements.

DO loops

DO statement is used for creating unconditional loops.

Syntax

DO [<n> TIMES] [VARYING <f> FROM <f1> NEXT <f2>].

…..

ENDDO

 

Sample program with DO statement

DO 10 TIMES.

WRITE SY-INDEX.

ENDDO.

 

WHILE loops

WHILE statement is used for creating conditional loops. As long as the specified condition is TRUE the loop iterations will continue. When the condition becomes FALSE the loop will be terminated.

Syntax

WHILE <condition> [VARY <f> FROM <f1> NEXT <f 2>].

….

ENDWHILE.

 

Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes

SAP ALECRMSCMSRMSAP Solutions SAP ReferencesSAP BasicsPP ModuleWMSAP Partners
HomeContact & Privacy PolicyTwitter
All of the product names here are trademarks of their respective companies. The site sapstack.com is not affiliated with SAP AG.
©2018 sapstack.com