You are on page 1of 111

CSC Private Slide 1

ABAP/4 OVERVIEW
CSC Private CA-AS India team Slide 2
ABAP/4
CSC Private CA-AS India team Slide 3
SAP R/3 Structure
Application Layer for Standard and new applications.
Middle ware Layer also called as R/3 Basis .
Operating System, Database
O.S Database GUI Protocols
NT Oracle Win 3.1 TCP/IP
Unix Ingress NT,95 CPC
AS/400 Informix,DB/2
CSC Private CA-AS India team Slide 4
Components of M.W.Layer

ABAP/4 Development Workbench
Database Interface
GUI etc.,
CSC Private CA-AS India team Slide 5
ABAP/4 Dev Workbench
It contain different tools for development of ABAP/4 objects, checking and
analysing programs and finally transportation of objects.
1) ABAP/4 Language 2) Data modeler
3) Object browser 4) Repository
5) Test & Analysing tools
6) The Query and 7) Workbench Organizer
CSC Private CA-AS India team Slide 6
ABAP/4 Language

It is the Central part of Middle ware layer that eliminates dependencies
from Hardware, Operating Systems or database management systems.
CSC Private CA-AS India team Slide 7
Data Modeler

Relation ship between the tables are stored in the form of ER diagrams.
(ER = Entity Relation ship)
CSC Private CA-AS India team Slide 8
Object Browser

Hirarcheal representation of Programs, Screens, Menus, Transactions,
Tables etc.,
CSC Private CA-AS India team Slide 9
Repository
The ABAP/4 Repository is made up of following Runtime Objects.
Programs
Screens and
Dictionary
Dictionary contains Metadata. Metadata is nothing but description of data
and definitions.
CSC Private CA-AS India team Slide 10
Test & Analysing Tools

For testing and analysing performance of Programs and Transactions.
CSC Private CA-AS India team Slide 11
Work Bench Organizer

Transportation of Objects between the systems.
CSC Private CA-AS India team Slide 12
Introduction to ABAP/4

ABAP : Advanced Business Application
Programming
4 : Fourth generation Language
CSC Private CA-AS India team Slide 13
Introduction to ABAP/4 contd.
Multi Lingual
Only Tool for developing SAP applications.
ABAP Workbench contains all tools, we need to
create ABAP/4 Programs.
ABAP/4 program contains all usual control
structures and modularization concepts.
After coding, we will save and generate. During
generation, the system creates a Run Time
object. When we execute, the system executes
this Run Time Object.

CSC Private CA-AS India team Slide 14
Structure of ABAP/4 Programs
These are different from sequential programming languages such as
FORTRAN, PASCAL and C.
Instead it shares certain features with event Oriented programming
languages such as VB and JAVA.
CSC Private CA-AS India team Slide 15
Structure of ABAP/4 Prog. contd.
An ABAP/4 program has modular structure.
Source text (processing Block) always consists,
Collection of One or more programming modules .
Programming module consists of sequential
statements.
With in the processing Block, we can use general
Control statements such as DO, IF, WHILE and
CASE statements.
CSC Private CA-AS India team Slide 16
Execution of ABAP/4 Prog.
For Execution of ABAP/4 Programs you need a special Run Time
Environment .
This Run Time Environment is responsible for calling the individual
program modules one after the other .
This Run Time Environment is nothing but ABAP/4 Processor .
CSC Private CA-AS India team Slide 17
Characteristics of ABAP/4 Prog.
Declarative Elements for declaring Data.
Operational Elements for Manipulating data.
Control statements for processing program flow.
Functions for processing character strings.
Subroutines with or without passing values.
Central Library with special type of Subroutines
called Function modules.
CSC Private CA-AS India team Slide 18
Charact of ABAP/4 Prog.contd.
Open SQL (a subset of SQL) to read and change data base tables.
Allows you to define and process Internal Tables.
Allows you to store data as Sequential files on Application and
Presentation Servers.
CSC Private CA-AS India team Slide 19
Types of ABAP/4 Programs
Executable program (1)
INCLUDE program (I)
Module pool (M)
Function group (F)
Subroutine pool (S)

CSC Private CA-AS India team Slide 20
Types of ABAP/4 Prog. contd.

SAP differentiates between two general types of ABAP/4 Programs.
Report Programs
Dialog Programs
CSC Private CA-AS India team Slide 21
Report Programs

Reports are stand alone programs.
We use reports to read data base tables and represent results in Lists
Reports are collection of processing blocks, controlled by System calls
depending on events.
CSC Private CA-AS India team Slide 22
Report Programs contd.

Reports can use LDBs or SELECT STATEMENTS defined by
DEVELOPER.
Reports can call Dialogue programs and vice versa.
CSC Private CA-AS India team Slide 23
Dialogue Programs

Dialogue programs are not stand alone programs. (we have to link the
dialogue programs to at least one or more SCREENS and
TRANSACTION CODES)
We use Dialogue Programs to read and change Database tables.

CSC Private CA-AS India team Slide 24
Dialogue Programs contd.

Dialogue programs are controlled by Screen flow logic.
Dialogue program is also called as Module pool program or
TRANSACTION.
These module pools are separated in to PBO and PAI events.
CSC Private CA-AS India team Slide 25
Dialogue Programs contd.

Collection of PBO, PAI and a screen is called DYNAMIC PROGRAM
(DYNPRO).
A module pool must have at least one DYNPRO.
CSC Private Slide 26
DATA TYPES
CSC Private CA-AS India team Slide 27
Data Types
1) Elementary 2) Structured
System Defined
(Pre Defined)
3) Elementary 4) Structured
User Defined
Data Types
CSC Private CA-AS India team Slide 28
1) Elementary System Defined Data
Types
Character (C)
Numeric Text(N)
Integer(I)
Packed(P)
Float(F)
Date(D)
Time(T)
Hexadecimal(X)
CSC Private CA-AS India team Slide 29
2) Structured System Defined Data Types

All Database Tables
CSC Private CA-AS India team Slide 30
3) Elementary User Defined Data Types

Types
CSC Private CA-AS India team Slide 31
4) Structured User Defined Data Types
Internal Tables and
Field Strings
CSC Private CA-AS India team Slide 32
Elementary System defined
Data Types
CSC Private CA-AS India team Slide 33
Character (C) Data Type
Data a(5) type c.
Data a(5).
Data b.
Data : a(5),b.
a = ABCD.b = A.
move ABCD to a. move A to b.
Data : a(5) value ABCD,b value A.
CSC Private CA-AS India team Slide 34
Numeric Text (N) Data Type
Data a(3) type n.
a = 123.
Data b(6) type n value 500029.
Data :c(3) type n value 123,
d(6) type n value 500029.
Data e(3) type n.
move 123 to e.
CSC Private CA-AS India team Slide 35
Integer (I) Data Type
Data a type i.
a = 125.
Data b type i value 130.
Data : c type i value 135,
d type i value 140.
Data : e type i.
move 145 to e.
CSC Private CA-AS India team Slide 36
Packed Number (P) Data type
Data a type p decimals 2.
a = 123.45.
Data b type p decimals 2 value 234.56.
Data : c type p decimals 2 value 123.45,
d type p decimals 2 value 234.56.
Data e type p decimals 2.
move 234.56 to e.
CSC Private CA-AS India team Slide 37
Float (F) Data Type
Data a type f.
a = 123.45.
Data b type f value 234.56.
Data : c type f value 123.45,
d type f value 234.56.
Data e type f.
move 123.45 to e.
CSC Private CA-AS India team Slide 38
Date (D) Data Type
Data a type d.
a = 20000225.
Data b(8) type d. b = 20011226.
Data : c type d value 20000328,
d(8) type d value 20011221.
Data : e type d.
move 20011212 to e.

CSC Private CA-AS India team Slide 39
Time (T) Data Type
Data a type t.
a = 081152.
Data b(6) type t. b = 090231.
Data : c type t value 081152,
d(6) type t value 090231.
Data : e type t.
move 101010 to e.
CSC Private CA-AS India team Slide 40
Hexa Decimal (X) Data Type
Data a type x.
a = 01.
Data b type x value AB.
Data : c(2) type x value 1234,
d type x value AC.
Data e type x.
move A1 to e.
CSC Private CA-AS India team Slide 41
Structured System Defined
Data Types
CSC Private CA-AS India team Slide 42
Tables
Tables sflight.
Tables : sflight, sbook.
CSC Private CA-AS India team Slide 43
Elementary User defined
Data Types
CSC Private CA-AS India team Slide 44
Types Data Type
Types name(5).
Data : name1 type name,
name2 type name,
name3 type name,
name4 type name.
CSC Private CA-AS India team Slide 45

Structured User Defined
Data Types
CSC Private CA-AS India team Slide 46
Structured User Defined Data
Types

Internal Tables & Field strings

CSC Private Slide 47
DATA OBJ ECTS
CSC Private CA-AS India team Slide 48
Data Objects
Can not exist without Data types.
Occupies memory space.
Created during Run Time.
CSC Private CA-AS India team Slide 49
Data Object Types
Internal External System
Defined
Special
Data Object
CSC Private CA-AS India team Slide 50
Internal Data Objects
Variables
Constants
Literals
CSC Private CA-AS India team Slide 51
Variables
Data a type value 1234.
During run time, Data Object A is created
and its value is 1234.
The value of A in this case (declared as variable) can be changed during
run time.
a = a + 1.
CSC Private CA-AS India team Slide 52
Constants
Constants a type i value 1234.
During run time, Data Object A is created
and its value is 1234.
The value of A in this case (declared as constant) can not be changed
during run time.
CSC Private CA-AS India team Slide 53
Literals
Data a(10) value ABCDEF.
During run time, Data Object A is created
and its value is ABCDEF.
CSC Private CA-AS India team Slide 54
External Data Objects
All Table fields comes under this
category.
Data a like sflight-carrid value SQ.
During run time, Data Object A is
created and its value is SQ.
CSC Private CA-AS India team Slide 55
System defined Data Objects
Space , and System variables comes under this category.
Data a like sy-datum.
a = sy-datum.
During run time, Data Object A is created
and its value is todays date.
CSC Private CA-AS India team Slide 56
Special Data Objects
Parameters
Selection Criteria
CSC Private CA-AS India team Slide 57
Parameters
Data : a type i value 123,
b type i value 321.
You can not assign another set of values to a & b, unless we change
these values with in the above code.
Hence the need for Parameters.
CSC Private CA-AS India team Slide 58
Parameters contd.
Parameters : a type i,
b type i.
With parameters declaration a selection screen is created during run time
and the user can input any number of sets of values.
CSC Private CA-AS India team Slide 59
Parameters contd.
You can assign default values variables declared
under parameters.
Parameters : a type i default 123,
b type i default 321.
During run time, the above default values will
appear in the selection screen. User can use the
same values or he/she can change the above set of
values for later use.
CSC Private CA-AS India team Slide 60
Selection Criteria
Data : a like sflight-carrid.
a = SQ.
You can not assign another value to a, unless we change this value with
in the above code.
Hence the need for Selection Criteria.
CSC Private CA-AS India team Slide 61
Selection Criteria contd.

select-options a for sflight-carrid.

With select-options declaration a selection screen is created during run
time and the user can input any range of values.
CSC Private CA-AS India team Slide 62
Selection criteria contd.
You can assign default values to variables declared
using select-options.
Select-options : a for sflight-carrid default
SQ.
During run time, the above default values will
appear in the selection screen. User can use the
same value or he/she can change the above value
for later use.
CSC Private Slide 63
CONSTRUCTS
CSC Private CA-AS India team Slide 64
Constructs
Branching
If * Elseif * Else * Endif.
Case * Endcase.
Looping (System index SY-INDEX)
Do * Enddo.
While * Endwhile.
CSC Private CA-AS India team Slide 65
Constructs contd.
If * Elseif * Else * Endif.
If a = 5.
write: / five.
Elseif a = 10.
Write:/ Ten.
Else. Write:/ Others.
Endif.
CSC Private CA-AS India team Slide 66
Constructs contd.
Case ** Endcase.
Case a.
When 5. write: / five.
When 10. Write:/ Ten.
When Others. Write:/ Others.
Endcase.
CSC Private CA-AS India team Slide 67
Constructs contd.
Do ** Enddo.
Do 2 times.
Write:/ ABCD.
Enddo.
ABCD
ABCD
CSC Private CA-AS India team Slide 68
Constructs contd.
Do ** Enddo contd.

A = 5. A = 5.
Do 2 times. Do 2 times.
Write:/ A. A = a + 1.
A = a + 1. Write:/ a.
Enddo. Enddo.
CSC Private CA-AS India team Slide 69
Constructs contd.
Do ** Enddo contd.
A = 1.
Do 3 times. Do 3 times.
Write:/ A. Write:/ sy-index.
A = a + 1. Enddo.
Enddo.

CSC Private CA-AS India team Slide 70
Constructs contd.
Do ** Enddo contd.
Do 5 times. Do 5 times.
If sy-index = 3. Write:/ sy-index.
Continue. If sy-index = 3.
Endif. Continue.
Write:/ sy-index. Endif.
Enddo. Enddo.
CSC Private CA-AS India team Slide 71
Constructs contd.
Do ** Enddo contd.
Do 5 times. Do 5 times.
If sy-index = 3. Write:/ sy-index.
Exit. If sy-index = 3.
Endif. Exit.
Write:/ sy-index. Endif.
Enddo. Enddo.
CSC Private CA-AS India team Slide 72
Constructs contd.
While ** Endwhile.

While sy-index <= 5.
Write:/ sy-index.
Endwhile.
CSC Private CA-AS India team Slide 73
Checkboxes
Parameters : c1 as checkbox,
c2 as checkbox.
If c1 = X and c2 = . <add 2 numbers >
elseif c1 = and c2 = X.<subtract>
elseif c1 = X and c2 = X <multiply>
else. <divide>.
Endif.
CSC Private CA-AS India team Slide 74
Radiobuttons
Parameters : r1 radiobutton group g1,
r2 radiobutton group g1.
If r1 = X .
<add 2 numbers >
else.
<subtract>
Endif.

CSC Private Slide 75
STRING OPERATIONS
CSC Private CA-AS India team Slide 76
String Operations
Concatenate
Split
Shift
Replace
Translate
Offset
String length
String comparision
CSC Private CA-AS India team Slide 77
String Operations contd.
Concatenate
data : a(10),b(10),c(10),d(40).
A = Apple. B = Orange. C = Banana.
Concatenate A B C into D.
Write:/ d.
Concatenate A B C into D separated by /.
Write:/ d.



CSC Private CA-AS India team Slide 78
String Operations contd.
Split
data : a(10),b(10),c(10),d(40).
D = Apple/Orange/Banana.
Split d at / into a b c.
Write:/ a
/ b,
/ c.
CSC Private CA-AS India team Slide 79
String Operations contd.
Shift
Data : a(6) value ABCDEF.
Shift a.(by default shifts to left by one place)
write: / a. BCDEF
A = ABCDEF.
Shift a by 2 places.
Write:/ a. CDEF
CSC Private CA-AS India team Slide 80
String Operations contd.
Shift contd.
Data : a(6) value ABCDEF.
Shift a right.
Write:/ a. ABCDE
A = ABCDEF.
Shift a right by 2 places.
Write:/ a. ABCD
CSC Private CA-AS India team Slide 81
String Operations contd.
Shift contd.

Data : a(6) value ABCDEF.
Shift a up to C. Write:/ a. CDEF
a = ABCDEF.
Shift a circular. Write:/ a. BCDEFA



CSC Private CA-AS India team Slide 82
String Operations contd.
Shift contd.
Data a(6) ABCDEF.
Shift a circular by 2 places.
Write:/ a. CDEFAB
a = ABCDEF.
Shift a circular right by 2 places.
Write:/ a. EFABCD
CSC Private CA-AS India team Slide 83
String Operations contd.
Replace

Data p(6) value ABCABC.
Replace ABC with DEF into p.
Write:/ p. DEFABC
(Replaces first occurrence only)
CSC Private CA-AS India team Slide 84
String Operations contd.
Translate

Data p(11) ABC ABC ABC.
Translate p using ADBECF.
WRITE:/ P. DEF DEF DEF
CSC Private CA-AS India team Slide 85
String Operations contd.
Offset

Data p(6) value ABCDEF, q(3).
q = p+2(3).
Write :/ q. CDE
q = p+0(1).
Write:/ q. A

CSC Private CA-AS India team Slide 86
String Operations contd.
String Length.

Data: a(50) value PQRPQRPQRXYZ,
b type i.
b = strlen( a ). 15
CSC Private CA-AS India team Slide 87
String Operations contd.
String Comparison
Contains any ca
Contains only co
Contains string cs and
Contains pattern cp.

CSC Private CA-AS India team Slide 88
String Operations contd.
Contains any (ca) [ case sensitive ]
If SAP ca ABAP/4.
Write:/ True.
Else.
Write:/ False.
Endif.
True
CSC Private CA-AS India team Slide 89
String Operations contd.
Contains only (co) [ case sensitive ]
If SAP co ABAP/4.
Write:/ True.
Else.
Write:/ False.
Endif.
False
CSC Private CA-AS India team Slide 90
String Operations contd.
Contains string (cs) [ not case sensitive ]
If ABAP/4 cs Ab.
Write:/ True.
Else.
Write:/ False.
Endif.
True
CSC Private CA-AS India team Slide 91
String Operations contd.
Contains pattern (cp) [ not case sensitive ]
If ABAP/4 cp *aP++.
Write:/ True.
Else.
Write:/ False.
Endif.
True
CSC Private Slide 92
OUTPUT STATEMENTS
CSC Private CA-AS India team Slide 93
Output statements contd.
The basic ABAP/4 statement for output on the Screen is WRITE.
Syntax :
Write f .
f can be any data object.
CSC Private CA-AS India team Slide 94
Horizontal Lines
Write: / sy-uline.
Write:/P sy-uline.
Write:/P sy-uline(L).
Write:/P(L) sy-uline.
Uline.
Uline /P.
Uline /P(L).
CSC Private CA-AS India team Slide 95
Vertical Lines

Write:/ sy-vline.
Write:/P sy-vline.
CSC Private CA-AS India team Slide 96
Blank Lines

Skip.
Skip 2.
Skip to line 5.
CSC Private CA-AS India team Slide 97
Formatting Options
Write f option.
CSC Private CA-AS India team Slide 98
Formatting Options contd.
Different Options
Left-justified.
Centered.
Right-justified.
No-gap.
No-zero.
No-sign.
CSC Private CA-AS India team Slide 99
Formatting Options contd.
Under g.
Using Editmask m.
Decimals d.
Round r.
Exponent e.
CSC Private CA-AS India team Slide 100
Formatting Options contd.
Left-justified, centered, Right-justified

Data a(50) value ABCD.
Write:/ a,
/ a centered,
/ a right-justified.
CSC Private CA-AS India team Slide 101
Formatting Options contd.
NO-GAP

Data : p(4) value ABCD,
q(4) value EFGH.
Write:/ p no-gap, q.
CSC Private CA-AS India team Slide 102
Formatting Options contd.
NO-ZERO

Data a(5) type n value 123.
Write:/ a no-zero.
CSC Private CA-AS India team Slide 103
Formatting Options contd.
NO-SIGN

Data : a type i value 20,
b type i value 25,
c type i.
C = a - b.
Write: / c no-sign.
CSC Private CA-AS India team Slide 104
Formatting Options contd.
Under g.

Data : a(4) value ABCD,
b(4) value EFGH.
Write:/10 a,
/ b under a.
CSC Private CA-AS India team Slide 105
Formatting Options contd.
Using edit mask m.

Data : a like sy-datum.
A = sy-datum.
Write:/ a,
/ a using edit mask _ _ / _ _ / _ _ _ _.
CSC Private CA-AS India team Slide 106
Formatting Options contd.
Decimals d.

Data : a type p decimals 3.
a = 123.456.
Write:/ a decimals 2.

CSC Private CA-AS India team Slide 107
Formatting Options contd.
Round r.

Data a type p decimals 3.
a = 123.456.
Write:/ a round -2,
/ a round -1,
/ a round 1.
CSC Private CA-AS India team Slide 108
Formatting Options contd.
Exponent e
Data a type f.
a = 123456.789.
Write:/ a exponent -2,
/ a exponent -1,
/ a exponent 1,
/ a.
CSC Private CA-AS India team Slide 109
Formatting Options contd.

Format intensified. (default)
Format intensified off.
Format inverse.
Format inverse off. (default)
Format color n.
CSC Private CA-AS India team Slide 110
Formatting Options contd.
write:/ a color n.
n can be col_background.
1 or col_heading ( Blue)
2 or col_normal (White)
3 or col_total (Yellow)
4 or col_key (Olive green)

CSC Private CA-AS India team Slide 111
Formatting Options contd.
Write :/ a color n.
n can be
5 or col_positive (Green)
6 or col_negative (red)
7 or col_group (violet)

You might also like