0% found this document useful (0 votes)
36 views2 pages

Visibility of ABAP Data Objects

Uploaded by

Debebook
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Visibility of ABAP Data Objects

Uploaded by

Debebook
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

The extent to which data objects are visible depends on the context.

The following rules apply for data objects that are defined using the DATA statement:

 If the DATA statement appears between FORM and ENDFORM, it defines a local
data object of a subroutine.
 If the DATA statement appears between FUNCTION and ENDFUNCTION, it
defines a local data object of a function module.
 In all other positions, the DATA statement defines a global data object, which is
visible in the entire program.
 If a global data object and a local data object have the same name, only the local data
object is visible within the modularization unit. In technical terms, it ignores the
identically named global data object.

Caution: Data objects in modules and event blocks are always global. If the DATA statement
appears between MODULE and ENDMODULE, the object you define is still a global data
object that is visible in the entire program. Likewise, data objects that you declare in an
ABAP event block are visible globally.

To avoid misunderstandings, SAP recommends that you declare such data at the start of the
program, and avoid declaring DATA statements completely in modules and event blocks.

The TABLES statement always creates data objects that are visible throughout the program.
Data objects that you create using the TABLES statement are always visible in the entire
program, even if the statement appears within a subroutine or function module.
If you use objects (instances of ABAP classes) in your application, the visibility of data is
determined in a different way.

Data objects that are defined in the declaration part of a class are called attributes.

For attributes, the visibility sections are as follows:

 Private attributes

Private attributes are visible only within the object or class. All the methods of the
object can read and change the data. External access to these attributes is possible
only when you use a suitably defined method.

 Public attributes

Public attributes are also visible and accessible outside of the object or class.

 Protected attributes

Protected attributes are visible within the object or class, and also to instances of any
subclasses.

If the DATA statement appears within METHOD..ENDMETHOD, it defines a local data


object in the method.

You might also like