Write up on Tech Geek History: SAP ABAP-Data Dictionary

Literature Review

(Peer to Peer Journal Knowledge Based Article)

SAP is a proprietary product of the German company SAP AG. SAP was found by five ex IBM employees who had been working in IBM enterprise-wide software division. The name of the employees who found the company was as follows:

They initially started the company as a private partnership under the German System in the year 1972. Their first client was a German chemical company where they developed mainframe programs for payroll and accounting processes. As IBM used to store data on punch cards mechanically they stored it locally and thus they called their software real-time software. [In the earlier 19th-century punch cards were used also called punched cards, IBM cards, or Hollerith cards. In the 19th century, these punch cards were used for controlling textile machines, and then gradually in the 20th century, the punch cards were used as in-unit recording machines for input, processing, and data storage. The punched cards often prepared using keypunch machines as the primary medium for both computer programs and data in the early digital computers.]

Their first commercial product was launched in the year 1973 and was based on the tier system like the one-tier system was called SAP R1 and the two-tier system was called SAP R2 and the three-tier system was called SAP R3.

SAP is basically divided into three layers and they are as follows:

1. Presentation Layer.
2. Application Layer.
3. Storage layer.

SAP R1 had all the above layers in a single tier. This was sufficient when the amount of computations and data is low. As the amount of computations increased the R1 system became slow and they then introduced two tier system. Here in the two tier system the presentation layer is in one tier and the other two layers on the second tier. Depending on the amount of load and computations a single tier out of the two tiers can be allocated to the one of the layers. Then as the amount of computations and data increased and also the SAP software evolved the 2 tier system was also getting slow.

Then SAP system started using the 3 tier system where each layer was placed in individual tier and the approach of distributed and effecting processing was used, thus following the trend from mainframe computing to client/server architectures.

The three tier architecture is as follows:

SAP R/1 started being a financial software. Subsequently, the current MM module was added including purchasing, inventory management, and invoice verification. SAP R/1 was born with two big innovations:

  • Being a standard software that could be used for different customers rather than tailoring a solution for each of them. In 1972, there did not exist in the market any software for standardized business processes that could be adopted by many industries.
  • Real-time processing. Before SAP R/1, the information processed by the user was sent from the computer and recorded in punch cards. Subsequently, this information was moved from the punch cards to the database through nightly jobs. With SAP R/1, the software was directly connected to the database. Therefore, the data could be processed in real time.

Over the years, SAP R/1 evolved to include other new modules such as Assets Accounting. Finally, in 1979, SAP launched what it is considered their first ERP, SAP R/2. It supported and integrated major business functions in real time. Additionally it handled multi-country and multi-currency implementations. With the innovation of the direct connection to the database, the finance department, for instance, didn’t have to wait until the following day to update the material movements in accounting. Eliminating the need that the material movements were reported by people from the warehouse. Real-time processing was a big revolution.

SAP R/3 – Real-time in desktops

Launched in 1991, SAP R/3 was another revolutionary product. In fact, SAP R/3 was the product that shot SAP to stardom. The application was rewritten to exploit the power of a layered, three-tier architecture approach. You can read more details about the architecture of the SAP installation in this post. SAP R/2 customers were required to migrate to SAP R/3. This was not an update of the product, it was a whole new product.

Let’s contextualize the birth of SAP R/3:

  • We are talking about the early years of the graphical user interfaces (GUI). In 1983 Apple launched Lisa, the first computer with a graphical user interface. Windows introduced their operating system Windows at the end of 1985.
  • The internet was born in the 1960s. Initially it was only used by the United States Department of Defense. The early 1990s is marked as the beginning of the transition to the modern Internet. The internet was not used in company networks before this time.

Now let’s have a look to the innovations introduced with SAP R/3:

  • Adopting client-server concept. This was seen as innovative for an ERP product. From SAP R/3, the installation of the applications was done in the server (application layer). The end-user desktops (clients) were able to communicate to the application layer (write and read information). In the client-server architecture, computers are linked through a network, that was an innovation in the 1990s.

Image: Client – Server concept

  • Uniform graphical interface. The introduction of SAP GUI brought about the end of the mono-chromatic, text-based, messy green screens and the start of a new graphical interface. This improved the end user experience. Despite the fact that the Windows Operating System was GUI based, in those years, a significant number of applications running on these operating systems had no graphical user interface (GUI).

SAP Database’s Background

a) Evolution of Databases:

a) Initially limited to flat-file systems.

b) Evolved into relational and object-relational systems.

c) Each type has specific use cases.

b) Early Database Systems:

a) Originated in 1968 as file-based systems.

b) Benefits of SAP included ordered data and convenient storage.

c) Limited by the technology of the time.

d) Allowed data access sequentially, randomly, or by indexing.

c) SAP Database Management System (DBMS):

a) Known for its platform-independent nature.

b) Combines features of Oracle and Informix databases.

c) SAP Modules can be extended like Oracle.

d) Possesses an advanced database engine similar to Informix.

d) Programming Languages and Databases:

a) SAP Database often requires programming language support.

b) Modern languages like Python and Java are commonly used today.

c) Early SQL usage involved third-generation languages like COBOL and BASIC, which predated C.

What are the Different Types of SAP Databases?

There are several types of SAP Databases, all of which we will explore in detail below:

1) Network Database

A Network Database consists of multiple member files or records linked to multiple owner files and vice versa. A Network Database provides multiple owners with various data access paths. The Database can be imagined as an upside-down tree, where the member information represents the branches leading to the owner at the bottom – and every fragment of data is eventually connected to the main data.

Network databases allow more natural modelling of relationships between records and entities. It is also more flexible and accessible, which results in faster search, navigation, and access to data. An example of a network database is SAP HANA, which consists of components that facilitate system communication with the help of networking channels. For a comprehensive understanding of how to optimise these features, a SAP S/4HANA Guide can provide valuable insights into leveraging the full potential of SAP HANA for improved data management.

2) Open-source Database

An Open-source Database has a code that can be accessed publicly and is free to download, re-use and modify. This Database stores important information that organisations control. Users can use the Database to create their systems in accordance with their business requirements and modify the source code according to their preferences.

Users of Open-source Databases do not require any payment for using the code, unlike Commercial Databases, where users pay to use larger datasets or access additional features. These Databases are cost-effective and flexible to use. An example of such an Open-source Database is SAP MaxDB.

3) Object-oriented Database

Object-oriented Database Management Systems (OODBMS) make code easier to manage as they help integrate Database functionality into Object-oriented Programming languages. Such Object-oriented Databases incorporate Relational Database principles. An OODBMS is known to use the following:

1) Objects: Objects are building blocks of classes with either built-in or user-defined types.

2) Class: A class determines the behaviour of an object.

3) Methods: The methods of a class determine its behaviour.

4) Pointer: A pointer helps access elements of an object Database and establish relationships among objects.

Using Object-oriented Databases has several advantages. The advantages include transparency, easy retrieval, seamless integration, and persistent storage. Users are allowed to store all the properties of data objects in the Database, and the Database continues to store them after the program terminates. Upon restarting the program, the Database can retrieve an object with the specified properties. This facilitates the storage and retrieval of complex data objects transparently. For a deeper insight into these capabilities.

4) Cloud Database

A Cloud Database can be defined as a Database hosted on a Cloud server which can be accessed through a web interface or Applicating Programming Interface (API). Much like traditional Databases, these Cloud Databases provide several functionalities.

However, they facilitate secure data storage without the organization investing in expensive hardware. Cloud Databases are known to support Relational Databases such as Structure Query Language (SQL) and NoSQL Databases such as MongoDB. Their common features include the following:

1) Scalability: This feature helps businesses easily manage large volumes of data without affecting the overall performance.

2) Elasticity: This feature means businesses can increase or decrease the number of data nodes per their specific requirement.

3) Security: This feature assures that the data stored in the Cloud is safe from any possible theft or unauthorised data breaches.

4) Redundancy: This feature means businesses can ensure their data despite server failures due to regular backups.

5) Manageability: This final feature means that IT teams can conveniently perform several administrative operations on the Database.

5) NoSQL Databases

NoSQL refers to all the Database technologies which do not use Simple Query Languages as the primary language while accessing data. These kinds of Databases are different from Relational Databases, as they do not require a predefined schema – a feature that makes them great for semi structured or unstructured data. These Databases are often referred to as Non-relational Databases. Some of its features include:

1) Modifiability: Programmers can modify the NoSQL Database in real time.

2) Integrity: Modifying data in this Database does not affect the applications.

3) Versatility: This Database can benefit from technologies like Apache Cassandra, MongoDB, CouchDB, and CouchBase.

What are Some Examples of SAP Databases?

Now that we have discussed what an SAP Database is as well as the types of SAP Databases, we will look at a few examples of SAP Databases now.

1) SAP HANA

SAP High-Performance Analytic Appliance (HANA) is a multi-model Database that facilitates using multiple data models using a single back-end. As with traditional Databases, an SAP HANA Database stores data in its memory rather than on a disk, which facilitates faster data access than Disk or Solid-State Drives (SSD).

The Database supports the search, analytics and integration of structured and unstructured data. It also helps develop smart, insight-driven applications through real-time data, in-memory computing and machine learning. One can access these features both on the Cloud and on-premises.

2) SAP IQ

SAP Intelligent Query (IQ) is a column-based, Relational Database system that facilitates Business Intelligence (BI), data warehousing and data marts. The two principal components of SAP IQ are clients and servers, both of which provide their own features to the Database. The client components provide connectivity, SQL command pursuing, authentication, monitoring and administration via the web. The server components provide features such as column stores, query engines, parallel data loading engines, Database encryption, authorisation and scalability.

3) SAP ASE

SAP Adaptive Server Enterprise (ASE) is a Relational Database server known to handle large volumes of data and users simultaneously. This feature of the SAP ASE Database ensures reliability, accessibility and performance across multiple industries. It also facilitates the processing of mission-critical transactions while maintaining high levels of performance and availability.

These Databases also possess flexible SQL systems that decrease risk and improve agility. The SAP ASE is also resource-efficient, meaning that it helps organisations lower their operational costs.

4) Oracle Runtime Database

Oracle Runtime Database is multi-platform document store which allows you to access data regardless of your device type and its Operating System (OS). This allows clients to work using different programming languages like Android, JavaScript, and iOS while using an instance of a Realtime Database.

Oracle Runtime Database is accessible on both mobile and website platforms. Additionally, it ensures seamless updates with the latest data control features, making it a valuable tool for database management.

5) SAP MaxDB

SAP MaxDB Database is known for the consistent structure of its data. This is possible due to the application data and the metadata within the metadata having a unique name, allowing for consistent formatting.

6) Microsoft SQL Server

Microsoft SQL Server is one of the leading figures in the domain of Databases It is a Relational Database Management tool which is capable of supporting multiple applications. The usage of this server includes transaction, processing, and analysis.

7) IBM Db2

IBM Db2 is a collection of products, which is frequently used for Database Management. Db2 is one of the most popular AI- powered tools in this Database, capable of helping with both structured and unstructured Data Management. The Db2 range of tolls simplify the data handling process, by allowing you to take advantage of AI.

Conclusion

SAP Database stands as a cornerstone for businesses striving to harness the power of data. Its sophisticated architecture and practical applications enable companies to manage vast amounts of information efficiently and access critical data instantly. By mastering this database, businesses can drive innovation, enhance decision-making, and maintain a competitive edge in today’s fast-paced market.

https://pl3group.com/en/sap-the-genesis

 ABAP Dictionary

Purpose

You use the ABAP Dictionary to create and manage data definitions (metadata). The ABAP Dictionary permits a central description of all the data used in the system without redundancies. New or modified information is automatically provided for all the system components. This ensures data integrity, data consistency and data security.

The ABAP Dictionary supports the definition of user-defined types (data elements, structures and table types). You can create the corresponding objects (tables or views) in the underlying relational database using these data definitions. The ABAP Dictionary describes the logical structure of the objects used in application development and shows how they are mapped to the underlying relational database in tables or views.

The ABAP Dictionary also provides standard functions for editing fields on the screen, for example for assigning input help to a screen field.

Integration

The ABAP Dictionary is completely integrated in the ABAP Workbench. The SAP system works interpretatively, permitting the ABAP Dictionary to be actively integrated in the development environment. Instead of the original objects, the interpreters see only internal representations of these objects.

These internal representations are adjusted automatically when the system finds that changes have been made in the ABAP Dictionary. This ensures that the screen and ABAP interpreters, input help, database interface, and development tools always access current data.

When you work on development projects, objects of the ABAP Dictionary can be changed any number of times before being activated and made available to the operative components of the system. Objects can have both an active and an inactive version in the ABAP Dictionary at the same time.

Inactive ABAP Dictionary objects have no effect on the runtime system (ABAP processor, database interface). This permits greater changes to several objects without impairing the executability of the system. The objects can be activated together only when they all have been changed.

ABAP Data Dictionary is the Central source of data of SAP system OR ABAP dictionary is the central core component which supports the creation and management of all the data definitions used in the system. ABAP Dictionary is completely integrated with the ABAP development workbench and is active in the development and run-time environments of the SAP system. This ensures that any changes made in the data definitions results in subsequent changes in the all related ABAP programs, function modules, menu, screen painter or any other application where it has been used.  

The major object types in the Data Dictionary are Database tables, views, data type (data elements, structures, table types), domains, search helps and lock objects. The user can create, modify or delete the data definitions using the above objects.

The SAP R/3 system comes loaded with the basic business functionality usage data objects. However if you want you can create your own data objects as well. These are called as user defined types. But before creating any of user defined data objects ensure that the one you are creating is already provide by SAP or else you might end up duplicating the object and hence inefficiently utilizing SAP’s features.

A brief Introduction ABAP Dictionary Objects

  1.  Database Table- A table is multi dimensional matrix which is used to store data. There are 3 layers of data description of ABAP data dictionary which is to isolate the end users and even developers from the underlying database management system. The three layers of data description are:-
  •      External Layer – This is the end user view of the database. It mainly consists of how the user sees and interacts with the data. 
  •  ABAP Layer – The ABAP/4 layer describes the data formats used by the ABAP/4 processor. This is the developer’s/programmer’s view of the database. 
  • Database Layer – It is the DBA view of database. It describes the data formats used in the database.

In R/3 database there are two types of tables:- A. Client Dependent  B. Client Independent

  • Client Dependent- Database Tables with their first field name as ‘MANDT’ and type as ‘CLNT’ are client dependent tables.
  • Client Independent- All the tables with the first field name is not “MANDT’ are client Independent, or in other words, all the tables which are not client dependent are client Independent.

The data in client dependent table is stored and retrieved based on the client number of the user. This is helpful in the scenario where we want developers and testers data to be different. 

Based on SAP R/3 system there are three types of tables: – A. Transparent Table, B. Pool table C. Cluster Table.

A-Transparent Table: – These tables have the same structure both in the ABAP dictionary as well as in the underlying Database.  It means that there is a one to one mapping between the two and the both the dictionary table and database table shares the same name, number of rows and columns. As we create a Transparent table in the Data Dictionary a similar structure table is created in the underlying database as well.

Transparent tables are mainly used to store application data which is basically the master data or transactional data of table. And mostly, transparent tables are the only one you will create as pooled and cluster tables are not used to store transaction data.

E.g.:- BKPF, VBAK, VBAP, KNA1, COEP etc

B- Pool Table: – A pool table means a pool of tables of the data dictionary representing a single database table. There is a many to one relationship between the data dictionary and database and the names of table in ABAP dictionary are different from the one in database.  Pool tables are used to store system data and system configuration. A Pool table is stored along with other pooled tables in database as table pool.

E.g. of Pool Table: – M_MTVMA, M_MTVMB


C- Cluster Table: – Cluster Tables are similar as the pool tables while the only difference between the two is that all the pool table stored in table pool does not need to have any foreign key relationship but in the case of cluster table it are must. Cluster tables can be used to store control data.  They can also be used to store temporary data or texts, such as documentation.
E.g.  Of cluster table BSEC, BSET, BSEG.


 2.VIEW: – A VIEW in SAP is same as in other programming languages. A VIEW is a table with no contents. A view could also be representation of data from 2 or more logically related tables combined using joins or any other database operations. A View is mainly used to either display data from two or more tables or to project only selected fields of tables. We can use a view either separately (through SE11) or we can use it in any report we create (SE38) There are four types of Views in SAP: –


A.      Database View– A database view is the one which we create to display logically related data distributed among various tables.


B.      Projection view– A projection view is the one which we create to display only selected fields of a table. You cannot define any select conditions or joins in the projection view.


C.      Maintenance View– Maintenance like database view displays application data from multiple tables but the tables in maintenance view must be connected through foreign key relation.


D.      Help View– Help views are created to provide Input Help(F4) for any field in selection screen. Please Note that we can only use Help view if we need to retrieve data from tables combining them using Outer Join.


3.       Domain: – Domain defines the technical attributes of a field such as the data type, length and value range of field. For e.g. A Domain ‘ID’ is of data type ‘Integer’, length ‘4’ and value range 1 to 9999.  


4.       Data Elements: – Data elements define the semantic characteristics of a field. A data element contains field labels and Documentation (F1) of the field. A data element consists of a domain and the short description about the domain for which it is defined.

For e.g. A data element ‘Employee Id’ for employee table has a domain ‘ID’ defined and the short text defined as ‘Employee ID for employee of XYZ company’.


5.       Structure: – Structures are complex data types composed of multiple fields including data elements, table types or other structures. Structures are mainly used when we want to retrieve the records from database tables and alter them for modifying database or for displaying it to users.


6.       TYPE GROUPS – Suppose, we require a group of data types or 2 or more structures or both for more than one programs. Then instead of declaring them individually I each program we can create a type pool or type group of them. Type groups allows us to define the data types or structures in data dictionary.

Significant Study

SAP ABAP focuses on Data Types:

Data Objects in ABAP

A data object in an ABAP program represents a reserved section of the program memory.ABAP knows three types of data objects: Variables, Constants, and Literals

Variables

A variable is a data object with content that can change during runtime. A variable is identified by a name. The name is also used to address the data object at runtime. The starting value of an ABAP variables is always well-defined.

Constants

Constants are similar to variables. But in contrast to variables the value is hard coded in the source code and must not change during runtime. Like variables, constants have a name by which they can be re-used.

Literals

The value of literals is also hard-coded in the source code. In contrast to constants, literals don’t have a name. Because of that you cannot reuse a literal. Only use literals to specify the values for constants and the starting values for variables.

ABAP data objects are always typed: Every data object is based on a data type which determines the kind of information they can contain. The data type of an ABAP data object stays the same throughout a program execution.

Declaration of Variables

A variable in an ABAP program is declared with keyword DATA.

A DATA statement consists of three parts. Let’s look at each part in more detail

DATA

Keyword DATA is followed by the name of the variable. The name of a variable may be up to 30 characters long. It may contain the characters A-Z, the digits 0-9, and the underscore character. The name must begin with a letter or an underscore.

TYPE

The type of the variable is specified after addition TYPE. In the example, built-in types i (for integer numbers) and string (character string with variable length) are used.

VALUE

Addition VALUE is optional and you can use it to specify a start value for the variable. If VALUE is missing, the variable is created with an initial value that depends on the technical type of the variable.

Sources of ABAP Data Types

ABAP offers the following sources of Data Types:

ABAP Built-in

ABAP has a set of 13 predefined data types for simple numeric, char-like, and binary data objects.

TYPES Statement

Statement TYPES allows you to define data types and reuse them in different places, depending on the location of the definition.

ABAP Dictionary

The ABAP Dictionary is a part of the ABAP Repository. Among other things, it manages global data types which are available throughout the system. ABAP Dictionary types not only define technical properties, they add semantic information, for example, labels. ABAP Dictionary types are particularly useful when implementing user interfaces

ABAP Data Types and Variables:

In SAP’s ABAP (Advanced Business Application Programming), data types and variables are fundamental concepts that are used to manage and manipulate data within programs. Understanding these concepts is essential for ABAP developers. Here’s an overview of ABAP data types and variables:

1. ABAP Data Types:

ABAP provides various data types to represent different kinds of data. These data types can be categorized into several groups:

1. Elementary Data Types: These are basic data types that represent single values, such as numbers, characters, and dates.

  • I for integer
  • F for floating-point numbers
  • C for characters
  • D for dates
  • T for time

2. Complex Data Types: Complex data types represent structured data, such as tables, structures, and internal tables.

  • DATA for defining variables of a specified data type.
  • TABLE for defining internal tables.
  • STRUCTURE for defining structures.
  • TYPE for creating user-defined data types.

3. Reference Data Types: These data types are used to store references to objects in memory.

  • REF TO for references to data objects.

4. Special Data Types: These data types represent special values or flags.

  • X for hexadecimal values (used for binary data).
  • STRING for character strings.

5. Logical Data Types: These data types are used for boolean values.

  • ABAP_BOOL for boolean data type.

2. Variables in ABAP:

Variables in ABAP are used to store data of different types. Variables must be declared before use. ABAP supports the declaration of variables with various data types, including elementary, complex, and reference types.

1. Variable Declaration:

  • Variables are declared using the DATA statement. 

2. Variable Initialization:

  • Variables can be initialized at the time of declaration or later in the program.
  • Example:

3. Data Type Declaration:

  • ABAP allows you to declare variables based on predefined data types or user-defined types.
  • Example:
DATA lv_date TYPE d.
DATA lt_customers TYPE TABLE OF zcustomer.
       Copy to Clipboard

4. Constants:

Constants are variables whose values do not change during program execution.

  • Constants are declared using the CONSTANTS statement.
  • Example:

5. Scope of Variables:

  • Variables can have different scopes, such as local variables (within a subroutine or method), global variables (visible throughout the program), or instance variables (associated with an object in object-oriented ABAP).

3. Type Casting:

ABAP allows type casting or conversion between compatible data types using appropriate conversion functions and operators. Type casting ensures that data is used correctly in operations and assignments.

  • Example of type casting:
DATA lv_number TYPE i VALUE 42.
DATA lv_string TYPE string.

lv_string = lv_number. “Implicit conversion to string
       Copy to Clipboard

What are Data Types?

  • Think about the different kinds of data we have – characters, text, numbers, and so on.
  • For a computer to perform functions on data, it is a much easier process if it falls under a pre-defined category.
  • Declaring a type for the data that we have speeds up execution considerably, and also reduces the time identifying data that would have otherwise been spent on producing useful output for the code.

Data Types in ABAP

In ABAP, we have several types of fixed as well as variable data types, as follows:

TYPEKEYWORDDESCRIPTION
Byte FieldXByte number in hexadecimal – e.g. 2B, 511, DC, etc.
Text FieldCAny kind of alphanumeric or special character – e.g. ‘c’
IntegerIAny kind of number e.g. 24, 1, -3478
Floating PointFNumbers with decimal point – e.g. 3.14, 2.0
Packed NumberPNumber defined by parameters ‘length’ and ‘decimal’ places – e.g. 100000000.00
StringSTRINGA series of alphanumeric and special characters – “Data Flair”, “SAP #2”, “ABAP123”

Complex and Reference Data Types in ABAP

  • There are also complex data types in ABAP.
  • Complex types are for structures (object made of components stored one after the other in memory) and tables (a 2D structure of rows and columns in which data is stored sequentially).
  • For structure types, the primary data types as well as nested structures may be grouped together.
  • When these primary types are grouped together, the entire structure can be accessed as one or the individual elements can be retrieved as well – this is known as internal tables in ABAP.

Now let’s see with what parameters these internal tables can be described –

PARAMETERDESCRIPTION
Line/rowRows, or the horizontal lines of a table can be of type  elementary, complex or reference.
KeyKeys are unique identifiers of table rows, and are usually of elementary type.
Access methodAccess methods are modifiers that basically declare how the individual table rows or cells can be authorised for access

Reference types are the data types used to refer to instances of class, interface and run-time data items. 

Here’s a sample program based on Data Types in ABAP –

EPORT ZR_SS_DATAFLAIR_SAMPLE_001.

DATA text_line TYPE C LENGTH 40.

text_line = ‘Data Flair SAP ABAP Tutorial’.

Write text_line.

DATA text_string TYPE STRING.

text_string = ‘Awesome Tutorial on Data Types by Data Flair’.

Write / text_string.

DATA sample_int TYPE I.

sample_int = -1234.

Write / sample_int.

DATA sample_byte TYPE X.

sample_byte = ‘FF’.

Write / sample_byte.

DATA sample_float TYPE F.

sample_float = ‘3.14’.

Write / sample_float.

Output:

Data Flair SAP ABAP Tutorial

Awesome Tutorial on Data Types by Data Flair

-1234

FF

3,140000000000001E+00

What are Variables?

Now, think about the data to be stored with an example.

  • Suppose you want to take an integer as input, add 1 to it, and output the result
  • How will you take the input?
  • Via keyboard, mouse and so on.
  • However, once you receive the input, how will you make sure whatever it is gets added to 1?
  •  
  • You store it, of course!
  • And to store the integer, you need something that would hold the value and ‘vary’ according to what the input is, i.e. you require a variable.

Therefore, a variable is a symbol that holds some data, which can be performed upon by some additional instructions.

Variables in ABAP

  • In ABAP, you can create variables according to one data type.
  • That is, before creating a variable, you must know what data type it will belong to.
  • Similarly, in our above example, we have declared that our input will be an integer.
  • Hence, the variable will be an integer variable.

SYNTAX FOR VARIABLE in ABAP

DATA variableName TYPE dataType.

Here,

  • Length limit to variable name is 30 characters (max)
  • Any data type – elementary, complex or reference can be used in declaration

EXAMPLE FOR VARIABLE in ABAP

DATA dataFlairID Type I.

There are three variable types in ABAP – 

  1. Static variables
  2. Reference variables
  3. System variables

STATIC VARIABLES IN ABAP

  • Static variables are variables that are active throughout the block in which they are declared i.e. its lifetime extends from the point of declaration in the block to the end of that block.
  • With local variables (described above) the declaration begins with ‘DATA’, for static variables within a class the declaration has ‘CLASS-DATA’ instead.
  • Along with ‘CLASS-DATA’ statement, ‘PARAMETERS’ are used to declare linked data objects and ‘SELECT-OPTIONS’ to include selection screens and their internal tables
  • Static variables are usually declared within subroutines or function modules.

There are a few rules to follow when naming a variable. Those rules are as follows – 

1. Do not use any ABAP keyword as a variable name

2. Do not use special characters in variable name except underscore ‘_’ used to separate words for easier understanding

3. Don’t try to change names of predefined structures, objects and data

4. Variable name must be lucid and it should easily convey the use without explanation

5. Avoid using hyphens ‘-’ in variable names as they are used in structures

Example of static variables in ABAP:

REPORT ZDataflair_001.

PARAMETERS: NAME(10) TYPE C,

CLASS TYPE I,

ID TYPE P DECIMALS 2,

CONNECT TYPE MARA-MATNR.

WRITE: ID.

Output:

2

REFERENCE VARIABLES IN ABAP

  • Reference variables refer to another type, usually elementary data type
  • These may refer to a class as well
  • They are of dynamic type, whereas in its declaration a static type which is more general is used

Example of ABAP reference variables:

CLASS DATAFLAIRCLASS DEFINITION.

PUBLIC SECTION.

DATA DATAFLAIRDATA TYPE I VALUE 1.

ENDCLASS. DATA: ODATAFLAIRREF TYPE REF TO DATAFLAIRCLASS ,

DDATAFLAIRREF1 LIKE REF TO ODATAFLAIRREF,

DDATAFLAIRREF2 TYPE REF TO I .

CREATE OBJECT ODATAFLAIRREF.

GET REFERENCE OF ODATAFLAIRREF INTO DDATAFLAIRREF1.

CREATE DATA DDATAFLAIRREF2.

DDATAFLAIRREF2→* = DDATAFLAIRREF1→*→ DATAFLAIRDATA.

WRITE: DATAFLAIRDATA.

OUTPUT:

1

SYSTEM VARIABLES IN ABAP

  • System variables are ones that can be accessed by all ABAP programs
  • Once accessed, they are allotted values by the runtime environment itself
  • These values reflect the current status of the system at the given point in time
  • The SYST table provides a complete reference to all system variables in ABAP
  • The SYST structure, as all structures, comprises elementary components which can be accessed by using ‘SYST-’ or ‘SY-’

Example of ABAP system variables:

REPORT ZDATAFLAIR_001.

WRITE:/’SY-SAPRL’, SY-SAPRL,

/’SY-ABCDE’, SY-ABCDE,

/’SY-HOST ‘, SY-HOST,

/’SY-DBSYS’, SY-DBSYS,

/’SY-TCODE’, SY-TCODE,

/’SY-LANGU’, SY-LANGU,

/’SY-SYSID’, SY-SYSID,

/’SY-MANDT’, SY-MANDT,

/’SY-DATUM’, SY-DATUM,

What are constants?

  • A constant is exactly what it sounds like – a constant value.
  • We can store a constant under a fixed name, similar to a variable. 
  • However, the difference is that you cannot change the value of a constant once it is declared.
  • For e.g. if you want to store the value of pi = 3.14, you would use a constant!
  • A constant has a value attached to it, which is assigned via its declaration. 
  • This value is stored in the program memory. 
  • The value attached cannot be changed during the execution of a program – which may lead to a run-time error, and this unchangeable value can be considered a literal.

Output:

Leave a Comment

Your email address will not be published. Required fields are marked *