SAP LOCAL ABAP Statements



Get Example source ABAP code based on a different SAP table
  


ID LOCAL
• LOCAL ABAP Statement

LOCAL
Short Reference

ABAP_SYNTAX_OBS
LOCAL dobj.

What does it do?
The statement LOCAL, which is forbidden in classes, saves the current content of a data object dobj in an internal buffer. It can be used only in subroutines or function modules. At the end of the procedure, the data object dobj is reassigned the value in the buffer. If LOCAL is executed in a procedure for a data object more than once, all executions are ignored except the first one.
All data objects possible in write positions can be specified for dobj. If dobj is an internal table, the procedure must not be called within a LOOP loop across the table.
Modifiable formal parameters of the procedure, field symbols, or dereferenced data references are also possible after LOCAL. If formal parameters are specified, the assigned actual parameter is set to the value in the buffer at the end of the procedure. For field symbols, the field reference and the content of the referenced fields are saved.



Latest notes:

The statement LOCAL is used, in particular, to protect global variables of the compilation unit declared with DATA from unwanted changes during a procedure. Instead of using LOCAL, the global data of the compilation unit should not be accessed in procedures.
ABAP_HINT_END



Example ABAP Coding

When the following program section is executed, the value of the global variable text is buffered twice, once by specifying the name in subr1 and a second time in subr2 by specifying the formal parameter para, to which text is passed by reference. After returning from subr2, text has the value that is set in subr1 again, and after returning from subr1, text has the value set in the compilation unit.
ABEXA 00382
ABAP_EXAMPLE_END

Return to menu