DO Loop with Exit Condition
Task
Write ABAP logic using a DO loop that continues execution until a specific condition is met, at which point the loop should terminate using EXIT.
- Use DO loop
- Check condition inside the loop
- Terminate loop using
EXIT
Write Your ABAP Code
Loading...
📥 Sample Input & Output
Initial value: lv_count = 1 Loop continues until lv_count = 5 Final value when EXIT is triggered: 5
💡 Hint
Use an IF condition inside the DO loop and call EXIT when the condition is satisfied.
✅ View Reference Solution
DO.
IF lv_count = 5.
EXIT.
ENDIF.
lv_count = lv_count + 1.
ENDDO.