Control Statements:
- IF…ENDIF.
- IF….ELSE…ENDIF.
- IF….ELSEIF…ENDIF.
- DO…ENDDO.
- WHILE…ENDWHILE.
- CASE…ENDCASE.
PARAMETERS : P_AGE(3) TYPE N.
FI P_AGE >= 18.
WRITE: / ‘ELIGIBLE’.
ENDIF.
DO N TIMES.
….
…
….
ENDDO.
Inside DO…ENDDO. The system field, SY-INDEX contain current loop index.
Parameters P_NAME TYPE I.
DATA RES TYPE I.
DO 10 TIMES.
RES = P_NUM * SY-INDEX.
WRITE: / P_NUM, ‘*’, SY-INDEX, ‘=’, RES.
ENDDO.
WHILE…ENDWHILE.
WHILE (condition)
…
…..
…
ENDWHILE.
PARAMETER P_NUM TYPE I.
WHILE P_NUM <> 0.
P_NUM = P_NUM -1.
P_NUM = 7.
CONTINUE.
ENDIF.
WRITE : /P_NUM.
ENDWHILE.
CONTINUE skips the loop processing.
EXIT cancels the innermost loop.
CASE…ENDCASE.
CASE variable
WHEN ‘ ‘
….
…
WHEN ‘ ’
…
….
WHEN OTHERS
….
…
ENDCASE.
PARAMETERS P_COLOR TYPE I.
CASE P_COLOR.
WHEN ‘1’.
WRITE: /’RED’.
WHEN’2’/
WRITE:/’GREEEN’.
WHEN OTHERS.
WRITE:/’INVALID COLOR’.
ENDCASE.
No comments:
Post a Comment