Like every programming language programs work with local data which reserves a memory space. In ABAP you can define local variables namely ABAP Data Objects specific to your program by referring to ABAP Data Types. With DATA command, you can define variables that is ABAP Data Objects, adding either TYPE or LIKE keywords and one of ABAP Data Types.
ABAP Data Types
ABAP Data Types can be one of Elementary Types(numeric,character,hexadecimal type), User-Defined Types(TYPES keyword), Data Dictionary Types(Data Element,Structure,Table Type), Reference Types( used with TYPE REF TO ).
This figure illustrates a summary of Data Types.
- Elementary Types with fixed and variable length
You can use predefined types to define local data types and objects in your program. Fixed length types can be divided into three categories :numeric,character and hexadecimal types. Following table shows fixed length types and their attributes.
If your variables length and memory requirement could change in run time then you should use variable length types which are ‘string’ for character strings and ‘xstring’ for byte strings.
- User-Defined Data Types
Local types in ABAP programs are under this category.You can define your own custom type with TYPES keyword.
- Data Dictionary Types
The ABAP Dictionary allows you to define global data types via SE11. These types are Data Elements,Structures,Table Types. However you can also use Database Tables as Data Types. Next chapter will be completely reserved to Data Dictionary Types.
- Reference Types
You can define a reference type in the ABAP Dictionary by specifying an existing class(TYPE REF TO class), an interface(TYPE REF TO interface), or using a generic reference to objects (REF TO OBJECT) or data (REF TO DATA).
ABAP Data Objects
Data Objects is an instance of the related Data Type and reserves memory space by ABAP program in the amount of the type specified. Data Objects
could be created in following two forms.
- Anonymously as a reference field with CREATE DATA keyword
- As Named Data Object with following keywords
Declaration of variables and constants in every context:
Declaration of static attributes in classes:
Declaration of static variables in procedures:
Declaration of interface work areas:
Except defining your own Data Objects SAP provides a couple of Predefined Data Objects in an ABAP program run time environment. You do not have to declare this Data Objects explicitly.These are
- Constant ‘space’
This predefined Data Object is same with ‘ ‘ character.
- Self-reference ‘me’
It is an object reference variable and can be used in all instance methods of the class. The type of this variable is the class which instance method is implemented
- Structure ‘scree
In dialog module programs you can access this structure whose elements correspond to screen elements.
- System Fields in Structure SY
This structure contains fields about the current state of the program an updated by ABAP kernel. It’s type is the ABAP Dictionary data type SYST.