Keep a decision’s input stable while you use it

Suppose one method records a dispatch decision and then passes its status to several checks. An accidental reassignment in the remaining method body could make those checks disagree. FINAL(...) declares an immutable variable: once initialized, the variable cannot be reassigned.

Capture the value once

FINAL(snapshot) = VALUE ty_snapshot(
  dispatch_id = 'D-1001'
  status = 'READY' ).
DATA(result) = snapshot-status.

Use immutability when a local value should stay fixed for the rest of its scope. It can make data flow easier to review, but it does not make the underlying business decision correct and is not a replacement for validation.

FINAL and other modern declaration features depend on the ABAP language version and release. Verify support in the target system, particularly on older classic landscapes. ABAP Cloud also requires any referenced global types to be released for the applicable use.

Sources

Developer practice · ABAP

Practice: capture a read-only status snapshot

Create a FINAL shipment snapshot with status READY and copy that status into 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