SAP LOCAL ABAP Statements

Warning: Undefined variable $saptab in /customers/b/9/9/trailsap.com/httpd.www/abap-statements/index.php on line 46

Get Example source ABAP code based on a different SAP table
  

Warning: Undefined variable $prev in /customers/b/9/9/trailsap.com/httpd.www/abap-statements/index.php on line 62
Standard SAP Help for LOCAL

LOCAL

Short Reference
• LOCAL ABAP Statement

ABAP Syntax(Obsolete)LOCAL dobj.

What does it do? The statement LOCAL (not allowed 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 to the value in the buffer. If LOCAL is executed in a procedure for a data object more than once, only the first execution is taken into account.

All data objects possible in write positions can be specified for dobj. If dobj is an internal table, the procedure should not be called within a LOOP loop that processes 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 master program declared with DATA from unwanted changes during a procedure. Instead of using LOCAL, the global data of the master program should not be accessed in procedures.



Example ABAP Coding
When executing the following program section, the value
of the global variable text is buffered twice, in separate locations: once by specifying the name in subr1 and and a second time in subr2 by specifying the formal parameter para, to which text is passed by reference. After returning from subr2 , text once again has the value that is set in subr1, and after returning from subr1, text assumes the value set in the master program. DATA text TYPE string VALUE 'Global text'.

cl_demo_output=>write_text( text ).

PERFORM subr1.

cl_demo_output=>display_text( text ).

FORM subr1.
LOCAL text.
text = 'Text in subr1'.
cl_demo_output=>write_text( text ).
PERFORM subr2 USING text.
cl_demo_output=>write_text( text ).
ENDFORM.

FORM subr2 USING para TYPE string.
LOCAL para.
para = 'Text in subr2'.
cl_demo_output=>write_text( text ).
ENDFORM.

Return to menu