SAP OO OBS CASE 1

Get Example source ABAP code based on a different SAP table
  


ABAP Code Snippet
ARTICLE

Incorrect Statement After CASE
In ABAP Objects WHEN must be the first statement after CASE .

Error message in ABAP Objects if the following syntax is used:

CASE a.
MOVE 5 TO a.
WHEN 5.
WRITE a.
ENDCASE.
Correct syntax:

MOVE 5 TO a.
CASE a.
WHEN 5.
WRITE a.
ENDCASE.
Reason:

The CASE control structure must always reflect the semantics of an IF - ELSEIF control structure, which is not ensured if a statement could occur between CASE and WHEN.