STATICS stat [options].
Declaration of static variables stat. The statement STATICS for declaring static variables can only be used in subroutines, function modules, and static methods.
The naming conventions apply to the stat name. The syntax for the additions options is used for declaring normal variables as with the statement DATA. Only the addition READ-ONLY is not possible.
As with normal local variables, one with STATICS declared variables can only be viewed in its
procedure. The life of a variable with
STATICS declared variables corresponds to the same one of a global data object. The variable is generated once when loading the
framework program in the internal mode, and the contents set to the
start value of the
VALUE addition. Calling and ending the procedure have no effect on the life and content.
In instance methods, the statement STATICS is not allowed. Instead, you can use
static attributes of the class, declared with CLASS-DATA.
The subroutine add_1 gets the same result for the variable local for each call as this is instanced again each time. The static variable static is already available and its value increased by 1 during each call.
DO 10 TIMES.
DATA local TYPE i VALUE 10.
STATICS static TYPE i VALUE 10.
local = local + 1.
static = static + 1.
WRITE: / local, static.