A type is a promise about the value

A stock count of 18 units is not the same kind of value as a label like A-14 or a reorder threshold like 20.50. Choosing an appropriate ABAP type helps prevent confusing text with arithmetic.

Start with the shape of the data

DATA(bin_code) = 'A-14'.
DATA quantity TYPE i VALUE 18.
DATA reorder_threshold TYPE p LENGTH 8 DECIMALS 2 VALUE '20.50'.

i is an integer type, useful for whole-number counts in a small example. Packed numbers (p) can represent decimal quantities with a declared number of decimal places. Character-like values are appropriate for labels and identifiers.

TYPES: BEGIN OF ty_bin,
         bin_code TYPE string,
         quantity TYPE i,
       END OF ty_bin.

DATA(bin) = VALUE ty_bin( bin_code = 'A-14' quantity = 18 ).

A structure groups related fields into one meaningful record. It does not store a row in a database by itself; it is a value in your program.

Avoid guessing types from appearance

'0018' can be text when leading zeros are meaningful, even though it looks numeric. A quantity should generally be numeric so comparisons and calculations behave as intended. Real SAP applications often use data elements and domain-specific types; use the type defined by the business object or API rather than inventing a replacement.

Practice

Create a whole-number quantity and decimal threshold. Build a short message in result, then add the output statement for your selected program context.

Version note: Type availability and exact syntax vary by ABAP release/language version. Verify in your system.

Sources

Developer practice · ABAP

Practice: model a warehouse bin

Define a whole-number quantity and a decimal reorder threshold, then assign a readable bin label to result.

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