Give each value a clear job
The dispatch team sees an order as Packed, while the warehouse rule says it should become Ready to ship after a final scan. These are different kinds of data: one changes as work progresses; the other is a fixed value used by this example.
A variable can change
DATA(current_status) = 'Packed'.
current_status = 'Ready to ship'.
DATA declares a data object. Inline declaration lets ABAP infer the type from the initial value; here the literal gives it a character-like type. Later assignments change the contents, not the identity of the variable.
A constant records a fixed value
CONSTANTS target_status TYPE string VALUE 'Ready to ship'.
Use CONSTANTS when the value should not be reassigned in the program. It communicates intent to the reader and prevents accidental changes. Do not make a value constant merely because it has not changed yet: choose based on whether the logic should allow reassignment.
Name values for meaning
Names such as current_status and target_status explain why the value exists. A vague name like x makes later conditions harder to understand. ABAP identifiers are case-insensitive, though a consistent lowercase style is common in examples.
Practice
Declare a target status and current status. Assign the current status to result, then use the selected environment’s output. The browser checker checks structure only—it is not an ABAP compiler.
When to choose each
- Use a variable for values that the program updates.
- Use a constant for a value that should remain fixed within the program’s logic.
- Use an explicit type when the intended domain is not obvious from an initial value.
Version note: Inline declarations and available built-in types depend on release and language version. Confirm syntax in your system.
Sources
- SAP Samples, ABAP Cheat Sheets overview
- SAP Help Portal, ABAP Keyword Documentation
Developer practice · ABAP
Practice: store a shipment status
Create a fixed target status and a current status for a sample shipment. Set result to the current status so it can be displayed.
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
CONSTANTS target_status TYPE string VALUE 'Ready to ship'.
DATA(current_status) = 'Packed'.
DATA(result) = current_status.
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.