Last Updated on August 10, 2022 by admin
Data types and Data Objects in SAP ABAP
All ABAP programs use data to work on, which are characterized by length, name, and data type. Every data in an ABAP program has these attributes. Data type describes the content of the program. Data objects on the other hand are instances of an abstract data type. In SAP both data objects and data types have separate namespaces.
ABAP DATA TYPES
ABAP Data types can be divided into elementary, reference, and complex types.
1. Elementary Types: – They are data types of fixed or variable length that are not made up of other data types. In variable data types, the memory space used by the data objects changes dynamically during runtime and their definitions can be altered later. This is not so with fixed-length data types.
#Predefined or User-Defined Elementary Data Types: – In predefined data types, you are allowed to define elementary data types on your own in ABAP by making use of the TYPES statement. You base these on the predefined data types. You can define your own technical attributes.
2. Reference Types: – These data types describe reference variables, which are data objects that have references in them. Reference variables are components of a complex data object like structures or internal tables.
3. Complex Data Types: – Complex data types are those that are made up of other data types. They are of two types – structured types and table types.
-
- Nested structures contain one or more other structures as components, unlike non-nested structures.
- Flat structures contain only elementary data types of fixed length.
- Deep structures contain at least one internal table, reference type, or string as a component. Structures : – Structures are used to group together work areas that logically belong together. The various elements of a structure may be of any type or can be a different structure or internal table as well. Structures may be classified as Nested and non-nested structures or Flat and deep structures.
- Internal Tables: – Internal tables may contain a series of lines that are all of the same data types. Internal tables have a line type, which is used to identify table rows using a unique or non-unique key, and a table type that determines just how individual table entries, whether non-sorted, sorted index tables or hash tables are accessed.
Data Objects: –
An ABAP data object is a part of the repository which has content that can be addressed and interpreted by the program. Before using them, all data objects must first be declared in the ABAP program, and they exist only as long as the program is being executed. Which means that Data objects are not persistent?
How do you declare Data Objects?
You can declare data objects in the declaration part of the ABAP program. The declaration should include the data type of the object, and any missing technical attributes. The declaration happens before the program is executed, and the technical attributes are made use of just while the program is running.
The various data objects in ABAP are:
1. Literals: – Literals exist in the program source code and have fixed technical attributes such as field length, number of decimal places, and data type. But literals are nameless.
2. Named Data Objects: – They are data objects that have a name using which you may address the ABAP program. They include text symbols, constants, and variables.
# Text symbols are nothing but pointers to texts present in the text pool.
#Variables are data objects which have contents that may be changed in an ABAP program using program statements. To declare variables, you should use statements such as DATA, CLASS-DATA, STATICS, PARAMETERS, SELECT-OPTIONS, and RANGES.
#Constants are data objects whose contents cannot be changed.
3. System-Defined Data Objects: –
System-defined data objects are available at run-time always and don’t have to be declared explicitly.
4. Interface Work Areas: – Interface work areas work as interfaces between programs, screens, and logical databases and are declared with statements such as TABLES and NODES.
5. Objects: – They are anonymous data objects that are nameless and declared using CREATE OBJECT command.