Make the rule visible in code
A fictional support desk uses three labels: URGENT, NORMAL, and LOW. The rule is easy to explain to a person; write it so another developer can follow it just as easily.
IF for a condition or range of conditions
IF ticket_level = 'URGENT'.
DATA(result) = 'Escalate'.
ELSE.
result = 'Queue normally'.
ENDIF.
Use IF when a rule is based on a condition, comparison, or combination of conditions. ELSEIF can handle additional branches. Keep the order intentional: a broad condition earlier can prevent a more specific branch from being reached.
CASE for one value with distinct choices
When comparing one variable against several exact alternatives, CASE can make the choices easy to scan:
CASE ticket_level.
WHEN 'URGENT'.
result = 'Escalate'.
WHEN 'NORMAL'.
result = 'Queue normally'.
WHEN OTHERS.
result = 'Review label'.
ENDCASE.
Choose IF for ranges and compound conditions; choose CASE when one value maps to a list of alternatives. Neither is always “better”—readability and the rule determine the fit.
Practice
Handle an URGENT ticket using IF, assign the output label to result, and add the chosen environment’s output statement. The code checker does not run ABAP.
Version note: This lesson uses basic control statements, but syntax and language restrictions still depend on the target ABAP version.
Sources
- SAP Samples, ABAP Cheat Sheets overview
- SAP Help Portal, ABAP Keyword Documentation
Developer practice · ABAP
Practice: classify a ticket priority
For a ticket marked URGENT, assign 'Escalate' to result. Use IF/ELSE and close the block correctly.
This choice changes the output pattern checked here: WRITE belongs in a classic executable report, while out->write( ) uses the supplied output reference in an ABAP Cloud class-run method. It does not switch the language version of the other code; check release and API availability in your target system.
Complete the task and include the output statement shown for your selected environment. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.
0 required structures detected · 0 checks
Write your solution, then check its structure.
One possible solution
DATA(ticket_level) = 'URGENT'.
IF ticket_level = 'URGENT'.
DATA(result) = 'Escalate'.
ELSE.
result = 'Queue normally'.
ENDIF.
WRITE result.out->write( result ).These are context-specific output examples. In your own program, use the result variable from your solution and the output mechanism available in that program.