Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarative statemnts →  Data Types and Data Objects →  Declaring Data Objects 


Short Reference

Other versions: 7.31 | 7.40 | 7.54


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 additions READ-ONLY and BOXED, and the declaration of LOB handle structures are 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_one 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.

  PERFORM add_one. 

FORM add_one. 
  DATA    local  TYPE i VALUE 10. 
  STATICS static TYPE i VALUE 10. 
  local  = local  + 1. 
  static = static + 1. 
  WRITE: / local, static.