Tutorial by Examples

IF lv_foo = 3. WRITE: / 'lv_foo is 3'. ELSEIF lv_foo = 5. WRITE: / 'lv_foo is 5'. ELSE. WRITE: / 'lv_foo is neither 3 nor 5'. ENDIF.
CASE lv_foo. WHEN 1. WRITE: / 'lv_foo is 1'. WHEN 2. WRITE: / 'lv_foo is 2'. WHEN 3. WRITE: / 'lv_foo is 3'. WHEN OTHERS. WRITE: / 'lv_foo is something else'. ENDCASE
CHECK is a simple statement that evaluates a logical expression and exits the current processing block if it is false. METHOD do_something. CHECK iv_input IS NOT INITIAL. "Exits method immediately if iv_input is initial "The rest of the method is only executed if iv_input is not i...
ASSERT is used in sensitive areas where you want to be absolutely sure, that a variable has a specific value. If the logical condition after ASSERT turns out to be false, an unhandleable exception (ASSERTION_FAILED) is thrown. ASSERT 1 = 1. "No Problem - Program continues ASSERT 1 = 2. &quo...
SWITCH and COND offer a special form of conditional program flow. Unlike IF and CASE, they respresent different values based on an expression rather than executing statements. That's why they count as functional. COND Whenever multiple conditions have to be considered, COND can do the job. The syn...

Page 1 of 1