Start with a record, not a pile of unrelated variables
A dispatch screen needs an identifier, a status, and a package count. Declaring each field separately makes it easy to accidentally mix values from different deliveries. A structured type gives one dispatch a named, reusable shape.
Describe the shape with TYPES
TYPES: BEGIN OF ty_dispatch,
dispatch_id TYPE string,
status TYPE string,
package_count TYPE i,
END OF ty_dispatch.
TYPES defines a type; it does not create a populated dispatch. The components can have different elementary types and are accessed by name later. Choose names and types that reflect the values your own business rule needs.
Create a value using the type
DATA(dispatch) = VALUE ty_dispatch(
dispatch_id = 'D-104'
status = 'READY'
package_count = 3 ).
This is a fictional local type, not an SAP-delivered table or API. In a real project, an existing DDIC or CDS type may be appropriate, but ABAP Cloud code must use repository objects released for its language version. Don’t create a duplicate type without checking the project’s existing model.
Classic ABAP and ABAP Cloud use the same structure ideas here; the surrounding program entry point and available repository types can differ. The snippets show source fragments, not a complete executable program.
When to use it
Use a local TYPES declaration when a small record is specific to one program or class. If several components of the application need the same public shape, a released shared type may be more suitable.
Sources
Developer practice · ABAP
Practice: declare fields for a dispatch record
Define a local structured type for one dispatch, create a sample record, and put its identifier in result.
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
TYPES: BEGIN OF ty_dispatch,
dispatch_id TYPE string,
status TYPE string,
package_count TYPE i,
END OF ty_dispatch.
DATA(dispatch) = VALUE ty_dispatch( dispatch_id = 'D-104' status = 'READY' package_count = 3 ).
DATA(result) = dispatch-dispatch_id.
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.