Ansicht
Dokumentation

ABENFINAL_INLINE - FINAL INLINE

ABENFINAL_INLINE - FINAL INLINE

General Material Data   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.
SAP E-Book

FINAL, Inline Declaration for Immutable Variables

... FINAL(var) ...

Effect

Declaration of an immutable variable. A declaration expression with the declaration operator FINAL in general works in the same way as an inline declaration with the declaration operator DATA and the same general rules apply.

While DATA declares a normal variable, FINAL declares a so-called immutable variable: The write position where the variable var is declared with FINAL is the only one, where a value can be assigned to that variable in the current context. In all other positions, any write access leads either to a syntax error or the uncatchable exception MOVE_TO_LIT_NOTALLOWED_NODATA.

The declaration operator FINAL can be used in the same declaration positions as the operator DATA with one exception: FINAL cannot be used behind OPEN CURSOR because usually there is always a second write access with CLOSE CURSOR in the same context..

Note

That there is only one write position for FINAL in a context does not mean that only one write access can be executed at runtime. For example, the declaration operator FINAL can be positioned inside a loop or it can be used after INTO in a LOOP statement. Then a value is assigned several times to var, but var cannot be changed in any other write position.

Immutable Variables

Example

Three immutable variables yesterday, result, and wa are declared inline with FINAL. They can be used at read positions but any attempt using them at write positions would lead to a syntax error or an exception.






Fill RESBD Structure from EBP Component Structure   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.

Length: 2569 Date: 20240512 Time: 072304     sap01-206 ( 55 ms )