LOCAL

LOCAL Syntax Diagram

Effect

Can only be used after the FORM statement.
Saves the current value of the field f when you enter the routine and restores it when you leave the routine.
You should not regard the LOCAL statement as a declaration. It only saves the value of f at the point where the form was called.
You can also use LOCAL for field symbols and formal parameters. With field symbols, it not only saves and restores the field reference created using ASSIGN, but also the contents of the field referenced when you enter the routine.
With formal parameters, please note that although changing the value of the formal parameter does not affect the actual parameter after you leave the routine (if you specified the formal parameter after LOCAL), the values of the formal and actual parameter within the routine are always identical.
This contrasts with the VALUE specification (see FORM ) where changing the passed field within the routine does not affect the value of the formal parameter.

Example

DATA: GD_LEVEL TYPE I VALUE 1. 
WRITE: / 'Initial value of GD_LEVEL: ', GD_LEVEL. 
PERFORM F1. 
 
FORM F1. 
LOCAL GD_LEVEL. 
  GD_LEVEL = GD_LEVEL + 1. 
  WRITE: / 'value of GD_LEVEL in FORM f1:', GD_LEVEL. 
  PERFORM F2. 
ENDFORM. 
 
FORM F2. 
LOCAL GD_LEVEL. 
  GD_LEVEL = GD_LEVEL + 1. 
  WRITE: / 'value of GD_LEVEL in FORM f2:', GD_LEVEL. 
ENDFORM.

Output:
Initial value of GD_LEVEL: 1
value of GD_LEVEL in FORM F1: 2
value of GD_LEVEL in FORM F2: 3