Construct a record where you need it

Assigning several components one by one is valid, but it can spread one logical setup across many statements. VALUE constructs a structure from its type and named component values in one expression.

Name the components explicitly

DATA(dispatch) = VALUE ty_dispatch(
  dispatch_id = 'D-412'
  status = 'READY'
  package_count = 4 ).

The target type can be written before the parentheses, as above. If the type is unambiguous from the receiving variable, VALUE #( ... ) lets ABAP infer it from context. Avoid using # when the context is not obvious to a reader.

Components you omit are initialized; they do not inherit values from some previously used structure. This is useful for safe construction, but be deliberate when a missing value has business meaning. A constructor expression improves concision, not validation of business rules.

The syntax is supported in modern ABAP releases. Older classic systems may not support every constructor-expression feature used in newer examples. Check the target system’s ABAP Keyword Documentation before adopting it.

Sources

Developer practice · ABAP

Practice: initialize a complete dispatch record

Use VALUE to create a record with its ID, status, and package count, then store its status in 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