Sie sind auf Seite 1von 39

SAP/ABAP

Content

Introduction of SAP Application Server Architecture.

ABAP Syntax Basics.

Data Objects And Data Types.

Create First ABAP Program.

By Ahmed Saad

Introduction
The following diagram shows
the 3-tier architecture of SAP
R/3 system.
R3 Applications are written
using ABAP.
ABAP is used to communicate
the database management
system and SAPgui in the
presentation layer through the
application server .

Structure of the application server


The individual components of
application server:

Work Processes
Dispatcher
Gateway
Shared memory
Database connection

Work Processes
Every program run in as SAP system
is work process.
Independent of OS and database.
SAP basis consultants are
responsible for configuring SAP
system, in such a way, to manage
the number of work processes used
so as channels and connections to
database.
A memory area is dedicated to
each work process

Work Process Architecture


There are 3 Modules in work processes
1. Screen Processor: Executes the flow logic of the
application program.
2. ABAP Processor: Executes the processing logic of
the application program
3. Database interface: ..

Note: The screen processor tells the ABAP


processor which module of the screen flow logic
should be processed next.

Cont. Work Process Architecture


3. Database interface
main responsibilities:
Establishing and
terminating connections
between the work
process and the
database.
Access to database
tables
Access to R/3 Repository
objects (ABAP programs,
screens and so on)

Work Process Types


Dialog Work Process: deals with requests from an active
user to execute dialog steps (user inputs).
Update work processes: execute database update requests
resulting from the dialog work Process.
Background work processes: processes of programs that
can be executed without user interaction (background jobs).
Enqueue work process: Administers a lock table in the
shared memory area to handle executing more than one
database LUW .
Spool work process: passes sequential datasets to a printer
or to optical archiving.
i.e. LUW stands for Logical Unit of Work which is inseparable database
operations & each dialog step is a database LUW.

The Dispatcher

link between the work processes and the logged-on users


Controls the distribution of the
Work Processes to the system users.
Keeps an eye on how many Work
Processes are available, and
when a user triggers a transaction.
Receive requests for dialog steps
from the SAPgui and direct them to
a free work process.
Directs screen output resulting
from the dialog step back to the
appropriate user.

Gateway
Each application server contains a gateway.
This is the interface for the R/3 communication
protocols (RFC, CPI/C).
It can communicate with other application servers in the
same R/3 System, with other R/3 Systems, with R/2
Systems, or with non-SAP systems.

Shared Memory
Common main memory area used by all work processes
in and application server.
Contains the resources that all work processes use
such as programs and table contents.
Memory management ensures that the work
processes always address the correct context (the data
relevant to the current state of the program that is
running).
Local buffering of data in the shared memory reduces
the number of database reads required.

Database Connection
Application server uses it to register its work
processes with the database layer, and receives a
single dedicated channel which cannot be changed
while the system is running .
So A working process make database changes within a
single database LUW.

ABAP
Advanced Business Application Programming

ABAP Syntax
An ABAP program consists of individual ABAP statements.
ABAP is not case sensitive.
(Ex. WRITE myDATA. Similar to Write MYDATA.)

Every statement begins with a keyword and ends with a period.


ABAP Supports Chaining statements.
To do so, you specify the identical starting segment once and conclude it with a colon
(:), the remaining segments are then listed, separated by commas (,) and concluded
with a period (.)
(Ex. WRITE: 'Hello', 'ABAP'.)

Comments:
For placing a comment in the beginning of the line use (*) .
Ex. * This is a comment line
For placing a comment after the line use ().
Ex.

WRITE 'COMMENT'. "Start of comment

ABAP
Operating/Database system-independent
programming
ABAP contains a subset of SQL called Open SQL
for comfortable database access for various
database
ABAP Programming
ABAP Report
Dialog Programming (Transaction)

Chained Statements
WRITE Hello World.
WRITE OK.
=
WRITE: Hello World, OK.
DATA tmp1 TYPE I.
DATA tmp2 TYPE C.
=
DATA: tmp1 TYPE I,
tmp2 TYPE C.

Chained Statement
MOVE sy-subrc TO tmp1.
MOVE sy-subrc TO tmp2.
MOVE sy-subrc TO tmp3.
=
MOVE sy-subrc TO: tmp1,
tmp2,
tmp3.

Chained Statement
PERFORM cal_1 USING a1 a2.
PERFORM cal_1 USING a3 a4.
=
PERFORM cal_1 USING: a1 a2,
a3 a4.

Comments
* This is full line comment
WRITE Hello World. Write data (partial line comment)
WRITE Test.

ABAP Command : Case Sensitivity


ABAP command is not case sensitive

WRITE Hello World.


WriTe Hello World.
wRiTE Hello World.

Data Objects / Data Types

Data
Objects
ABAP Data
Objects: They contain methods ,events
and data which are allocated and called during the
runtime.
They can be divided into classes and interfaces.
Object references, on the other hand, can be created
with reference to either classes or interfaces.
Variable

Structure

Internal Table

Table Structure

Constants

<Methods>

Data Types.
Elementary types are the smallest
indivisible unit of types (Fixed length,
Variable length).
Reference Type: Reference types
describe data objects that contain
references (pointers) to other objects .
Complex Type: A type which is made up
of other types.
Structures: a sequence of any elementary
types, reference types, or complex data types.
Internal Tables: consists of a series of lines
that all have the same data type (elementary
type, reference type, or complex data type).

Data Types cont.

Data Types Cont.


Use predefined
elementary data types:
Ex. DATA: name(20) TYPE
c.
DATA: age(3) TYPE n.
Define your own data
types.
Ex. TYPES: name(20)
TYPE c.
DATA: fname TYPE
name.
DATA: lname TYPE
name.

Structure

* Syntax
DATA BEGIN OF <structure name>.
DATA field1.
DATA field2.

DATA END OF <structure name>.

Structure Data Type


id

* Structure data type 0000000


0
. TYPES: BEGIN OF student ,
id(5) TYPE n,
name(10) TYPE c,
dob TYPE d,
END OF student.
DATA: student1 TYPE student.
studen1-name = Ahmed.

name

dob

Defining Structure (Include Structure)

* Include Structure
DATA BEGIN OF wa.
INCLUDE STRUCTURE customers.
DATA tel(7).
DATA END OF wa.

Defining Structure (Include Structure)

* Include Structure
DATA BEGIN OF Manager.
INCLUDE STRUCTURE employee.
DATA office phone(12).
DATA END OF Manager.

Defining Structure
* LIKE option
DATA Manager LIKE Employee.
Manager -id = 1.
Manager -name = John.
WRITE: Manager -id, Manager -name.

Constants
* Constant
CONSTANTS: pi TYPE p DECIMALS 2 VALUE '3.14.
CONSTANTS max_no TYPE I VALUE 999.
DATA counter TYPE I VALUE max_no.
WRITE: max_no, counter.

System Fields
The system fields (structure syst) are filled by the
runtime environment. You can use them to query the
system status in an ABAP program
You should access them only for reading

sy-datum
sy-uzeit
sy-datlo
sy-timlo
sy-mandt
sy-subrc

= Current date of application server


= Current time of application server
= Current date of SAP GUI
= Current time of SAP GUI
= Current client logon
= Return value of ABAP statement

How to create
ABAP program
Transaction Code : SE38

Types of ABAP Reports

1
3

1. Report Listing
4

2. Drill-down Report
3. Control-break
Report

ABAP Program : Dialog Program


Dialog Program
: attribute type M
(Module Pool)

Reading
Data

Writing
Database

Reading and changing data

Dialog Program : Transaction

Transaction : SE38

Program Attribute

ABAP Editor

Basic Functions of the ABAP Editor

Find and
Repeat Find
Syntax Check

Syntax Check

Execution (F8)

(Ctrl+F2)
Display/change mode
(Ctrl+F1)

Activation
(Ctrl+F3)

ABAP help (F1)

Where used list

(Ctrl+Shift+F3)

Standard toolbar

Das könnte Ihnen auch gefallen