LOCAL f.
This statement is not allowed in an ABAP Objects context.
See Cannot Use the LOCAL statement.
The LOCAL statement can only be used after FORM
and
FUNCTION.
Saves the current value of the specified 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.
DATA text TYPE string VALUE `Global text`.
WRITE / text.
PERFORM subr1.
WRITE / text.
FORM subr1.
LOCAL text.
text = `Text in subr1`.
WRITE
/ text.
PERFORM subr2 USING text.
WRITE / text.
ENDFORM.
FORM
subr2 USING para TYPE string.
LOCAL para.
para = `Text in subr2`.
WRITE / text.
ENDFORM.
You cannot use the LOCAL statement with internal tables
if the code before and after the statement has been called within a
LOOP performed on an internal table.
Within a
loop performed on an internal table, the MOVE statement
is carried out by the LOCAL statement and the table is
then copied back. This destroys the LOOP administration for the table.
Global Data from the Main Program