Calculate the gap, not the whole order

A store wants 40 units of a safety item. The warehouse already has 27 available. The immediate gap is 13; requesting 40 more would overstock the store.

Expressions combine values

DATA(target_quantity) = 40.
DATA(available_quantity) = 27.
DATA(result) = target_quantity - available_quantity.

The expression on the right is evaluated, then assigned to result. Parentheses can make a longer calculation easier to read:

DATA(result) = target_quantity - ( available_quantity + reserved_quantity ).

Before using a calculation in a real process, decide what should happen when availability is already at or above the target. An expression calculates a result; it does not decide the business rule for every edge case.

Compare approaches

For this small difference, direct arithmetic is clearest. For a conditional rule, wrap the assignment in IF or use a conditional expression supported by your ABAP version. Avoid compressing a business rule into a clever expression if the named steps make it easier to review.

Practice

Use the provided target and available quantities. Assign their difference to result and display it with your selected output mechanism. The checker checks code fragments, not arithmetic execution.

Sources

Version note: Numeric conversions, expression syntax, and supported operators can differ by ABAP release and language version.

Developer practice · ABAP

Practice: calculate a top-up amount

The store wants 40 units and 27 are available. Calculate the difference in result; this exercise assumes availability is below the target.

Choose your ABAP environment

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