Home  >  Blog  >   SAP ABAP

SAP ABAP Tutorial

Are you looking for an easy guide to learn SAP ABAP? No more wait! Mindmajix offers you a comprehensive tutorial to learn SAP ABAP from basics to advanced. Yes! You will learn from ABAP variables to report programming from this quick guide in-depth. What are you waiting for? Let’s jump into the blog to explore SAP ABAP.

Rating: 4.8

ABAP stands for Advanced Business Application Programming.  It is one of the fourth-generation programming languages. Nowadays, ABAP is considered as the primary SAP application server programming language in addition to Java. This technical module of SAP is used for developing applications related to SAP. With ABAP, you can easily customize SAP as per your requirements. 

With this SAP ABAP tutorial presented by MindMajix, let’s dive deeper into the main concepts of ABAP and understand how to work around ABAP. This tutorial is designed for beginners to understand the SAP ABAP technology. In addition, professionals can sharpen their SAP ABAP skills through this quick guide. Let’s get started.

Table of Contents

What is SAP ABAP?

Know that ABAP is a high-level programming language that SAP AG Software Company has developed and maintains for developing SAP applications. Initially, it was developed to generate SAP R/2 reports. The R/2 was used to allow a company to develop mainframe business apps. These apps are used for financial accounting and the management of material. 

Being a core programming language, ABAP is used in SAP ERP software. Considering that it is a fourth-generation language, it is called ABAP/4. The syntax of this language is simple and quite similar to the COBOL.  

If you're a non-programmer, you cannot use the ABAP language directly as it needs programming skills. However, the language is pretty easy to learn anyway. To design and develop ABAP programs, you must be knowledgeable in relational database design as well as object-oriented concepts. You can use the transaction codes to execute the ABAP. 

Why Learn SAP ABAP?

Here are some of the reasons why you should be going with SAP ABAP: 

  • ABAP is regarded as the core language that is used in the SAP R/3 platform.
  • The functional modules of SAP are written in the ABAP language.
  • ABAP is an easy-to-learn programming language offering object-oriented and procedural programming concepts.
  • Developers can effortlessly use ABAP language to make changes in ERP system applications.
  • It is the primary technology that the developers of ABAP are working on to develop varying SAP applications.
  • ABAP offers a variety of essential features, like the ability to make changes, data persistence, exception handling, data sharing, and more.
If you want to enrich your career and become a professional in SAP ABAP, then enroll in "SAP ABAP Training". This course will help you to achieve excellence in this domain.

SAP ABAP - Environment

The reports are a good initial point to familiarise yourself with ABAP tools and principles. These ABAP reports are generally used in a variety of areas. Let's find out how easy it is to write an ABAP report. 

Let’s start with a “Hello World” example.

Every ABAP statement starts with an ABAP keyword. The statement ends with a period. ABAP Keywords are separated by a space at least.

Moreover, you must use the ABAP editor to enter codes. The editor is also known as AS ABAP. It is essentially an app server that has its own database, development tools, and runtime environment. The editor offers a development platform that works autonomously with hardware, databases, and operating systems.

1. Using the ABAP Editor:

Step 1: You can start the transaction SE38 to open the ABAP editor.

Step 2: On the editor's first screen, give your report a name in the "PROGRAM" field. Whatever the name, it should precede with "Z" as it ensures your report is in the customer namespace. For instance, if you consider naming the report HELLO, it should be "ZHELLO."

Step 3: After specifying the report’s name, you can click the ‘CREATE’ button. soon after, a pop-up will come up as ”ABAP: PROGRAM ATTRIBUTES”. You must provide additional details about the report in the window.

Step 4: As the report type, select “Executable Program” and give the title and “SAVE” to move ahead.

Step 5: A window emerges on the screen named “CREATE OBJECT DIRECTORY ENTRY”. You need to select the “LOCAL OBJECT” on the screen.

Step 6: Now, it’s time to complete the first copy by inserting the WRITE statement below the REPORT statement. So the complete report will have the below two lines.

WRITE 'Hello World'

2. Starting the Report:

You can save the report by using the save icon or the keyboard command (Ctrl + S). The ABAP development will take place in the AS ABAP. 

Beginning the report is quite simple, just like saving it. Click on the “ACTIVATION” option and begin the report through the “DIRECT PROCESSING” icon or the “F8 function key.” now, the following will be displayed on the screen with the title and output.

My First ABAP Report
Hello World

It will not be relevant to the user if you don't change an existing report or activate a new one. This is essential in a central development environment where you can work on objects developers use in projects. 

3. Viewing the Existing Code:

If you see the Program field and double-click on the value ZHELLO, the ABAP editor will show your report's code. This is known as Forward Navigation. Double-clicking on the name of an object will open that object in the right tool.

MindMajix Youtube Channel

SAP ABAP - Screen Navigation

It is important to have a basic understanding of the elements of the ABAP screen, ABAP Editor, etc., the following will explain the same in detail.

1. Login Screen

Once you have logged into the SAP server, then the SAP login screen will prompt you for a User ID and Password. You must give a valid user ID and password and click "Enter." Then, this screen will appear: 

SAP ABAP Login Screen

2. Toolbar Icons

In the SAP toolbar, you will find the following components:

  • Menu Bar: It is at the top line of the dialogue window.
  • Standard Toolbar: you can the standard functions such as top of page,[age up, end of page, page down, and save.
  • Title Bar: It showcases the name of the business or application process that you are presently in.
  • Application Toolbar: It has the menu options relevant to applications
  • Command Field: This option allows you to start applications without navigating the menu transactions. It also allows you to assign logical codes to business processes.

SAP ABAP Toolbar Icons

3. ABAP Editor

To go to the ABAP Editor, begin the transaction SE38 in the command field.


4. Standard Keys and Icons

You can use the exit keys to log off or exit the module or program. You can also the keys to navigate to the last accessed screen. 

Here are some standard exit keys as used in SAP:

ABAP Standard Keys and Icons

Here are the options to check, activate, and process the reports:

Activating, Processing the Reports

5. Log Off

You must always Exit from the ABAP Editor and/or log off from the SAP system once you have finished the work.


[ Check out SAP ABAP Interview Questions and Answers ]

SAP ABAP - Variables

Know that variables are also called as data objects. They are used to store values within the given memory portion of the program. It is possible to change the content of variables by using ABAP statements. Each variable has a certain type in ABAP, which helps to define the layout and size of memory. It also defines the range of values that can be stored in the memory. Besides, it defines the set of operations that you can apply to variables.

You must declare variables first. The basic variable declaration form is:

DATA <f> TYPE <type> VALUE <val>


  • <f> is the variable name. It can have a maximum of 30 characters
  • <type> is the variable type. The type of data with specific technical attributes is known as <type>.
  • The <val> is nothing but the initial value of the <f> variable. Explicit, constant, or literal clauses can be other potential values for <val>. 

The following are a few examples of variable declarations:

DATA d1(2) TYPE C.  
DATA d2 LIKE d1.  
DATA minimum_value TYPE I VALUE 10

Note that d1 is the C-type variable type. d2 is the d1 type variable type. Also, the minimum value is the ABAP integer type - I variable. 

Know that there are three types of variables, such as:

1. Static Variables:

You can declare static variables in static methods, function modules, and subroutines. The variable lifetime is connected with the declaration context. You can use the ‘CLASS-DATA’ statement to declare variables with the classes. 

‘PARAMETERS’ statement can be used to declare the elementary data objects. These objects can be connected with the input fields on selected screens. 

You can use the SELECT-OPTIONS statement to declare the internal tables. The tables are usually associated with the input fields on selected screens.

Here are some conventions used when naming a variable:

  • It is not possible to use the special characters like “,” for naming variables.
  • Changing the name of a predefined data object is not possible.
  • It is not possible to maintain a variable name like ABAP keyword or clause.
  • The variable name should convey the variable meaning without needing more comments.
  • You can use hyphens to represent structures’ components. It is better to avoid using hyphens.
  • You can separate the compound words by using the underscore character. 

Following is the method that helps to declare a variable through the PARAMETERS statement.

REPORT ZTest123_01. 


  • NAME is the parameter of ten characters
  • CLASS is the integer type. It has a default size in bytes.
  • SCORE specifies the packed type parameter. This parameter can have values of a maximum of 2 decimal places.
  • CONNECT specifies the MARA-MATNF type ABAP dictionary.

 The code mentioned above gives this output:

ABAP Dictionary

2. Reference Variables:

To declare the reference variables, the following syntax is used:

  • RET TO declares a reference variable
  • The specification provides the static type of the reference variable after REF TO
  • The static type helps to limit the set of objects
  • The dynamic type is essentially the data class or type
  • The static type is the same or general as the dynamic type.

Here is an example:

Dref1 LIKE REF TO Oref, 
Dref2 TYPE REF TO I . 
Dref2→* = Dref1→*→Bl.

The code above shows declaring an Oref along with two data reference variables - Dref1 and Dref2. Here, data reference variables are typed completely. They can be dereferenced through the differencing operator.

3. System Variables:

  • You can access ABAP system variables from all the ABAP programs.
  • The run-time environment fills these fields.
  • The value indicates the system's state at a given time in the fields.

Here is an example:

REPORT Z_Test123_01. 

      /'SY-DATUM', SY-DATUM, 
      /'SY-DBSYS', SY-DBSYS, 
      /'SY-HOST ', SY-HOST, 
      /'SY-LANGU', SY-LANGU,
      /'SY-MANDT', SY-MANDT,
      /'SY-OPSYS', SY-OPSYS,
      /'SY-SAPRL', SY-SAPRL,
      /'SY-SYSID', SY-SYSID,
      /'SY-TCODE', SY-TCODE,
      /'SY-UNAME', SY-UNAME,
      /'SY-UZEIT', SY-UZEIT.

After executing the above code, you will get the below results:

SY-DATUM 12.09.2015 
SY-DBSYS ORACLE                   
SY-HOST sapserver 
SY-OPSYS Windows NT 
SY-UZEIT 14:25:48

Become a SAP ABAP expert by enrolling in SAP ABAP Training in Hyderabad

SAP ABAP - Constants and Literals

Know that constants are the data objects created statistically through declarative statements. A constant can be declared by assigning a value to it. You can store the value in the memory location of the program. You cannot change the assigned value during the program execution.


By using a CONSTANTS statement, you can easily declare the named data objects. Here is the syntax for it:

CONSTANTS <f> TYPE <type> VALUE <val>.

There are three types of constants: reference, complex, and elementary constants.

Here is how you can define constants through the CONSTANTS statement:

Write: / 'The value of PQR is:', PQR.

Here, the output will be: 

The value of PQR is: 1.2356

On the other hand, literals are those unnamed objects that you create within a program’s source code. They are completely defined by their value. You cannot change a literal’s value. 

There are many literal types. They are briefed below:

1. Numeric Literals:

They are essentially digit sequences that have prefixed signs. They don’t have any notation or decimal separator. Following are a few examples of numeric literals.


2. Character Literals:

These are the sequences of alphanumeric characters in an ABAP program’s source code and are enclosed in a single quotation mark. They have a predefined ABAP type C and can be described as text field literals. Here are some of its examples:

Text Field Literals

Write 'MindMajix'. 
Write / 'ABAP Tutorial'.

String Field Literals

Write `MindMajix `. 
Write / `ABAP Tutorial `.

The output of the cases mentioned above will be:

ABAP Tutorial

SAP ABAP - Loop Control and Decisions

There might come a situation when you would have to execute a code block many times. Generally, statements can be executed in a sequence, meaning that the first statement will be executed first, then the second one,  then the third, and so on.

Programming languages offer a variety of control structures that let you execute complicated paths. You can execute either one or multiple statements several times with a loop statement. 

SAP ABAP Loop Statement

ABAP programming language offers a variety of loop types to handle the requirements of looping, such as: 

  • WHILE Loop: This loop repeats executing statements if the given condition is true. It tests the condition before running the body of the while loop.
  • Do Loop: It is useful when it comes to repeating a specific task a certain number of times.
  • Nested Loop: This loop allows the use of one or many loops inside of any DO or WHILE loop.

1. Loop Control Statements

In general, loop control statements help to change the complete execution from the typical sequence. ABAP comes with control statements with which you can terminate loops prematurely. ABAP supports the below-mentioned control statements.

  • CONTINUE: This statement allows the loop to skip the remaining of its body and start passing the next loop.
  • CHECK: In case the given condition is false, the remainder of statements post the CHECK will be ignored, and the system begins the next loop pass.
  • EXIT: It terminates the loop entirely and transfers execution to the statement instantly after the loop.

2. Decision

Structures have one or many conditions that can be tested by the program when it comes to decision-making. 

Additionally, a statement(s) must be executed if the given condition is true. Conversely, other statements will be executed if the given statement is false. 

Here is a generalized decision-making structure that can be found in several programming languages:

ABAP Decision making

The ABAP programming language offers these decision-making statements:

  • IF Statement: It comprises a logical expression followed by one or multiple statements.
  • IF..Else Statement: an IF statement is usually followed by an ELSE statement.
  • Nest IF statement: An IF statement consists of another IF statement, then it is called a Nest IF statement. It is common to IF..Else statement as well.
  • CASE Control Statement: if you want to compare two or more variables or fields, you can use this statement.

Enrich your career in SAP ABAP by enrolling in SAP ABAP Training in Bangalore

SAP ABAP - Function Modules

Function modules cover a significant part of the entire SAP system as SAP has modularised code for years through function modules, allowing developers, customers, and themselves to reuse code. 

Functions modules are sub-programs comprising a specific set of reusable statements with exporting and importing parameters. These modules can be executed autonomously. SAP system includes many predefined function modules that you can call from any ABAP program. The function group works as a type of container for several function modules that logically belong to each other. For example, the function modules for a Human Resources (HR) payroll system will come together into a function group.

ABAP Create Function Module

You must explore the function builder to figure out how to create the function modules. You can discover it with transaction code SE37. All you have to do is type a function module name with some wild card characters to showcase how function modules could be looked for. Type in *amount* and hit the F4 key.

SAP ABAP - Dictionary

As you might know, SQL can be segregated into two parts: 

  • Data Manipulation Language (DML)
  • Data Definition Language (DDL) 

DML comprises update and query commands like DELETE, UPDATE, INSERT, SELECT, and more. ABAP programs regulate the DML part of the SQL.  

On the other hand, the DDL part has commands such as ALTER TABLE, DROP TABLE, CREATE INDEX, CREATE TABLE, and more. ABAP dictionary regulates the DDL part of SQL.

SAP ABAP Dictionary

You can view the ABAP dictionary as metadata (data about data) in the SAP database with the metadata regulated by the database. The dictionary is generally used to create and manage data definitions, views, types, domains, data elements, and tables. 

Types in ABAP Dictionary

There are three types in the ABAP dictionary, such as:

  1. Data Elements: They describe an elementary part by defining data type, data length, and possible decimal places.
  2. Structures: These come with components and can have almost any type.
  3. Table Types: They talk about the structure of an internal table.

SAP ABAP - SQL Overview

1. Open SQL

Open SQL is the subset of ABAP statements that allow direct access to the data stored in the central database of AS ABAP. The Open SQL statements map the functionality of DMLL in ABAP. All database systems support open SQL statements. 

You can use the open SQL interface to convert the Open SQL statements into database-specific SQL. The statements are usually transferred to the database system and executed there. They can access database tables declared in the ABAP dictionary.

2. Native SQL

The Native SQL covers all the statements that can be transferred statically to the Native SQL interface of the database interface. Native SQL statements don’t come within the ABAP’s language scope and don’t follow the syntax of ABAP. 
ABAP only comprises statements to isolate program sections wherein Native SQL statements can be listed.

Native SQL Statement

SAP ABAP - Object Orientation

Object orientation is meant to simplify software design to make it easier to comprehend, maintain, and reuse. Object-oriented programming (OOP) signifies diverse thinking regarding writing software. 

  • Classes: A class is majorly used to define the object’s form and combine data representations with methods for manipulating data into one package. The functions and data in a class are known as members of that class.
  • Objects: This one is a particular variable with different behaviors and characteristics. The attributes or characteristics of an object are used to describe the object's state, methods, or behaviors for performing actions.
  • Inheritance: Inheritance is one of the most essential concepts in object-orient programming. It lets you define a class, making it easy to create and maintain an entire application.
  • Polymorphism: From the object-oriented programming perspective, polymorphism works together with inheritance to make it possible for different types in an inheritance tree to be used interchangeably.
  • Encapsulation: It is a concept that combines data and functions to manipulate data and keep both safe from misuse or external interference. 

SAP ABAP - Report Programming

A report is a data presentation in an organized structure. Several database management systems comprise a report writer that allows you to design as well as create reports. SAP applications support report creation as well.

You can create a classical report in the WRITE statement in a loop through the output data. They don't have any sub-reports. SAP also offers standard reports, like RSCLTCOP, that you can use to copy tables across the clients. 

Generally, these reports have one screen as an output. You can use a variety of events like TOP-OF-PAGE & INITIALIZATION to create a classical report. These events are linked to specific user actions and get triggered when the user is performing those actions.

Upskill your career by applying in SAP ABAP Training in Noida


1. What is SAP ABAP used for?

SAP ABAP is used for developing business apps in the SAP environment.

2. What type of language SAP ABAP is?

SAP ABAP is a multi-paradigm programming language, which means you can use object-oriented, procedural and other programming principles. 

3. Is SAP ABAP SQL based?

Yes, SAP ABAP is a subset of SQL.

4. Is ABAP easier than Java?

Yes, SAP ABAP is an extremely simple and easy programming language. If you have an experience in some other programming language, it will become easier for you to learn ABAP.

5. Is SAP ABAP functional or technical?

SAP ABAP is functional.


Understanding the concept of SAP ABAP is quite a breeze. If you are experienced in some other programming language, it becomes much easier to work with ABAP. Now that you have gotten a gist of the SAP ABAP tutorial, it’s high time you begin developing a business application using this programming language.  

If you want to sharpen your skills in SAP ABAP further, enroll in this SAP ABAP Certification Training by MindMajix. This live, self-paced training course is instructor-led and takes you through the fundamentals of ABAP and how to work with the workbench tools.

Join our newsletter

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
SAP ABAP CourseApr 23 to May 08View Details
SAP ABAP CourseApr 27 to May 12View Details
SAP ABAP CourseApr 30 to May 15View Details
SAP ABAP CourseMay 04 to May 19View Details
Last updated: 19 Dec 2023
About Author

Viswanath is a passionate content writer of Mindmajix. He has expertise in Trending Domains like Data Science, Artificial Intelligence, Machine Learning, Blockchain, etc. His articles help the learners to get insights about the Domain. You can reach him on Linkedin

read more
Recommended Courses

1 / 15