Preserve the record and change only what changed
The dispatch is still the same delivery after packing: its identifier and package count must carry forward. Building a new structure from scratch with only status would leave those other fields initial.
Copy with BASE, then override
DATA(packed_dispatch) = VALUE ty_dispatch(
BASE dispatch
status = 'PACKED' ).
BASE dispatch seeds the new value with the existing structure; the named assignment overrides its status. The original dispatch remains unchanged. Without BASE, VALUE initializes components that are not assigned in the expression.
Use this when a copy-with-small-changes is clearer than several assignments. It is not a substitute for an explicit business transition: first check whether packing is valid, then construct the updated value. For a large mutable object, ordinary assignments or a focused method may communicate intent better.
Sources
Developer practice · ABAP
Practice: create a packed copy of a shipment
Keep the original dispatch unchanged, create a copy with status PACKED, and put the new status 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-509' status = 'READY' package_count = 2 ).
DATA(packed_dispatch) = VALUE ty_dispatch( BASE dispatch status = 'PACKED' ).
DATA(result) = packed_dispatch-status.
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.