Are you looking for an easy guide to learn SAP ABAP? No more wait! MindMajix offers you a comprehensive SAP ABAP tutorial for beginners to learn 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.
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
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.
Here are some of the reasons why you should be going with SAP ABAP:
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. |
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.
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.
REPORT ZHELLO
WRITE 'Hello World'
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.
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.
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.
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:
In the SAP toolbar, you will find the following components:
To go to the ABAP Editor, begin the transaction SE38 in the command field.
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:
Here are the options to check, activate, and process the reports:
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 ]
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>
Here:
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:
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:
Following is the method that helps to declare a variable through the PARAMETERS statement.
REPORT ZTest123_01.
PARAMETERS: NAME(10) TYPE C,
CLASS TYPE I,
SCORE TYPE P DECIMALS 2,
CONNECT TYPE MARA-MATNR.
Here:
The code mentioned above gives this output:
To declare the reference variables, the following syntax is used:
DATA <ref> TYPE REF TO <type> VALUE IS INITIAL
Here is an example:
CLASS C1 DEFINITION.
PUBLIC SECTION.
DATA Bl TYPE I VALUE 1.
ENDCLASS. DATA: Oref TYPE REF TO C1 ,
Dref1 LIKE REF TO Oref,
Dref2 TYPE REF TO I .
CREATE OBJECT Oref.
GET REFERENCE OF Oref INTO Dref1.
CREATE DATA Dref2.
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.
Here is an example:
REPORT Z_Test123_01.
WRITE:/'SY-ABCDE', SY-ABCDE,
/'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-ABCDE ABCDEFGHIJKLMNOPQRSTUVWXYZ
SY-DATUM 12.09.2015
SY-DBSYS ORACLE
SY-HOST sapserver
SY-LANGU EN
SY-MANDT 800
SY-OPSYS Windows NT
SY-SAPRL 700
SY-SYSID DMO
SY-TCODE SE38
SY-UNAME SAPUSER
SY-UZEIT 14:25:48
Become a SAP ABAP expert by enrolling in SAP ABAP Training in Hyderabad
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:
REPORT YR_SEP_12.
CONSTANTS PQR TYPE P DECIMALS 4 VALUE '1.2356'.
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:
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.
183.
-97.
+326.
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
REPORT YR_SEP_12.
Write 'MindMajix'.
Write / 'ABAP Tutorial'.
String Field Literals
REPORT YR_SEP_12.
Write `MindMajix `.
Write / `ABAP Tutorial `.
The output of the cases mentioned above will be:
MindMajix
ABAP Tutorial
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.
ABAP programming language offers a variety of loop types to handle the requirements of looping, such as:
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.
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:
The ABAP programming language offers these decision-making statements:
Enrich your career in SAP ABAP by enrolling in SAP ABAP Training in Bangalore
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.
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.
As you might know, SQL can be segregated into two parts:
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.
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.
There are three types in the ABAP dictionary, such as:
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.
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.
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.
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 for SAP ABAP Training in Noida
SAP ABAP is used for developing business apps in the SAP environment.
SAP ABAP is a multi-paradigm programming language, which means you can use object-oriented, procedural and other programming principles.
Yes, SAP ABAP is a subset of SQL.
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.
SAP ABAP is functional.
Explore SAP OOPS ABAP Sample Resumes! Download & Edit, Get Noticed by Top Employers!
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.
Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:
Name | Dates | |
---|---|---|
SAP ABAP Training | Nov 26 to Dec 11 | View Details |
SAP ABAP Training | Nov 30 to Dec 15 | View Details |
SAP ABAP Training | Dec 03 to Dec 18 | View Details |
SAP ABAP Training | Dec 07 to Dec 22 | View Details |
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