Skip to main content

Nested Control Structures

BeginnerControl Structures⏱ 10 min

Task

Write ABAP logic using nested control structures. Use a DO loop combined with an IF condition to determine whether a number is even or odd.

  • Use DO loop
  • Use IF / ELSE inside the loop
  • Understand nesting flow

Write Your ABAP Code

ABAP Editor
Loading...
📥 Sample Input & Output
Loop runs 3 times

Iteration 1 → Odd
Iteration 2 → Even
Iteration 3 → Odd
💡 Hint

Use MOD operator inside an IF condition to check even or odd numbers.

✅ View Reference Solution
DO 3 TIMES.
  IF lv_i MOD 2 = 0.
    " Even number
  ELSE.
    " Odd number
  ENDIF.
  lv_i = lv_i + 1.
ENDDO.