Site icon DataFlair

SAP ABAP Tutorial

SAP ABAP Introduction

FREE Online Courses: Click, Learn, Succeed, Start Now!

In this tutorial, we’ll be learning about the introduction to SAP ABAP. We will learn what SAP ABAP means, its history and dive deep into why and how it is an important language in today’s business systems.

What is SAP ABAP?

Inside the SAP database, the ABAP code runs in two forms:

  1. Source code: the basic program that is written, edited, or updated by a programmer.
  2. Generated code: similar to Java bytecode, generated code is an intermediate level of code between written code and final machine code.

Why ABAP?

History of SAP ABAP

SAP ABAP Architecture

Types of ABAP Programs

ABAP programs can be divided into two types:

  1. Reports: standalone programs that are executable, contain one screen.
  2. Module pools: many screens that are logically linked together as one.

ABAP also has non-executable programs:

  1. Interface type pools
  2. Object classes
  3. INCLUDE modules
  4. Function groups
  5. Subroutine pools

Basic Syntax of ABAP programs

1. Statements

Example of Statements in ABAP

REPORT ZDATAFLAIR_REPORT_001.
    WRITE: ‘HELLO WORLD!’.
    *The output will write whatever is included within single quotes

Output:

HELLO WORLD!

2. Comments in ABAP

Example

REPORT ZDATAFLAIR_REPORT_001.
    * this is a full-line comment
    WRITE: ‘HELLO WORLD!’.	“ this is a half-line comment

Output:

HELLO WORLD!

Few Keywords in ABAP

1. ULINE: to add an underline below the statement

E.g.  

REPORT ZDATAFLAIR_REPORT_001.
    WRITE: ‘HELLO WORLD!’.
    ULINE.

Output:

HELLO WORLD!

2. SKIP: to go to the next line in the display

E.g.

REPORT ZDATAFLAIR_REPORT_001.
    WRITE: ‘HELLO WORLD!’.
    SKIP.
    WRITE: ‘BYE BYE WORLD!’.

Output:

HELLO WORLD!
BYE BYE WORLD!

Messages in ABAP

A message displays errors, warnings, and other messages that the system may want to send to the programmer. It is usually a 2-character text that pops up to inform the user of the happenings in the execution.

Let’s see a few examples of messages:

MESSAGE MEANING DESCRIPTION
E Error This message showcases an error that leads to the program stopping its execution
W Warning This message pauses execution due to a warning, and needs user intervention for the execution to continue
I Information This message displays some information for the user which they need to intervene to pop out of
A Abend This message abends or retracts whatever transaction was being done by user
S Success This showcases the success of a transaction
X Abort This message creates dump and halts execution of program

How to write your first ABAP Report in ABAP Environment

  1. Open SAP System
  2. Go to SE38 – this opens the ABAP Editor/Workbench – the workbench includes several features of ABAP like the Editor, which we will use now and the rest we shall see in further tutorials
  3. Under field ‘Program’ enter your report name. It must start with a ‘Z’ or ‘Y’ and is case insensitive e.g. ‘ZDATAFLAIR_HELLOWORLD’

     4. Now select the ‘Create’ button on the right

     5. Click on ‘OK’ and choose the ‘Executable Program’ option from the dropdown menu

Write the following statements to create your first Hello World program:

REPORT ZDATAFLAIR_HELLOWORLD.
WRITE 'Hello World!'.

Output

Hello World!

Colon Notation in ABAP

In ABAP, we can combine a few lines of code if all of them begin with the same statement. We can do this by using the colon notation (:).

For e.g.

Instead of writing –

WRITE ‘Hello’.
WRITE ‘My’.
WRITE ‘Name’.
WRITE ‘Is’.
WRITE ‘Dataflair’.

We can write –

WRITE: ‘Hello’,
      ‘My’,
      ‘Name’,
      ‘Is’,
      ‘Dataflair’.

Output (same in both cases):

Hello My Name Is Dataflair

Summary

Thus, in this tutorial, we learned about ABAP. In the following tutorials, we will go through each concept one by one and learn what exactly SAP ABAP includes.

Exit mobile version