0% found this document useful (0 votes)
7 views

To Control The Flow of The ABAP Program Use The Following Statements

The document discusses different statements used to control program flow in ABAP including IF, IF-ELSE, IF-ELSEIF, and CASE-ENDCASE. The IF statement executes code conditionally based on if a condition is true, IF-ELSE executes one block if true and another if false, IF-ELSEIF checks multiple conditions in order, and CASE-ENDCASE branches based on the value of a variable. Examples are provided for each statement and their expected output.

Uploaded by

Vikram Bigamudre
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

To Control The Flow of The ABAP Program Use The Following Statements

The document discusses different statements used to control program flow in ABAP including IF, IF-ELSE, IF-ELSEIF, and CASE-ENDCASE. The IF statement executes code conditionally based on if a condition is true, IF-ELSE executes one block if true and another if false, IF-ELSEIF checks multiple conditions in order, and CASE-ENDCASE branches based on the value of a variable. Examples are provided for each statement and their expected output.

Uploaded by

Vikram Bigamudre
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

To control the flow of the ABAP program use the following statements.

IF Branching Conditionally IF statement The code between IF and ENDIF is executed only if the condition is true.
DATA: a TYPE i VALUE 10. " We can assign a value in the declaration

IF a > 5. WRITE:/ 'Condition True'. ENDIF.

Output

IF-ELSE statement The code between IF and ELSE is executed if the condition is true, the code between ELSE and ENDIF is executed if the condition is False.
DATA: a TYPE i VALUE 1. IF a > 5. WRITE:/ 'Condition True'. ELSE. WRITE:/ 'Condition False'. ENDIF.

Output

IF-ELSEIF statement Used to check multiple conditions.


DATA: a TYPE i VALUE 2. IF a > 5. WRITE:/ a, 'Greater Than', 5. ELSEIF a > 4. WRITE:/ a, 'Greater Than', 4. ELSEIF a > 3. WRITE:/ a, 'Greater Than', 3. ELSE. WRITE:/ a, 'Less Than', 3. ENDIF.

Output

CASE-ENDCASE Branching based on the content of the variable.


DATA: a TYPE i VALUE 4. CASE a. WHEN 3. WRITE:/ a, 'Equals', 3. WHEN 4. WRITE:/ a, 'Equals', 4. WHEN OTHERS. WRITE:/ 'Not Found'. ENDCASE.

Output

You might also like