A type is a template; a structure is one delivery

The previous lesson described a dispatch’s shape. Now separate that reusable description from the data object that represents one actual delivery. This makes the distinction between what fields exist and what values this delivery currently has explicit.

Declare the variable from the type

TYPES: BEGIN OF ty_delivery,
         delivery_id TYPE string,
         status TYPE string,
       END OF ty_delivery.

DATA dispatch TYPE ty_delivery.
dispatch = VALUE ty_delivery( delivery_id = 'D-208' status = 'PICKING' ).

DATA dispatch TYPE ty_delivery creates the variable. Before values are assigned, its components contain their type-specific initial values. A structure based on a DDIC or CDS type is also possible when that shared shape is intended and available to the program.

Inline declarations can be useful when the type is already clear at the point of use, but named local types are easier to reuse across a method or several declarations. In ABAP Cloud, use only released global objects; a familiar type name is not proof that the object is permitted.

Follow the value

DATA(result) = dispatch-status.

The identifier result gets the same type as dispatch-status. This is a source fragment; the output statement used by a complete program depends on its execution context.

Sources

Developer practice · ABAP

Practice: create a delivery structure

Declare a variable with type ty_delivery, assign it values, and copy its status 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