Customizing SAP for Dummies: ABAP Tutorial for Students with some Programming Experience – Part 1

As you know, I am going through some kind of ABAP training right now with the help of one of the team members. I have spend the last two weeks reading the documentation of help.sap.com and feel I am starting to get a better grip of what ABAP is and how you can use it.

The goal of this tutorial is to give any person with the basic knowledge of procedural programming, object-oriented programming (OOP) and SQL, a good overview of what the possibilities of the language are and how to understand a basic ABAP program.

So let’s start.

Programs in SAP are created, edited and debugged in the same presentation framework you normally use to access the SAP programs. These programs are called Transactions and are either local programs or belong to a package. The only reason for using packages is to group different files that belong together and make the transportation phase easier. Transportation meaning changing the status of a program, from the programing phase to the testing phase, to finally transporting the program to the SAP master.

Any program written in ABAP begins with one of the following introductory statements, a space and the name of the program:

  • REPORT
  • PROGRAM
  • FUNCTION-POOL
  • CLASS-POOL
  • INTERFACE-POOL
  • TYPE-POOL

What you normaly use is a report. A report is nothing more than an executable programm. Function pools are, as its name says, pools of functions you can include in your executable program. The same for type pools, which contains definitions of types to use in executable programs. Class pools are used in OOP, so we will come to that later (when I get to the topic in my training :-) )

Once you have defined the type of program and its name, you can start with the types and data definitions. I will explain both together as their similarities are many. To define a new type you have following syntax

TYPES new_type
{TYPE {REF TO} defined_type} |
{LIKE {REF TO} defined_variable}.

This code defines a new type new_type based on the already defined type defined_type or based on the type of the variable defined_variable. If you use the keyword REF TO the new type will be only a pointer to a variable of that type.

Analogous we can use following syntax to define a variable:

DATA new_type{(c)}
{TYPE {REF TO} defined_type} |
{LIKE {REF TO} defined_variable}
{VALUE d}.

Just notice that if you use the option (c) you will create an array of c elements of the defined type, and using the keyword VALUE you can assign a value d to the variable.

And for the end of this part I just want to show you the predefined types in ABAP you can use when defining new types or variables.

Numeric Types

Type Identifier Initial Value Lenght (in Bytes) Format
Integer I 0 4 -
Floating point number F 0 8 -
Packed number P 0 1-16 0000- (negative) / 0000 (positive)

Character Types

Type Identifier Initial Value Lenght (in Bytes) Format
Characters C ‘ ‘ 1 – 65535 -
Date D ‘00000000 ‘ 8 YYYYMMDD
Time T ‘000000 ‘ 6 HHMMSS
Hexadecimal field X 0 1 – 65535 X’0000..000′

Hope you have now a better understanding of what the basics of ABAP are. I will come back with more information next time. Stay tuned!

3 Responses to “Customizing SAP for Dummies: ABAP Tutorial for Students with some Programming Experience – Part 1”

  1. Customizing SAP for Dummies: ABAP Tutorial for Students with some Programing Experience - Part 2 « Interndia - Internship in India Says:

    [...] SAP for Dummies: ABAP Tutorial for Students with some Programing Experience – Part 2 In the first part of this tutorial I explained the basics of programs and types in ABAP. Today I will introduce you [...]

  2. Customizing SAP for Dummies: ABAP Tutorial for Students with some Programing Experience - Part 3 « Interndia - Internship in India Says:

    [...] Programing Experience – Part 3 It is time to continue the ABAP tutorial. After the basics in Part 1 and the first report in Part 2, in this part we are going to take a look at the different events in [...]

  3. Barron Anderson Says:

    I like your tutorial. You translations of SAP terminology to other standard programming languages is a great help. It seems not many people appreciate the skill of simplifying a complex task, but you have mastered this very well. Thanks!

Leave a Reply