• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

SAP ABAP Tutorials

Welcome to the SAP ABAP  Tutorials. The objective of these tutorials is to get in depth understanding of SAP ABAP . The tutorial starts with overview of SAP ABAP .

In addition to these tutorials, we will also cover common issues, Interview questions and How To’s of SAP ABAP .


ABAP (Advanced Business Application Programming) is a programming language for developing applications for the SAP R/3 system, a widely-installed business application subsystem. The latest version, ABAP Objects, is object-oriented programming. SAP will run applications written using ABAP/4, the earlier ABAP version, as well as applications using ABAP Objects.

SAP’s original business model for R/3 was developed before the idea of an object-oriented model was widespread. The transition to the object-oriented model reflects an increased customer demand for it. ABAP Objects uses a single inheritance model and full support for object features such as encapsulation,polymorphism, and persistence.

ABAP language syntax

ABAP is not case sensitive.

Every statement begins with a keyword and ends with a period.( WRITE is the keyword to print on screen )

WRITE 'Hello World!'.

Chained statements.If consecutive statements have identical part at the beginning, then ABAP allows you to chain these statements into a single statement. First write the identical part once and then place a colon (:). Then write the remaining parts of the individual statements separated by commas.Normal Statements:

WRITE 'Hello'.

Chained Statement:

WRITE: 'Hello', 'ABAP'.

Comments.If you want to make the entire line as comment, then enter asterisk (*) at the beginning of the line.

* This is a comment line

If you want to make a part of the line as comment, then enter double quote (“) before the comment.

WRITE ‘COMMENT‘. “Start of comment

Create an instance of a class that implements a certain interface, but you won’t know the name of the class you want to create until run time. In Java or .NET you would have used the reflection mechanism, but can you handle this case in ABAP

Here’s a short code snippet showing how:

DATA: iv_classname TYPE seocl name.
DATA: gr_error TYPE REF TO cx_dynamic_check.
DATA: gv_message TYPE string.

iv_classname = ‘CL_CLASSNAME’.

CREATE OBJECT iv_interface TYPE (iv_classname).

CATCH cx_sy_create_object_error INTO gr_error.
gv_message = gr_error->get_text( ).
WRITE :/1 gv_message.

CATCH cx_sy_dyn_call_param_missing INTO gr_error.
gv_message = gr_error->get_text( ).
WRITE :/1 gv_message.


Let’s have a look at the code.

In the first four rows, you define several variables data types.
iv_classname hold the name of the class (that’s the name which will be known only in run time)
iob_object – a reference to an interface that the class you’ll instantiate implements.
The other two variables are for error handling purposes.
Now, you use the CREATE OBJECT ABAP statement.

CREATE OBJECT iv_interface TYPE (iv_classname).

Note that had you known the class name during compile time, you could use the following statement:


The difference? No parenthesis, plus you give the class name instead of a string containing the class name.
Let’s move on. In case the class does not exist on the system you’re running (or your provided a wrong class name), you’ll get the exception CX_SY_CREATE_OBJECT_ERROR, saying that the class you’re trying to instantiate couldn’t be found. In case there are missing parameters, you will get aCX_SY_DYN_CALL_PARAM_MISSING exception.

CREATE OBJECT iv_interface TYPE (iv_classname) EXPORTING param1 = value1 param2 = value2.

You now know a little bit about dynamically instantiating objects in your code – a great way to implement dynamic and extensible factory methods.

Parameters in ABAP

Parameters statements are almost same like data statements but it used for the user inputs. The variables declared using parameters statement are known as parameters and these will be displayed on selection screen while running the program. The user needs to enter or modify the values there and again continue the program execution.

The syntax of parameters statement is

-parameters variable name[length]  [data type] [decimals] [default value].

-parameters variable name like previous defined variable name [default value].

Parameter statement has lot of additions for use.

















These core tutorials will help you to learn 
the fundamentals of SAP ABAP.
For an in-depth understanding and practical experience,
explore Online SAP ABAP Training.

Data Types

Data statement is used for defining variables in our ABAP programming.

The syntax of data statement:

-data variable name[length]  [data type] [decimals] [default value].

-data variable name like previous defined variable name [default value].

After watching different data types used in ABAP we can see the usage of data statement with some examples.

Character data types used in ABAP

-Type c:  ( Used for character , maximum length between 1- 65535 and default value will blank)

-Type n: ( Used for numeric text , maximum length between 1- 65535, valid values will be 1 – 9 and default value will 0)

-Type d: ( Used for date , fixed length 8, valid values will be 1 – 9 and default value will 00000000)

-Type t: ( Used for time , fixed length 6, valid values will be 1 – 9 and default value will 000000)

-Type x:  ( Used for hexadecimal and maximum length between 1- 65535)

Numeric data types used in ABAP

Type I : ( Used for integer , fixed length 4, maximum decimals is 0,valid values between-231 to +231 and default value will be 0)

Type p:  ( Used for packed decimal , maximum length between 8- 15, maximum decimals is 14, valid values between 0-9 and default value will be 0)

Type f: ( Used for floating point , maximum length 8, valid values between -1E-307 to 1E308 and default value will be 0.0)

Sample data statement declarations

Data x.

(Here variable x will be treated as character, because character is the default data type)

data x(2) type c .

(Here variable x will be treated as character with length 2)

data x type i value 100 .

(Here variable x will be treated as integer with default value 100)

data x type d value 20110112 .

(Here variable x will be treated as date with the specified default value)

By using like addition with data statement all the properties like data type , length of the previously defined variable will be assigned to the new variable.

Data x1(2) type c.

Data x2 like x1.

Contact US

Need an Instructor Led Training, Contact Us

Enter this code: captcha