01 abap book - basics
TRANSCRIPT
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 1/57
ABAP BASICS
ABAP TRAINING MATERIAL
Updated on - Apr 20, 2004 Page 1 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 2/57
ABAP BASICS
TABLE OF CONTENTS
SOME FACTS ABOUT SAP 4
WORKING WITH R/3 SYSTEM 6
SAP R/3 logon Scrn!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!6
Logg"ng O##!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$
U%"ng Tr&n%&c'"on Co(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$
G''"ng )l* "n ') R/3 %+%',!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-.
Wor"ng 0"') R/3 1%r %%%"on%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--
R/3 ARCHITECTURE --
Cl"n' / Sr2r &rc)"'c'1r!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-
T)r '"r &rc)"'c'1r o# R/3!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-3
ABAP/4 E5ELOPMENT WORKBENCH -4
ATA ICTIONARY -6
Ao1' &'& "c'"on&r+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-6
A(2&n'&g%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-6
T&l% "n ABAP/4 ("c'"on&r+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-7
Cr&'"on o# '&l!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.
Cr&'"ng o,&"n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.
Cr&'"ng &'& El,n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.
GENERAL INTROUCTION TO ABAP/4
C)&r&c'r"%'"c% o# ') ABAP/4 *rogr&,,"ng l&ng1&g%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3
REPORTS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!4
IALOG PROGRAMS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!8
Updated on - Apr 20, 2004 Page 2 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 3/57
ABAP BASICS
ATA TYPES AN ATA OB9ECTS :
&'& T+*%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:
&'& O;c'%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$
K"n(% o# &'& O;c'%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$
P&r&,'r%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3.
WRITE STATEMENT 3
For,&''"ng o1'*1'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!33
For,&''"ng o*'"on% #or &ll (&'& '+*%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!34
For,&''"ng o*'"on% #or n1,r"c #"l(%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!34
BRANCHES 36
Br&nc)"ng 0"') IF %'&',n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!36
Br&nc)"ng 0"') CASE %'&',n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3:
LOOPING 3$
Loo*"ng 0"') O %'&',n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3$
Loo*"ng 0"') WHILE S'&',n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3$
TRANSLATE co,,&n(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!4-
In%r' %'&',n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!4:
U*(&' %'&',n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!4:
l' %'&',n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!4$
Updated on - Apr 20, 2004 Page 3 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 4/57
ABAP BASICS
So, F&c'% &o1' SAP
After the Internet, SAP R/3 is one of the hottest topis in the o!p"ter ind"str# and the o!pan#
that de$e%oped it& It is targeted to !ost ind"stries, !an"fat"ring, retai%, oi% ' gas,
phar!ae"tia%, (an)ing, ins"rane, te%eo!!"niation, *ransport, he!ia% and so on& A%%
!a+or hardare endors ere f"%%# engaged to partner ith SAP. A*'*, U, Co!pa, I,
S"n ha$e s"pported and ertified R/3 p%atfor!&
SAP has %ist of !a+or ons"%tants a%% o$er the or%d %i)e Anderson Cons"%ting, Prie aterho"se
Cooper ' #(rand, rnst ' 6o"ng, P8 and !an# !ore&
*he o!pan# (ehind R/3 is SAP A8, fo"nded (# fo"r for!er I e!p%o#ees in 1972& *he
o!pan#:s head"arters are in a%%dorf, a s!a%% 8er!an ton& *he o!pan# na!e, SAP standsfor S6S*S, APPICA*I;<S and PR;=UC*S in data proessing& In 1992 R/3 as
introd"ed and in 1995 SAP A8 as ran)ed fifth a!ong independent softare $endors& ;ne of
the reasons for SAP:s s"ess is that sine it is a standard pa)age, it an (e onfig"red in
!"%tip%e areas and adapted to speifi need of a o!pan#& *oda#, !ore than 21,>00 "sto!ers
in o$er 120 o"ntries r"n !ore than >9,700 insta%%ations of SAP? softare& ith s"(sidiaries in
!ore than 50 o"ntries, the o!pan# is %isted on se$era% e@hanges, in%"ding the ran)f"rt
sto) e@hange and <6S "nder the s#!(o% BSAP&
SAP has to !ain prod"ts in the ("siness softare !ar)et, ainfra!e s#ste! R/2 and C%ient-
ser$er R/3& oth are targeted to ("siness app%iation so%"tions& Dere R indiates RA *I&
R/2 is SAP A8 !ainfra!e softare that r"ns on I, Sie!ens and other o!pati(%e e"ip!ent&
*his t#pe of so%"tion annot (e open, ("t ith A tehno%og#, R/2 an (e %in)ed ith R/3
s#ste! and share data& *his s#ste! is !ain%# targeted at enterprises ith data-intensi$e and
entra%iEed ind"stries&
R/3 is the prod"t that has rea%%# p%aed SAP A8 as the %eader in the o"ntr#& *his o!p%e@
C%ient/ser$er s#ste! is ore of o"r o"rse& *he g%o(a% aeptane of R/3 is not on%# (ea"se it
aters a%% o!p%e@ needs of ("siness ("t a%so this internationa% aeptane is (ea"se of R/3:sinternationa% app%ia(i%it#& or SAP this does not !ean ha$ing softare a$ai%a(%e in different
%ang"ages, ("t a%so o$ering "rren#, ta@es, ega% pratie onerning DR, I!port/e@port
reg"%ations& SAP a%so $a%"es its "sto!ers and it is shon (# the o!prehensi$e set of "a%it#
ser$ies p"t (# SAP to he%p "sto!ers d"ring the proess of i!p%e!enting and s"pporting the
R/3 s#ste!s& *hese ser$ies in%"de prod"t infor!ationF training, insta%%ation and "pgrade
ser$ie %i)e.
Updated on - Apr 20, 2004 Page 4 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 5/57
ABAP BASICS
OSS< ;n%ine Ser$ie S#ste! is one of the pri!ar# so"res of ser$ie and s"pport pro$ided (#
SAP& ith ;SS, "sto!ers an searh the SAP infor!ation data(ase and find so%"tions for
errors and pro(%e!s ith R/3 s#ste!s& 6o" an a%so s"(!it #o"r pro(%e!s to SAP&
Con%1l'"ng Sr2"c< ith re!ote ons"%ting ser$ie "sto!er reei$es i!!ediate and "pdated
tehnia% s"pport and ansers to their "estions&
M&"n'n&nc %r2"c< *his is the (asi and !ost o!!on t#pe of s"pport for "sto!ers in
tehnia% s"pport and ansers to their "estions&
In#or,&'"on Sr2"c< *hese are the $ario"s infor!ation so"res for reei$ing detai%ed
infor!ation a(o"t the R/3 s#ste!, !ar)eting (roh"res, s#ste! do"!entation, training
infor!ation and !an# !ore things&
Pr2n'"2 %r2"c%< *he pri!ar# one is the ar%# ath Ser$ie, hih ens"res s"essf"% andeffiient insta%%ation of the R/3 s#ste! in a%% phases& *his ser$ie !a)es reg"%ar/perfor!ane
he)s and ana%#Ees the s#ste! to identif# potentia% pro(%e!s, he%p s#ste! !anagers and SAP
ad!inistrators to t"ne the s#ste!& Soon after the ar%# ath session, SAP sends the "sto!er a
report ith the res"%t of the ana%#sis and reo!!endations for a$oiding potentia% pro(%e!s s"h
as data(ase (eo!ing f"%%&
So o$era%% SAP R/3 is an open %ient/ser$er softare s#ste!, designed to !anage ("siness
infor!ation needs of an entire enterprise& *he ho%e dataf%o of SAP R/3 or)s in an
integrated a#, hih !eans the data needs to (e entered +"st one and the s#ste! a"to!atia%%#
"pdates other %ogia%%# re%ated data&
Updated on - Apr 20, 2004 Page 5 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 6/57
ABAP BASICS
WORKING WITH R/3 %+%',
*he SAP R/3 presentation interfae (eha$es $er# si!i%ar%# to an# other t#pia% indo
app%iation and is a%so )non as SAP8UI& *he first sreen that #o" o!e aross in R/3 s#ste!
is SAP %ogon sreen&
SAP R/3 logon Scrn
*his is the first sreen that appears hen #o" "se SAP %ogon "ti%it#& It has fo"r fie%ds. the %ient,
the "ser, the passord and the %ang"age&
Cl"n'< Dere #o" enter the %ient n"!(er& *he %ient is gro"p of "sers ho has si!i%ar rights& It
an (e gro"p of "sers in a ("siness entit# or a ho%e ("siness entit# or a ho%e o!pan#&
♦ U%r< *he na!e of the SAP "ser identifiation& Users of the SAP s#ste! are %ient-speifi,
hih !eans that "ser (e%onging to one %ient is $a%id to on%# the parti"%ar %ient&♦ P&%%0or(< It is the passord that has (een assigned (# the s#ste! ad!inistrator&
♦ L&ng1&g< SAP R/3 s#ste! s"pports !"%tinationa% %ang"age on the sa!e s#ste! at the sa!e
ti!e, hih is $er# "sef"% for !"%tinationa% o!panies ith different (ranhes in se$era%
o"ntries and possi(%# "sing different %ang"ages&
After entering a%% the fie%ds press <*R )e# and s#ste! i%% ta)e #o" to AI< <U sreen&
Updated on - Apr 20, 2004 Page > of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 7/57
ABAP BASICS
User !ight get different sreens hen he %ogs on, depending "pon defa"%t settings of the "ser
!aster reord i&e&, if "ser is =;PR then the sreen hih he often or)s on is editor
sreen and he an go diret%# to this sreen, if s#ste! ad!inistrator sets this sreen for the "ser&
Main features of any R/3 window are as follows:
♦ R/3 standard indo e%e!ents (eha$e e@at%# the sa!e, as an# other standard indo
app%iation o"%d, %i)e !ini!iEing a sreen, setting the ati$e indo et&
♦ ro! *;P to ;**;, R/3 indo an ontain t#pia% e%e!ents s"h as he) (o@es,
p"sh ("ttons, inp"t fie%ds and fo%%oing e%e!ents.
♦ Mn1 &r is the first e%e!ent of the e$er# R/3 indo& It ontains the !en" ite!
orresponding to the parti"%ar R/3 app%iation& *he to !en" options S6S* and DP
are a%a#s present in e$er# R/3 indo& S6S* !en" option ontains a%% "ti%ities and
f"ntions, and is a$ai%a(%e to "ser at a%% the ti!es& *he DP !en" ontains a%% the a$ai%a(%e
options for the different t#pes and !ethods of o(taining on%ine he%p in the s#ste!&
♦ S'&n(&r( 'ool &r& *he seond R/3 indo e%e!ent "% *r%n' "n 2r+ R/3 0"n(o0& It isnothing ("t a o%%etion of ions, hih perfor! o!!on f"ntions %i)e sa$ing the o(+et,
e@it et& *he $ario"s ions on std& *oo% (ar are as fo%%os Gfro! %eft to rightH.
En'r Co,,&n( F"l( S&2 B&c
E="' C&ncl Pr"n' F"n(
F"n( N=' F"r%' P&g Pr2"o1% P&g N=' P&g
L&%' P&g Hl*
A%% ions in R/3 indo app%iation s"pport ;CUS propert#& It !eans, if #o" p%ae "rsor
o$er an ion, the s#ste! i%% sho the f"ntion of the ion&
♦ A**l"c&'"on 'ool &r< *he ne@t part of the sreen ontains ions !ost o!!on%# "sed in that
parti"%ar tas) or transation&
♦ S'&'1% &r is the (otto! %ine of the sreen and "s"a%%# shos errors or infor!ation !essages
to the "ser& It a%so in%"des other infor!ation s"h as s#ste! id, session n"!(er, %ient,
ser$er na!e and the response ti!e&
In '0n &**l"c&'"on 'ool &r &n( %'&'1% &r +o1 )&2 0or"ng &r&> 0)"c) "% different for
different sreens&
Updated on - Apr 20, 2004 Page 7 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 8/57
ABAP BASICS
Logg"ng O##
User an %og off the R/3 s#ste! fro! an# sreen& *here are three a#s of %ogging off the R/3 s#ste!,
hih are as fo%%os.
♦ ro! the en" (ar hoose S6S* → ;8 ;& In this ase, #o" get the %og off dia%og
(o@, hih infor!s the "ser that an# data not sa$ed i%% (e %ost if ontin"ing ith the %og off
proed"re&
♦ Use/< transation ode in the o!!and fie%d& *his is dangero"s, sine it does not as) if
#o" ant to sa$e the data&
♦ C%i)ing on the I* ("tton on the R/3 initia% sreen&
U%"ng Tr&n%&c'"on Co(
*he R/3 s#ste! pro$ides an a%ternati$e and effiient a# of se%eting !en" options for !o$ing
aro"nd the tas)s and f"ntions of the SAP s#ste! (# "sing transation ode diret%# in theo!!and fie%d&
hen !o$ing ith transation, #o" an go to an# part of the s#ste! (# !ere%# t#ping a
transation ode in the o!!and fie%d, pro$ided #o" ha$e a"thoriEation for that& *hat
transation ode is the fo"r-harater ode assoiated ith an# tas)& # t#ping the transation
ode and pressing <*R )e#, the s#ste! ta)es #o" diret%# to the initia% sreen for transation&
hene$er an# transation ode is entered in the o!!and fie%d, it gets stored in the ("ffer
!e!or#& If #o" %i) on drop don arro, s#ste! disp%a#s %ist of transation ode a%read#
entered and #o" an se%et fro! this %ist or enter ne one& *here are a%!ost te%$e tho"sand and
ninet# fo"r transations in SAP& or e$er# tas), transation ode is assoiated and it an (e
fo"nd (#
♦ SYSTEM STATUS
Stat"s indo is popped "p hih ontains the transation ode in the trans fie%d&
♦ *hro"gh YNAMIC MENU! It gi$es the %ist of tas)s& If #o" %i) on the top %ine of the
app%iation areas and pressing the searh and searh ne@t ("tton i%% gi$e #o" the transation
ode& /N 0"ll '& +o1 'o "n"'"&l %crn o# R/3
Updated on - Apr 20, 2004 Page J of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 9/57
ABAP BASICS
I!portant transation odes, hih #o" i%% (e "sing often, are.
E("'or%
• S37 "ntion "i%der
• S3J AAP/4 ditor
• S41 en" Painter
• S51 Sreen Painter
• S71 or! Painter
"c'"on&r+
• S11 Initia% AAP/4 ditionar# !aintain sreen&
Bro0%r%
• SJ0 ;(+et (roser&
• S1> =ata (roser&
T%'"ng Tool%
• S30 R"nti!e Ana%#sis
• S*05 SK *rae
Updated on - Apr 20, 2004 Page 9 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 10/57
ABAP BASICS
G''"ng )l* "n ') R/3 %+%',
R/3 in%"des !an# possi(i%ities to get on%ine he%p for a%!ost e$er# e%e!ent of the s#ste!, "sers
an get he%p for entire app%iation, for speifi f"ntion, for definitions of $ario"s ter!s "sed in
SAP, i&e&, 8%ossar#, !essages, sreens, fie%ds et&
6o" o(tain DP (# "sing an# of the fo%%oing options.
♦ Hl* #1nc'"on fro! the R/3 indo, hih is o!p"%sor# !en" ite! of e$er# R/3 indo&
♦ ? Icon of standard too% (ar&
♦ F- #1nc'"on +!
*he SAP s#ste! pro$ides he%p on !ost fie%ds that appear on the R/3 s#ste!& *o get he%p on
parti"%ar fie%d, position the "rsor o$er it and press he%p ("tton or 1 f"ntion )e#&
Another a# in hih R/3 s#ste! pro$ides he%p is hen s#ste! disp%a#s error !essages in the
stat"s (ar& =o"(%e %i)ing on the stat"s (ar shos additiona% infor!ation a(o"t the !essage&
Updated on - Apr 20, 2004 Page 10 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 11/57
ABAP BASICS
Wor"ng 0"') R/3 1%r %%%"on%
A $er# i!portant feat"re pro$ided (# SAP& In R/3 s#ste! #o" an or) ith !ore than one tas)
at an# gi$en point of ti!e, (# !eans of opening sessions& 6o" an a%% sessions as independent
R/3 indo here #o" an perfor! other tas)s&
# defa"%t, a "ser an open NINE sessions si!"%taneo"s%# and an or) or !o$e aro"nd ith a%%
sessions at the sa!e ti!e& Sessions an (e %osed at an# ti!e, itho"t ha$ing to %og off the
s#ste!&
User an reate ne sessions fro! an#here as CRA* SSSI;< o!es "nder S6S*
!en" hih is a$ai%a(%e in e$er# R/3 indo&
SYSTEM CREATE SESSION ;r /O "n co,,&n( #"l(
*his i%% open a ne session or indo and i%% p%ae it in front of a%% other indos&
*o !o$e a!ong sessions
♦ L"st !o"se %i) on an# part of the R/3 indo to !a)e that session ati$e&
♦ Co!(ination of A* M *A )e#&
R/3 Arc)"'c'1r*he o$era%% R/3 s#ste! in%"des the fo%%oing o!ponents.
*he UPPER %a#er, the f"ntiona% %a#er ontains the different ("siness app%iation& *he
integration of a%% app%iation depends "pon (asis s#ste!& App%iations are de$e%oped in AAP/4
ang& GAd$aned "siness App%iation the 4th generation %ang"ageH
Updated on - Apr 20, 2004 Page 11 of 57Created on - Apr 20, 2004
;perating S#ste! =ata ase <etor)
asis S#ste!
;r
idd%e a#er
"siness
App%iations
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 12/57
ABAP BASICS
*he R/3 (asis softare is the set of progra!s and too%s, hih interfaes ith the operating,
s#ste!, the "nder%#ing data(ase, protoo%s and the presentation interfae& *his %a#er ena(%es a%%
the app%iation to or) e@at%# the sa!e a# no !atter hat operating s#ste! or data(ase, the
s#ste! is insta%%ed on& It is an independent %a#er and ens"res the integration of a%% !od"%es&
esides a%% these speifi +o(s, ASIS s#ste! a%so ontains fo%%oing o!ponents and th"s
pro$ides !ore additiona% feat"res&
♦ AAP/4 de$e%op!ent or)(enh, hih in t"rn in%"des !an# feat"res %i)e repositor#, data
ditionar#, or)(enh organiEer, hih i%% (e dis"ssed in %ater part of the topis&
♦ AAP/4 %ang"age, s#ste! ad!inistrati$e too%s, a%% these o!ponents are "sed to ontro%,
t"ne the R/3 s#ste!&
♦ Spoo% s#ste! !anages the for!atting of data for printing and passing it to the host spoo%
s#ste!&
♦ ai% s#ste! #o" an send and reei$e !ai% fro! the o"tside or%d GInternetH&
♦ Co!!"niation interfae to e@terna% s#ste! fro! R/3 s#ste!. anages o!!"niation atthe ;S %e$e% G*CP/IPH, at the data(ase %e$e% ' (eteen app%iations too& GRC, =I, and
AH
♦ =ata(ase interfae *his o!ponent s"pports different Re%ationa% data(ases fro! different
$endors& *he !ain tas) of data(ase interfae is to on$ert the SK re"est fro! the SAP
de$e%op!ent en$iron!ent to the data(ase:s on SK en$iron!ent&
♦ a)gro"nd proessing ith this fai%it# #o" an s"(!it #o"r progra! for (a)gro"nd
e@e"tion&
ASIS s#ste! ontains the %a#ered o!ponents that fai%itate the de$e%op!ent of %ient/ser$er
arhitet"re&
Cl"n' / Sr2r &rc)"'c'1r
C%ient/Ser$er arhitet"re is !ain%# a softare onept that in%"des a set of ser$ie pro$iders
and ser$ie re"esters& *he set of o!p"ters ats as ser$ie pro$iders and is a%%ed as ser$er&
*he sets of softare o!ponent, hih at as ser$ie re"ester, are a%%ed as %ient&
In the %ient/ser$er arhitet"re, the data(ase ats %i)e a %i(rar# %er) retrie$ing (oo)s fro! the
she%f& *he "ser progra!s ha$e to re"est data(ase for the data instead of searhing for the data
the!se%$es& *his a# there is no ris) of the "sers p"tting the data o"t of order& If the desireddata is in "se, the data(ase !a)es the "ser ait "nti% it is free&
*he !a+or ad$antage of the %ient/ser$er arhitet"re is that the ser$er is a$ai%a(%e for a n"!(er
of %ients and there is distri("tion of or) (eteen the %ients and the ser$er& *he "ser direts
the re"est to the %ientF the %ient in t"rn "nderstands the "ser:s re"est and redirets the re"est
to the ser$er& *he ser$er retrie$es the data, gi$es it to %ient&
Updated on - Apr 20, 2004 Page 12 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 13/57
ABAP BASICS
6o" an ha$e %ient and ser$er on the sa!e !ahine or on different !ahines& ah %ient has a
orresponding proess inside the ser$er&
;ne of the !ost "sed %ient/ser$er onfig"rations ith the R/3 s#ste! is the 3 tiered arhitet"re,
hih separates a s#ste!:s o!p"ter into 3 f"ntiona% gro"ps.
T)r '"r &rc)"'c'1r o# R/3
=ata(ase Ser$er
App%iation Ser$er
Presentation Ser$er
GUn%i)e nor!a% C%ient/ser$er arhitet"re here #o" ha$e on%# to %a#ers i&e&, %ient and ser$er&H
Co!!"niation a!ong the 3 tiers is ao!p%ished (# standard protoo% ser$ies %i)e *CP/IP orCPIC GCo!!on Progra!!ing Interfae Co!!"niationH&
In a(o$e ase data(ase ser$er stores the data entra%%#& asia%%# ontains data(ase engine and
assoiated proesses& *he data(ase %a#ers ontain the data(ase s#ste! "sed (# a%% ser$ers&
App%iation ser$er ontains softare o!ponents to r"n the progra!& It ontains a SAP )erne%,
hih an r"n AAP/4 progra!&
*he presentation ser$er is #o"r %ient thro"gh hih #o" send #o"r re"est to app%iation ser$er&
It is a%so a%%ed as SAP graphia% "ser interfaes )non as SAP8UI and is a$ai%a(%e in indos
3&1, indos <*, indos 95, and aintosh& *he# a%% %oo) si!i%ar hate$er "nder%#ing
s#ste! the# are r"nning on&
*he SAP8UI in%"des a%% graphia% apa(i%ities of indo interfae ith !en" (ars, too% (ars,
fo"s propert#, and the entire !o"se %i)ing operations&
Updated on - Apr 20, 2004 Page 13 of 57Created on - Apr 20, 2004
DatabaseServer
ApplicationServer
ApplicationServer
ApplicationServer
PresentationServer
PresentationServer
PresentationServer
PresentationServer
PresentationServer
PresentationServer
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 14/57
ABAP BASICS
*he R/3 s#ste! is open s#ste! in the sense that it an r"n on an# operating s#ste! or an#
data(ase and an# o!!"niation tehno%og#& It !eans that.
♦ R/3 s#ste! an r"n on an# operating s#ste! p%atfor! s"h as U<I, <*, 95, AS/400&
♦ It s"pports $ario"s R=S s"h as SK ser$er, ;ra%e, Infor!i@, =2&
♦ Standard 8UIs s"pported (# R/3 are indos 95, <*, indos 3&1, and aintosh&
♦ SAP an "se standard o!!"niation protoo%s *CP/IP, CPIC, ;S/=C/= for netor)&
ABAP/4 2lo*,n' Wornc)
*he de$e%op!ent en$iron!ent of SAP R/3 s#ste! is f"%%# integrated set of $ario"s de$e%op!ent
too%s, data ditionar#, and progra!!ing %ang"age& "%% integration of a%% o!ponents !eans that
hanges in an# part ha$e a diret and i!!ediate effet on a%% app%iation "sing those
o!ponents&
*he sreen of AAP/4 de$e%op!ent or)(enh %oo)s %i)e
Tool% o# ABAP/4 0ornc)
For *rogr&,,"ng<
Updated on - Apr 20, 2004 Page 14 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 15/57
ABAP BASICS
♦ AAP/4 ditionar# =efining, !aintaining and storing the data ditionar# of the SAP R/3
s#ste! stores a%% the ditionar# o(+ets in%"ding ta(%es re%ationship and De%p infor!ation&
*ransation ode for this is S11&
♦ AAP/4 editor Creating and !aintaining the AAP/4 progra!, editing f"ntion !od"%es,
%ogia% data(ase, and sreens& *ransation ode is S3J&
♦ "ntion %i(rar# =efining and !aintaining the AAP/4 f"ntion !od"%es& *ransation ode
is S37&
♦ Sreen painter =esigning and !aintaining the sreens in transation& *ransation Code is
S51&
♦ en" painter =esigning and !aintaining the !eans for graphia% "ser interfae& *ransation
ode S41&
For N&2"g&'"ng<
♦ ;(+et (roser anaging and organiEing the de$e%op!ent o(+et in a hierarhia% for!&
*ransation ode is SJ0&
♦ AAP/4 repositor# infor!ation <a$igating and searhing for the ditionar# ;(+ets,
de$e%op!ent o(+ets and re%ationship o(+ets& *ransation ode SJ4&
♦ =ata (roser <a$igating in the data ta(%es of the data(ase& *ransation ode is S 1>&
For 1gg"ng<
♦ S; trae tra)ing the data(ase a%%s fro! the s#ste! transation and progra!s& *ransation
ode is S*05&
♦ =e("gger Stopping the progra! and ana%#Eing the res"%ts of the e@e"tion of e$er# progra!
state!ent&
♦ R"nti!e Ana%#sis Ana%#Eing the perfor!ane the s#ste! a%%s *ransation ode is S30
For Org&n"@"ng<
♦ or)(enh organiEer ontro%%ing and )eeping tra) of de$e%op!ent or) and tea! re%ated
de$e%op!ent pro+ets and !anaging $ersions of de$e%op!ent o(+ets& *ransation ode is
S09&
♦
*ransport s#ste! perfor!ing and !anaging the transport of de$e%op!ent o(+et arossdifferent s#ste!& *ransation ode is S01
Updated on - Apr 20, 2004 Page 15 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 16/57
ABAP BASICS
&'& "c'"on&r+
*he AAP/4ditionar# is entra% or)(enh repositor# "ti%it# pro$iding the data definition and
the infor!ation re%ationship that are %ater "sed in a%% the ("siness app%iation ithin R/3
*he AAP/4 ditionar# an (e seen as a %ogia% representation or a s"perior %a#er o$er the
ph#sia% "nder%#ing data(ase& *his data(ase !"st s"pport the re%ationa% data !ode%& *his !ode%
is strit%# fo%%oed (# data ditionar#&
Ao1' &'& "c'"on&r+
A =ata ditionar# in o!p"ting ter!s is the %o1rc o# "n#or,&'"on "n 0)"c) %+%', (&'& "%
(#"n(& *he data ditionar# is the cn'r&l"@( &n( %'r1c'1r( %o1rc o# "n#or,&'"on #or
1%"n%% &**l"c&'"on%! 6o" an sa# that it is ore of a e%%-str"t"red de$e%op!ent en$iron!ent&
*he e%e!ents that !a)e "p a ditionar# are )non as !etadata& M'&(&'& "% ') 'r, #or ')
(&'& 0)o% #1nc'"on "% 'o (%cr" o')r (&'&! =ata in ditionar# is not the at"a% data %i)e
e!p& na!e or e!p& address ("t rather a t#pe of data hose f"ntion is to define the properties of
the data s"h as t#pe, %ength, and re%ationship&
A(2&n'&g%
Ad$antage of "sing data ditionar# is a$oiding inonsistenies hen defining data t#pe that i%%
%ater (e "sed in different app%iations& *his a$oids red"ndanies&
hen a t#pe is defined in the ditionar#, it is a$ai%a(%e to an# progra! in the app%iation& A
hange in the definition of a t#pe of data in the ditionar# a"to!atia%%# affets an# other data or
progra!, hih has this data&
Again, data ditionar# is a fast and effiient a# to anser "estions s"h as hih entries e@ist
in a ta(%e of the data(ase, hat the str"t"re of ta(%e is&
Updated on - Apr 20, 2004 Page 1> of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 17/57
ABAP BASICS
Ac'"2&'"on o# ("c'"on&r+ o;c'%
or a ditionar# o(+et to (e effeti$e at r"nti!e, that is, for a ditionar# o(+et to (e a$ai%a(%e
for "se ithin a progra!, transation, and so on, it !"st (e in ati$e stat"s& or o(+ets to
(eo!e ati$e, R/3 in%"des the AC*IA*I;< f"ntion&
hen a ta(%e or aggregated o(+et is ati$ated, it is p%aed at the disposa% of the s#ste! as a
r"nti!e o(+et in a a# that !a)es it a$ai%a(%e "i)%# for the app%iation progra! to aess
re%e$ant infor!ation of ne ati$ated o(+ets&
hen a ditionar# o(+et is !odified, that !eans that the o(+et pre$io"s%# e@isted and ati$ated&
6o" need to reati$ate the o(+et after !odifiation&
hen !ass ati$ation is perfor!ed !assi$e%#, it !ight ta)e a "ite a %ong ti!e& *hen it sho"%d
(e in the (a)gro"nd s#ste!& *his t#pe of ati$ation is )non as (a)gro"nd ati$ation&
*he AAP/4 =ata ditionar# is the entra% o!ponent of AAP/4 repositor#& A =ata ditionar#
is entra%iEed and str"t"red so"re of infor!ation for ("siness app%iation& *he AAP/4
ditionar# is the ore of the R/3 de$e%op!ent s#ste!& It is the so"re of e$er# definition, ithin
R/3, fro! the $er# (asi do!ain to the o!pan# data !ode%& It is tota%%# integrated ith other
too%s of the de$e%op!ent en$iron!ent %i)e sreen painter, !en" painter, and editor&
So!e of the !ain a$ai%a(%e f"ntions in the AAP/4 ditionar# are as fo%%os.
♦ Add, de%ete, !odif#, and !anage the definition of the ditionar# data&
♦ Preser$e the data integrit#&
♦ e the entra% so"re of infor!ation e&g& fro! the ditionar# #o" get the infor!ation a(o"t
the defined re%ationship (eteen to ta(%es or e$en the diretor# te%%s hether ta(%e is ati$e
or e!pt#&
♦ It a%so per!its do"!entation of s#ste! data&
In the R/3 s#ste! instead of or)ing ith origina% o(+ets, #o" or) ith interna% representation
of o(+ets& ith this t#pe of operation the s#ste! perfor!ane is enhaned and has the
ad$antage that the de$e%op!ent too%s, sreen interpreters a%a#s aess "rrent data&
hen an# of the data ditionar# o(+ets are "sed in other parts of the de$e%op!ent or)(enh
for e@a!p%e, in progra!, progra!!er on%# has to enter a ta(%e na!e or fie%d na!e& *he s#ste!
a"to!atia%%# )nos a%% the properties and infor!ation of the fie%d&
Updated on - Apr 20, 2004 Page 17 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 18/57
ABAP BASICS
*o a%% AAP/4 ditionar#, fro! the !ain !en", Tool% ABAP/4 0ornc) (&'&
("c'"on&r+ or n'r 'r&n%&c'"on SE--!
&'& ("c'"on&r+ o;c'%<
♦ T&l< is a 2= data !atri@ ontaining ros and o%"!ns& Ros ontain data hi%e o%"!n
indiates fie%ds& *a(%e an ontain 0 or !"%tip%e ros&
♦ S'r1c'1r. is a s)e%eta% $ie of a ta(%e& It ontains the definition of o%"!ns and don:t ha$e
an# ontents& Str"t"re is genera%%# a te!p%ate (ased on hih a ta(%e is reated& *he (asi
differene (eteen str"t"re and ta(%e is that the str"t"re does not e@ist at the "nder%#ingdata(ase s#ste! %e$e%& Str"t"re e@ists as definition in the ditionar#&
♦ 5"0%< A $ie is an i!aginar# ta(%e& It ontains data, hih is rea%%# stored in other ta(%es&
*he ontents for the $ie are d#na!ia%%# generated hen a%%ed fro! progra!&
♦ &'& l,n'< is definition of the properties and t#pe for a ta(%e fie%d& It is an inter!ediate
o(+et (eteen the o(+et t#pe do!ain and the ta(%e fie%d& A fie%d in R/3 s#ste! is a%a#s
assoiated ith a data e%e!ent, hih at the sa!e ti!e is re%ated to do!ain&
Updated on - Apr 20, 2004 Page 1J of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 19/57
ABAP BASICS
♦ o,&"n< is for!a% definition of the data t#pe fro! a tehnia% point of $ie& It sets the
attri("tes s"h as data t#pe, %ength, possi(%e $a%"e range and so on&
♦ Loc o;c'%< *hese t#pes of o(+ets are "sed for %o)ing the aess to data(ase reords in
ta(%e& *his !ehanis! is "sed to enfore data integrit# that is to "sers annot "pdate the
sa!e data at the sa!e ti!e& ith %o) o(+ets #o" an %o) ta(%e-fie%d or ho%e ta(%e&
♦ S&rc) Hl* O;c'%< , hih gi$es %ist of possi(%e $a%"es for either pri!ar# )e#s or non-
pri!ar# )e#s&
T&l% "n ABAP/4 ("c'"on&r+
*a(%es are the (asi o(+ets in R/3 app%iation& *here are a%!ost J000 ta(%es in R/3 s#ste!&
o%%oing t#pes of ta(%es are a$ai%a(%e
• *ransparent ta(%es• Poo% ta(%es
• C%"ster ta(%es
ro! "ser point of $ie, a%% ta(%es are "sed to store data hate$er (e the t#pe of ta(%e& *here is
no differene in the (eha$ior or operation of these ta(%es& A%% of the! an (e !anaged (# "sing
standard ;P< SK& Doe$er fro! an ad!inistrator point of $ie transparent ta(%e do e@ists
ith the sa!e str"t"re (oth in the ditionar# as e%% as in the data(ase, e@at%# ith the sa!e
data and fie%ds& hi%e other to are not transparent in the sense that the# are not !anagea(%e
diret%# "sing data(ase s#ste! too%s& 6o" an aess these ta(%es in R/3 en$iron!ent fro! the
AAP/4 ditionar#& 6o" annot "se nati$e SK on these ta(%es& Poo% or %"ster ta(%es are
%ogia% ta(%es, hih are arranged as reords of transparent ta(%e&
A ta(%e is !ade "p of ros and o%"!ns& hen the ta(%e is reated, its o%"!ns are na!edF data
t#pe is s"pp%ied for eah o%"!n& *here an (e on%# one data $a%"e in eah o%"!n of eah ro
in a ta(%e& Reord or as it is a%%ed in different R=S is nothing ("t gro"p of fie%ds& hi%e a
o%"!n is a fie%d of a ta(%e, a ta(%e is an inde@ed fi%e& *he !ain inde@ is a%%ed as pri!ar# )e#,
hih an (e a sing%e fie%d or o!(ination of )e#s or fie%ds& A pri!ar# )e# an (e defined as a
fie%d, hih indefinites a sing%e "ni"e reord of the ta(%e& A ta(%e annot ha$e reord ith
d"p%iate pri!ar# )e#&
In an# R=S, ta(%es are re%ated to eah other& "t to re%ate ta(%e to eah other it is neessar#
that one of the ta(%es ontain so!e infor!ation of other ta(%e& ost%# ta(%es are re%ated to eah
other thro"gh pri!ar# )e#s& *he pri!ar# )e# of one ta(%e, if it e@ists in other ta(%e then it is
a%%ed foreign )e#& *his t#pe of data(ase !anage!ent s#ste! !eans that there is so!e
red"ndan# of data& "t "sing nor!a%iEation proed"res a$ai%a(%e an !ini!iEe it& ;ne of the
!ost i!portant f"ntions of foreign )e# is to ens"re data integrit#& or e@a!p%e sa# #o" ha$e
Updated on - Apr 20, 2004 Page 19 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 20/57
ABAP BASICS
P ta(%e, hih has fie%ds. e!p& no&, e!p&na!e, dept&ode, sa%ar# and #o" ha$e =P* ta(%es,
hih has dept&ode and dept&des& *hen in =P* ta(%e dept&ode is pri!ar# )e# hi%e
dept&ode in P ta(%e is foreign )e#& If #o" enter dept&ode for parti"%ar e!p%o#ee in P
ta(%e the dept&ode sho"%d e@ist in =P* ta(%e& S#ste! i%% he) the $a%"e for dept&ode in
=P* ta(%e, and if does not e@ist then i%% f%ash error& In this ase =P* is a%%ed he) ta(%e
hi%e P is foreign )e# ta(%e&
Cr&'"on o# '&l
Steps to reate a ta(%e
♦ Create do!ain
♦ Create data e%e!ent
♦ Create at"a% ta(%e
Cr&'"ng o,&"n
=o!ain as a%read# e@p%ained defines the tehnia% properties of a fie%d s"h as t#pe and $a%"e
range& A do!ain an (e reated fro! initia% sreen of data ditionar# (# %i)ing on reate and
%i)ing do!ain Radio("tton& Para!eters to (e passed are.
=ata t#pe. here #o" need to enter the data t#pe a$ai%a(%e in SAP&
ie%d %ength. ie%d %ength is the n"!(er of $a%id position&
a%"e ta(%e. <a!e of a ta(%e to (e entered& *he fie%ds referring to this do!ain !a# on%# ass"!e
$a%"es ontained in the $a%"e ta(%e&
;ne the do!ain is reated, sa$e and ati$ate it, so that it an (e "sed for f"rther o(+ets G(asi
r"%e of ditionar#H&
Cr&'"ng &'& El,n'
*he seond step of ta(%e reation is to reate data e%e!ent& It assigns a ertain !eaning to theta(%e fie%d, hih are defined "sing that data e%e!ent& A =ata e%e!ent a%a#s needs to (e defined
o$er a do!ain and fie%d is a%a#s defined o$er a data e%e!ent& *his a%%os a%% fie%ds ith sa!e
tehnia% properties to "se the sa!e data e%e!ent&
Para!eters to (e passed hen reating a data e%e!ent.
Short te@t. andator# fie%d&
Updated on - Apr 20, 2004 Page 20 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 21/57
ABAP BASICS
=o!ain. A !andator# fie%d& If the do!ain does not e@ist, SAP an ta)e #o" diret%# to
do!ain definition sreen&
*e@t e%e!ent. 6o" an enter desription is short or %ong te@t for the fie%d& *his te@t is "sed hen
entering data for these fie%ds&
Sa$e and ati$ate&
Cr&'"on o# &c'1&l '&l
Para!eters to (e passed for reation of ta(%e.
Short desription. andator# fie%d&
=e%i$er# %ass. As per User Re"ire!ent
*a(%e fie%ds. Speif# hether pri!ar# )e#& In this ase it is !andator# to enter data
e%e!ent&
=ata %ass. sta(%ishes the ph#sia% area of the data(ase&SiEe ategor#. A%%os #o" to speif# esti!ated spae re"ire!ent for the ta(%e&
"rther don "nder ("ffering s"are (o@, the s#ste! a%%os speif#ing hether ta(%e is going to
(e ("ffered& hen a ta(%e is ("ffered, it is %oaded into the ta(%e ("ffer fro! the app%iation
ser$er !e!or# and it i%% re!ain there "nti% #o" sith off or re(oot s#ste!&
If the ta(%e is to (e ("ffered, #o" need to speif# the t#pe of ("ffering& "%% is for entire ta(%e
hi%e partia% is for on%# those reords hih are (eing aessed&
;ne the ta(%e is reated, it has to (e generated or ati$ated to (e a(%e to aess (# other o(+ets
%i)e progra!s&
Updated on - Apr 20, 2004 Page 21 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 22/57
ABAP BASICS
Gnr&l In'ro(1c'"on 'o ABAP/4
SAP origina%%# de$e%oped the progra!!ing %ang"age AAP/4 GAd$aned "siness App%iation
Progra!!ingH for interna% "se to pro$ide (est or)ing onditions for de$e%opers& SAP
onstant%# i!pro$es the %ang"age to adapt to the inreasing re"ire!ents of the ("siness
app%iations& At present, AAP/4 is the on%# too% for de$e%oping app%iations at SAP&
SAP "sto!ers "se AAP/4 for their on de$e%op!ents& *he AAP/4 =e$e%op!ent
or)(enh ontains a%% too%s #o" need to reate and !aintain AAP/4 progra!s& AAP/4
progra!s are not o!p%ied ("t generated& ="ring generation, the s#ste! reates a so-a%%ed
r"nti!e o(+et fro! the so"re ode and the progra! attri("tes& hen #o" start the progra!, the
s#ste! e@e"tes the r"nti!e o(+et&
AAP/4, a fo"rth generation %ang"age, ontains a%% "s"a% ontro% str"t"res and !od"%ariEing
onepts for str"t"red progra!!ing& *he three parts of the AAP/4 %ang"age are.
Str"t"re and e@e"tion of AAP/4 progra!s
asi %ang"age e%e!ents
Progra!!ing reports
Progra!!ing dia%ogs
Structure and execution of ABAP/4 programs are essentia%%# different fro! entire%# se"entia%
progra!!ing %ang"ages s"h as ;R*RA<, PASCA, or C& AAP/4 instead shares ertain
si!i%arities ith !od"%ar, e$ent-orient progra!!ing %ang"ages s"h as is"a% asi or LAA&
*he to !ost i!portant state!ents onerning str"t"re and e@e"tion are.
An AAP/4 progra! has a !od"%ar str"t"re&
or e@e"tion, #o" need a speia% r"nti!e en$iron!ent&
*his !eans, that AAP/4 so"re te@ts a%a#s onsist of a o%%etion of progra! !od"%es Gone
sing%e !od"%e in the easiest aseH or the se"entia% set of state!ents& *he indi$id"a% progra!
!od"%es onsist of se"entia% e%e!ents& *he set of state!ents of a progra! !od"%e is a%so a%%ed
proessing (%o)&
*he r"nti!e en$iron!ent is responsi(%e for a%%ing the indi$id"a% progra! !od"%es one after the
other& *he r"nti!e en$iron!ent is the ABAP/4 processor, hih an o!!"niate ith te list processor or te dialog processor , depending on the progra! t#pe&
Progra! f%o ithin the indi$id"a% proessing (%o)s is se"entia%, as #o" )no it fro! other
se"entia% progra!!ing %ang"ages Gfor e@a!p%e, ;R*RA<, PASCA and CH& ithin the
proessing (%o)s, #o" an "se the genera% ontro% state!ents for the progra! f%o, s"h as I,
=;S, DI, AAP/4 does not ontain 8;*; e%e!ents&
Updated on - Apr 20, 2004 Page 22 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 23/57
ABAP BASICS
e !ain%# "se progra!s that onsist of a sing%e proessing (%o) on%# and, therefore, (eha$e
!ost %i)e%# %i)e progra!s of other se"entia% progra!!ing %ang"ages& or progra!!ing
app%iations, the entire%# se"entia% onept is not s"ffiient& SAP disting"ishes (eteen to
genera% t#pes of app%iation progra!s.
R*or'%< 6o" "se reports to read data(ases and represent the res"%ts in %ists& Reports are
o%%etions of proessing (%o)s that the s#ste! a%%s depending on e$ents&
"&log *rogr&,%< 6o" an dia%og progra!s to e@e"te transations, hih "s"a%%# read and
hange data(ases& =ia%og progra!s are o%%etions of proessing (%o)s Gso-a%%ed !od"%e
poo%sH that are a%%ed (# a sreen f%o %ogi& *he third part of the User:s 8"ide desri(es dia%og
progra!!ing in detai%&
R*or'% c&n c&ll ("&log *rogr&,% &n( 2"c 2r%&!
In its easiest $ersion, an AAP/4 progra! ontains one sing%e se"entia% piee of oding and,
th"s, one sing%e proessing (%o)&
C)&r&c'r"%'"c% o# ') ABAP/4 *rogr&,,"ng l&ng1&g%
♦ =e%arati$e e%e!ents for de%aring data of different t#pe and str"t"res&
♦ ;perationa% e%e!ents for !anip"%ating data&
♦ Contro% e%e!ents to ontro% proessing f%o&
♦ AAP/4 is !"%ti-%ing"a%& *e@t e%e!ents s"h as tit%es, headings, and te@t (od# are stored
separate%#, independent of the progra! odes& *h"s, #o" an hange, trans%ate, and !aintain
te@t e%e!ents itho"t ha$ing no adapt the oding&
♦ AAP/4 s"pports ("siness-re%ated data t#pes and operations& 6o" an e@e"te a%"%ations
"sing speia% data and ti!e fie%ds& *he s#ste! a"to!atia%%# e@e"tes a%% neessar# t#pe
on$ersions&
♦ AAP/4 pro$ides a n"!(er of f"ntions for proessing harater strings&
♦ AAP/4 a%%os #o" to define and a%% s"(ro"tines& 6o" an e$en a%% s"(ro"tines of other
progra!s& *here are different a#s of ho to pass para!eters to and fro! the S"(ro"tines&
♦ AAP/4 ontains a speia% t#pe of s"(ro"tine, a%%ed f"ntion !od"%e& "ntion !od"%es are
stored and !aintained in a entra% %i(rar#& *he# ha$e %ear%# defined data interfaes to the
a%%ing progra!& 6o" an test f"ntion !od"%es in a stand-a%one !ode independent of thea%%ing progra!&
♦ AAP/4 ontains an SK s"(set a%%ed ;P< SK& ;P< SK a%%os #o" to read and
hange data(ase ta(%es independent of the "nder%#ing data(ase s#ste!&
♦ AAP/4 a%%os #o" to define and proess interna% ta(%es that e@ist on%# for the e@e"tion
period of the progra!& Interna% ta(%es effiient%# s"pport the "sage of data(ase ta(%es and
a%%o #o" to i!p%e!ent o!p%e@ data str"t"res in a progra!&
Updated on - Apr 20, 2004 Page 23 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 24/57
ABAP BASICS
♦ AAP/4 a%%os #o" to store data not on%# in data(ases ("t a%so as se"entia% fi%es on
app%iation and presentation ser$ers&
REPORTS
♦ Reports are AAP/4 progra!s&
♦ 6o" "se reports to e$a%"ation data fro! data(ase ta(%es& *he res"%ts of s"h an e$a%"ation
an (e disp%a#ed on the sreen or printed for!&
♦ Reports are stand-a%one progra!s&
♦ *he "ser an e@e"te reports diret%# $ia the progra! na!e, for e@a!p%e, (# hoosing
S#ste! ? Uti%ities ? Reporting&
♦ A report progra! ontains a o%%etion of proessing (%o)s for different e$ents that are
a%a#s triggered e@terna%%#& In a report, #o" an reat on e$ents (# progra!!ing the
orresponding proessing (%o)s or ignore the e$ents (# not riting the orresponding proessing (%o)s& A report itse%f ne$er reates e$ents&
♦ Reports an "se %ogia% data(ases or se%et state!ents defined (# de$e%oper&
♦ or eah app%iation, SAP s"pp%ies %ogia% data(ases& ;r #o" an easi%# reate %ogia%
data(ase #o"rse%f&
♦ $ent ontro% of a report orresponds to a ertain she!e.
hen a report is e@e"ted, the AAP/4 proessor reates together ith the %ogia% data(ase
"sed Gif an#H a se"ene of ertain e$ents for hih #o" an progra! proessing (%o)s& *he
hrono%og# of the e$ents is G!ore or %essH
Steps in$o%$ed in reating a Report.
-! Proc%%"ng ') %lc'"on %crn
After starting a report, the se%etion sreen a%%os the "ser to enter %i!its or ontro%
$a%"es for f"rther report proessing& *he report an ontain se$era% proessing (%o)s for
e$ents d"ring se%etion sreen proessing, for e@a!p%e, for he)ing the inp"t $a%"es&
! R&("ng ') (&'&&%
After se%etion sreen proessing o!e the e$ents for reading the data(ase& ither the
report reads data fro! re%ationa% data(ases it "sing the orresponding AAP/4 state!ents
Gopen SKH or %ea$es this tas) to a %ogia% data(ase& In the %atter ase, the %ogia% data(asereates a se"ene of e$ents to a%%o the report to op# the data&
3! E2&l1&'"ng (&'& &n( cr&'"ng l"%'%
="ring or after reading the data(ase the report reates the o"tp"t %ist& ="ring %ist reation,
se$era% e$ents a%%o #o" to %a#o"t the o"tp"t %ist Gfor e@a!p%e, %a#o"t the page headerH&
4! O1'*1''"ng & l"%'
Updated on - Apr 20, 2004 Page 24 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 25/57
ABAP BASICS
*he %ast part of the proessing se"ene ontro%%ed (# the AAP/4 proessor is the %ist
o"tp"t on the sreen or printer& hen disp%a#ing the %ist on the sreen, "ser an trigger
other reports, that are interati$e and are e$ent dri$en& or e@a!p%e, (# %i)ing the
!o"se& # progra!!ing proessing (%o)s for these e$ents, #o" hange a nor!a% report
to a so-a%%ed In'r&c'"2 r*or'& If a report does not ontain e$ent )e#ords, the entire
oding of the report (e%ongs to a sing%e proessing (%o), hih is a%%ed (# a standard
e$ent& *his standard e$ent is triggered diret%# after proessing the se%etion sreen&
IALOG PROGRAMS
♦ 6o" "se dia%og progra!s to e@e"te transations& *he "sers of dia%og progra!s in dia%og
sessions read and hange data(ase ta(%es& Apart fro! the at"a% data proessing G;pen
SKH, "pdate and en"e"e onepts are of great i!portane hen progra!!ing dia%ogs&♦ =ia%og progra!s are not stand- a%one
♦ *o e@e"te dia%og progra!s, the# !"st (e %in)ed to at %east one sreen that itse%f is %in)ed to
a transation ode& *he transation ode deter!ines the initia% sreen ith hih the dia%og
session starts&
♦ =ia%og progra!s are ontro%%ed (# sreen f%o %ogi
♦ *he at"a% AAP/4 dia%og progra! is a so-a%%ed !od"%e poo%& A !od"%e poo% ontains a
o%%etion of dia%og !od"%es that are a%%ed (# the sreen f%o %ogi&
♦ *o eah !od"%e poo%, at %east one, ("t "s"a%%# se$era% sreens are a%%oated& ah sreen has
f%o %ogi& *he f%o %ogi onsists of P; Gproess efore o"tp"tH and PAI Gproess After
Inp"tH (%o)s& *his f%o %ogi does not "se the AAP/4 progra!!ing %ang"age and the
AAP/4 ditor too%, ("t a speia% state!ent set and the Sreen Painter too%, hih #o" a%so
"se to %a#o"t sreens& *he f%o %ogi !ain%# ontains the hrono%ogia%%# ordered a%%s of the
!od"%es in the orresponding !od"%e poo%&
♦ !e collection of PB" flow logic, screen, and PA# flow logic is called $ynamic program
%$ynpro&& A !od"%e poo% !"st ha$e at %east one d#npro& ah sreen of a dia%og session
th"s is the $isi(%e part of a d#npro, to hih a%so the f%o %ogi (e%ongs& *he proessing %ogi
of a dia%og session is stored in the orresponding !od"%e poo% in the for! of AAP/4
!od"%es&
♦ *he AAP/4 !od"%es in the !od"%e poo% are separated into P; and PAI !od"%es& *he
P; or PAI (%o)s of the f%o %ogi of eah d#npro of a !od"%e poo% an a%% eah P; or
PAI !od"%e of this !od"%e poo%&
♦ 6o" an "se AAP/4 state!ents in the proessing %ogi of the !od"%e poo% to ontro% the
hrono%og# of the different d#npros& After starting a dia%og session $ia the transation ode,
hih is fir!%# onneted to a d#npro of the !od"%e poo%, the sreen f%o %ogi passes "ser
entries to the proessing %ogi in the AAP/4 !od"%e poo%& *he proessing %ogi proesses
Updated on - Apr 20, 2004 Page 25 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 26/57
ABAP BASICS
the "ser entries Gdata(ase aessesH and, if re"ired, defines the appropriate s"(se"ent
sreens&
Updated on - Apr 20, 2004 Page 2> of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 27/57
ABAP BASICS
&'& T+*% &n( &'& O;c'%
=ata t#pes and data o(+ets are essentia% o!ponents of the AAP/4 t#pe onepts& oth an (e
de%ared and !aintained (# "ser& Un%i)e other progra!!ing %ang"ages in AAP/4 #o" an
reate =A*A *6PS independent%#&
&'& T+*%
♦ Are p"re desriptions
♦ <o !e!or# is assoiated ith data t#pes&
♦ =esri(es the tehnia% properties of data o(+ets&
Str"t"re and definition %assif# data t#pes& Can (e of.
1& %e!entar# or str"t"red2& Predefined or "ser defined
Pr(#"n( U%r(#"n(
<*AR6 C, =, , I, <, P, *, ased "pon e%e!entar#
=ata t#pes&
6o" an "se diret%# &g&,
*6PS. n"!(er t#pes I&
Can:t a%%oate !e!or# to
t#pes&
S*RUC*UR= Predefined t#pes are
*AS
User defined str"t"red
t#pes are ie%d String and
interna% ta(%es&
Updated on - Apr 20, 2004 Page 27 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 28/57
ABAP BASICS
&'& O;c'%
♦ =ata o(+ets are "nits reated d"ring r"nti!e&
♦ =ata o(+et annot e@ist itho"t data t#pe&
♦ ;"pies !e!or# spae&
K"n(% o# &'& O;c'%
-! INTERNAL ATA OB9ECTS
♦ L"'r&l
A %itera% has a fi@ed $a%"e&
@ RI*. B;R DAR=
♦ 5&r"&l%
=A*A state!ent is "sed to reate $aria(%es
@ =A*A. <U *6P I
<U is a $aria(%e de%ared (# =A*A state!ent& An# $aria(%e, hih #o" "se in progra!,
need to (e de%ared (efore #o" "se it and an (e done (# =A*A state!ent&
Dere $aria(%e is de%ared (# referring to e@isting data t#pe&
aria(%e an a%so (e de%ared (# referring e@isting data o(+et&
@& e ha$e a%read# de%ared <U (# =A*A state!ent&
=A*A. PRIC I <U&
Dere $aria(%e is de%ared (# "sing I para!eter, hih te%%s s#ste! that prie has a%% the
attri("tes of data o(+et <U i&e&, PRIC is a%so of t#pe I&
*he !ain differene (eteen *6P and I para!eter hen defining or de%aring the
o(+et is that *6P is "sed to refer e@isting =A*A *6P Ge%e!entar# or str"t"red or "ser
definedH hi%e I is "sed to de%are data o(+ets ith referene to e@isting =A*A
;LC*S&
♦ Con%'&n'
Constant is a data o(+et, hih ontains fi@ed $a%"e thro"gh o"t the progra!& Constant an
(e de%ared in progra! (# "sing C;<S*A<* state!ent&
@& C;<S*A<*. I<* *6P I AU 15&
Updated on - Apr 20, 2004 Page 2J of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 29/57
ABAP BASICS
In progra! $a%"e of I<* annot (e hanged& If #o" gi$e a state!ent %i)e I<* N 20&
In this ase s#ste! i%% gi$e error&
! ETERNAL ATA OB9ECTS
Are defined in ta(%es i&e&, in AAP/4 ditionar#& 6o" an aess this data fro! ta(%e&
*AS. SI8D*
=A*A. SA*S I SI8D*-SA*SA&
3! SYSTEMEFINE ATA OB9ECTS
SPAC ' S6S* ARIAS %i)e s#-"na!e, s#-dat"!, ' s#-repid&
4! SPECIAL ATA OB9ECTS
PARA*RS. are $aria(%e, hih an aept $a%"e fro! "ser&
SC*I;<S CRI*RIA. are speia% interna% ta(%es to aept $a%"e range fro! "ser&
N( #or &'& '+*%<
Consider the fo%%oing e@a!p%e&
=A*A. fna!eG20H,
!na!eG20H,
%na!eG20H,
add1G20H,
add2G20H,
add3G20H&
If #o" ha$e =A*A state!ent %i)e a(o$e, and if #o" need to hange the %ength of a%% the fie%ds sa#fro! 20 to 25, then #o" need to hange a%% the fie%ds i&e&, going thro"gh eah and e$er#
state!ent&
"t onsider the fo%%oing ase here *6PS has (een "sed&
*6PS.strG20H
=A*A.fna!e t#pe str,
Updated on - Apr 20, 2004 Page 29 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 30/57
ABAP BASICS
na!e t#pe str,
na!e t#pe str,
Add1 t#pe str,
Add2 t#pe str,
Add3 t#pe str&
In this ase if #o" need to hange the %ength of a%% fie%ds fro! 20 to 25& *hen +"st hange the
%ength of S*R and hange i%% (e ref%eted for a%% the fie%ds&
If #o" define a%% the t#pes in *6P-P;; i&e&, g%o(a% definition of a%% the t#pes, #o" an "se
these t#pes an#here and in an# progra!&
P&r&,'r%
Para!eter state!ent is "sed to aept inp"t fro! "ser& PARA*R state!ent is "sed hen#o" ant "ser to enter data and depending "pon hat he enters #o" need to ta)e ation& *he
para!eter state!ent de%ares the $aria(%e and a%so a%%os s#ste! to aept data into that
$aria(%e&
S#nta@&
Para!eters. n"! t#pe I&
Dere para!eter state!ent de%ares the $aria(%e and reates the se%etion sreen on hih "ser
enters the data i&e&, in this ase n"! is de%ared of t#pe I and "ser an enter an# n"!(er& ntered
$a%"e is stored in the sa!e $aria(%e and an (e "sed in progra!&
=ata. ! t#pe I
Para!eters. n"! t#pe I
N n"! 5
rite. / O*he n"!(er is:, !&
6o" an define defa"%t $a%"es ith para!eter state!ent for e@a!p%e
Para!eter. n"! t#pe I defa"%t 12&
In this ase hen se%etion sreen is disp%a#ed the defa"%t $a%"e is disp%a#ed& User an either "se
sa!e $a%"e or o$errite the $a%"e&
Para!eter of t#pe harater and %ength N 1, an (e disp%a#ed as Che)(o@ and Radio("tton&
Para!eter. C1 as Che)(o@,C2 as Che)(o@&
Para!eter. R1 Radio("tton gro"p g1,
R2 Radio("tton gro"p g1&
hen para!eter is defined as Radio("tton, it needs to (e attahed to one gro"p& ;n%# one
Radio("tton of one gro"p an (e %i)ed&
Updated on - Apr 20, 2004 Page 30 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 31/57
ABAP BASICS
$er# para!eter an (e assoiated ith %ang"age dependent te@t that is disp%a#ed on the
se%etion sreen& *his an (e done ith the he%p of te@t e%e!ents&
Updated on - Apr 20, 2004 Page 31 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 32/57
ABAP BASICS
WRITE S'&',n'
*he (asi APA/4 state!ent for o"tp"tting data on the sreen is RI*&
S#nta@.
RI* fie%dQ optionQ&
*his state!ent o"tp"ts the fie%d fQ to the "rrent %ist in its standard o"tp"t for!at&
# defa"%t, the %ist is disp%a#ed on the sreen&
*he fie%d fie%dQan (e an# $aria(%e or ta(%e fie%d or +"st %itera%&
PR;8RA =;
RI*. /OD;:&
hen #o" start this progra!, the s#ste! %ea$es the "rrent sreen i&e&, #o"r editor sreen and
(ranhes to the o"tp"t sreen, hih is a%so a%%ed as %ist sreen.
*he %ist sreen has the sa!e na!e as the tit%e of the progra! speified in the progra! attri("tes&
irst %ine on the sreen ontains the %ist header& # defa"%t, the %ist header is the sa!e as the tit%e
of the progra!& *he "rrent page n"!(er G1H appears on the right& *he %ist header is fo%%oed
(# one %ine and then the o"tp"t is disp%a#ed&
rite . OD;:&
rite . O;R DAR=:
;n the sreen, the o"tp"t is nor!a%%# %eft +"stified& "t in a(o$e ase, (ea"se e ha$e "sed to
RI* state!ents, the o"tp"t fie%ds are disp%a#ed one after the other, eah separated (# one
o%"!n Gi&e&, one (%an)H& If there is not eno"gh spae for an o"tp"t fie%d on the "rrent %ine, a
ne %ine is started&
A%!ost a%% s#ste!-defined fie%ds are right +"stified e@ept ;A*, I<*8R, and PAC=
i&e&, n"!(er fie%d& *he n"!eri data t#pes , P, and I are right +"stified and padded ith (%an)s
on the %eft& If there is s"ffiient spae, tho"sands of separators are a%so o"tp"t& If a t#pe P fie%dontains dei!a% p%aes, the defa"%t o"tp"t %ength is inreased (# one&
ith the data t#pe =, the interna% for!at of a date differs fro! its o"tp"t for!at& hen #o" "se
the RI* state!ent for o"tp"tting data, the s#ste! a"to!atia%%# o"tp"ts dates of t#pe = in the
for!at speified in the "ser:s !aster reord Ge&g& ==//6666 or /==/6666H&
Updated on - Apr 20, 2004 Page 32 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 33/57
ABAP BASICS
For,&''"ng o1'*1'
6o" an position the o"tp"t of a RI* state!ent on the sreen (# !a)ing a for!at
speifiation (efore the fie%d na!e as fo%%os.
S#nta@.
RI* A* /TposQTG%enQHT fQ,
here
• Othe s%ash:/O denotes a ne %ine,
• posQ is a n"!(er or $aria(%e denoting the position on the sreen,
• %enQ is a n"!(er or $aria(%e %ong denoting the o"tp"t %ength&
or $aria(%es #o" need to !ention the A*, for diret $a%"es it is not neessar#&
=A*A. < *6P I AU 10,
P;S *6P I AU 11,
** G10H AU O12345>7J90:
RI* A* P;S G<H **&
*his prod"es the fo%%oing o"tp"t on the sreenF
*he te@t 12345>7J90 appears in the te@t&
If the o"tp"t %ength %enQ is too short, feer haraters are disp%a#ed& <"!eri fie%ds are
tr"nated on the %eft and prefi@ed ith an asteris) GH& A%% other fie%ds are tr"nated on the right,
("t no indiation is gi$en that the fie%d is shorter&
=A*A. <UR *6P I AU 12345>7J90,
** G10H AU Oa(defghi+:&
RI*. G5H <UR, /G5H **&
*his prod"es the fo%%oing o"tp"t.7J90
a(de
In the defa"%t setting, #o" annot reate e!pt# %ines ith the RI* state!ent&
RI*. O;ne:,
/O :,
/ O*o:
Updated on - Apr 20, 2004 Page 33 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 34/57
ABAP BASICS
*he o"tp"t %oo)s as fo%%os.
;ne
*o
*he s#ste! s"ppresses %ines that ontain nothing ("t e!pt# spaes&
6o" an "se $ario"s for!atting options ith the RI* state!ent&
S#nta@
RI*VVVV fie%dQ optionQ
For,&''"ng o*'"on% #or &ll (&'& '+*%
"ption Purpose
*-LUS*II= ;"tp"t is %eft +"stified&
C<*R= ;"tp"t is entered&
RI8D*-LUS*II= ;"tp"t is right +"stified&
<;-8AP *he (%an) after the fie%d fQ is o!itted&
<;-R; If a fie%d ontains on%# Eeros, these are
rep%aed (# (%an)s& or t#pe C and <
fie%ds, %eading Eeros are rep%aed
a"to!atia%%#&
For,&''"ng o*'"on% #or n1,r"c #"l(%
O*'"on P1r*o%
<;-SI8< *he %eading sign is not o"tp"t&
=CIAS dQ dQ defines the n"!(er of digits after the
dei!a% point&
P;<<* eQ In t#pe fie%ds, the e@ponent is defined in
eQ
R;U<= rQ *#pe P fie%ds are !"%tip%ied (# 10G-rH
and then ro"ndedCURR<C6 Q or!at aording to "rren# Q in ta(%e
*CUR&
U<I* "Q *he n"!(er of dei!a% p%aes is fi@ed
aording to the "nit
"Q speified in ta(%e *00> for t#pe P
fie%ds&
Updated on - Apr 20, 2004 Page 34 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 35/57
ABAP BASICS
Hor"@on'&l l"n%
6o" an generate horiEonta% %ines on the o"tp"t sreen (# "sing the fo%%oing s#nta@.
S#nta@
UI<
i%% dra a horiEonta% %ine&
UI< G10H
i%% start draing horiEonta% %ine fro! 10th o%"!n position&
RI* at 10G40H S6-UI<
*his state!ent dras a horiEonta% %ine fro! 10th position&
5r'"c&l l"n%
6o" generate $ertia% %ines one the o"tp"t sreen (# "sing the fo%%oing s#nta@.
S#nta@
RI* A* /T posQTT S6-I<&
Bl&n l"n%
6o" an generate (%an) %ines on the sreen (# "sing the fo%%oing s#nta@ .
S#nta@
SIP n"!(erQT
Starting on the "rrent %ine, this state!ent generates n"!(erQ (%an) %ines on the o"tp"t sreen&
If no $a%"e is speified for n"!(erQ, one (%an) %ine is o"tp"t& In the standard setting, #o"
annot reate e!pt# %ines ith the RI* state!ent a%one&
*o position the o"tp"t on a speifi %ine on the sreen "se.
S#nta@
SIP *; I< n"!(erQ
*his state!ent a%%os #o" to !o$e the o"tp"t position "pards or donards&
Updated on - Apr 20, 2004 Page 35 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 36/57
ABAP BASICS
Br&nc)%
i)e other higher progra!!ing %ang"ages, AAP/4 pro$ides standard )e#ords to ontro% the
f%o of a progra!&
Us"a%%# AAP/4 progra!s get e@e"ted state!ent (# state!ent& an# ti!es #o" need to s)ip
fe state!ents depending "pon ertain onditions i&e&, #o" hange the f%o of progra!& *his
an (e done (#.
♦ r&nc)"ng IF> CASED
♦ loo*"ng O> WHILED
Doe$er, "n%i)e other %ang"age here #o" ha$e on%# interna% ontro%, ABAP/4 )&% "n'rn&l
con'rol &n( ='rn&l con'rol o# ') *rogr&, #lo0!
♦ *he "n'rn&l con'rol is steered (# standard )e#ords as !entioned a(o$e& 6o" define this
in #o"r progra! ode&
♦ *he ='rn&l con'rol is stored (# e$ents& $ents are generated either fro! other AAP/4
progra!s or fro! interati$e "ser inp"t G%i)e, for e@a!p%e, "sing the !o"se to %i) on the
sreenH& *he s#ste! does not neessari%# proess the state!ents in the sa!e se"ene as the#
are %isted in an AAP/4 progra!& *his !a)es AAP/4 an e$ent-dri$en progra!!ing
%ang"age& *he e@terna% ontro% p%a#s an i!portant ro%e !ain%# for report progra!s&
Br&nc)"ng 0"') IF %'&',n'
*he I state!ent a%%os #o" to ("2r' ') *rogr&, #lo0 'o & *&r'"c1l&r %'&',n' (%o),
depending on a ondition& *his state!ent (%o) onsists of a%% the o!!ands hih o"r
(eteen an I state!ent and the ne@t SI, S, or <=I state!ent&
S#nta@
Iondition1Q
state!ent (%o)Q
S state!ent (%o)Q
<=I
If the first ondition is tr"e, the s#ste! e@e"tes a%% the state!ents "p to the end of the first
state!ent (%o) and then ontin"es proessing after the <=I state!ent&
Updated on - Apr 20, 2004 Page 3> of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 37/57
ABAP BASICS
*o introd"e a%ternati$e onditions, #o" an "se SI state!ents& If the first ondition is
fa%se, the s#ste! proesses the fo%%oing SI state!ent in the sa!e a# as the I state!ent&
S (egins a state!ent (%o) hih is proessed if none of the I and SI onditions is
tr"e& *he end of the %ast state!ent (%o) !"st a%a#s (e on%"ded ith <=I&
I ondition1Q&
state!ent (%o)Q
SI ondition2Q&
state!ent (%o)Q
SI ondition3Q&
state!ent (%o)Q
S&
state!ent (%o)Q
<=I&
AAP/4 a%%os "n%i!ited nesting of I <=I state!ent (%o)s, ("t the# !"st ter!inate
ithin the sa!e proessing (%o)& In other ords, an I <=I (%o) annot ontain an e$ent)e#ord&
Br&nc)"ng 0"') CASE %'&',n'
*o e@e"te different state!ent (%o)s depending on the ontents of parti"%ar data fie%ds, #o" an
either "se I state!ent or the CAS state!ent as fo%%os.
S#nta@
CAS fQ&
D< f1Q&
state!ent (%o)Q
D< f2Q&
state!ent (%o)Q
D< f3Q&
state!ent (%o)Q
D< ;*DRS&
state!ent (%o)Q
<=CAS&
*he s#ste! e@e"tes the state!ent (%o) after the D< state!ent if the ontents of fQ e"a%s
the ontents of fiQ, and ontin"es proessing after the <=CAS state!ent& *he state!ent
(%o) after the optiona% D< ;*DRS state!ent is e@e"ted if the ontents of fQ do not
e"a% an# of the fiQ ontents& *he %ast state!ent (%o) !"st (e on%"ded ith <=CAS&
*he onditiona% (ranhing "sing CAS is a shorter and si!p%er for! of si!i%ar proessing ith
I& hen #o" ha$e !an# onditions I (eo!es !ore o!p%iated in s"h ases CAS is "sed&
Updated on - Apr 20, 2004 Page 37 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 38/57
ABAP BASICS
LOOPING
Loo*"ng 0"') O %'&',n'
If #o" ant to rite #o"r na!e sa# for 10 ti!es, #o" need to rite RI* state!ent for 10
ti!es&
hen #o" ant to proess a state!ent !ore than one, #o" an rite this state!ent ithin a
%oop ith the =; state!ent as fo%%os.
S#nta@
=; 5 ti!es&
rite . / na!e&
<==;&
*he s#ste! ontin"es proessing the state!ent (%o) for 5 ti!es introd"ed (# =; and
on%"ded (# <==;&
*he s#ste! fie%d S6-I<= ontains the n"!(er of ti!es the %oop has (een proessed so in this
ase hen the %oop is o$er $a%"e of s#-inde@ i%% (e 5&
In this ase #o" )no that, #o" ant to perfor! RI* state!ent for 5 ti!es& "t that is not
the ase a%a#s& an# ti!es #o" need to ter!inate the %oop depending "pon ertain onditions&
*his an (e done, (# "sing EIT or STOP state!ent&
*he i!portant point to re!e!(er hen #o" don:t #o" "se *IS option, is to a$oid end%ess
%oops hen or)ing ith the =; state!ent& If #o" do not "se the *IS option, in%"de at %east
one I*, S*;P state!ent so that the s#ste! an %ea$e the %oop&
I* and S*;P ta)es #o" o"t of that %oop&
Loo*"ng 0"') WHILE S'&',n'
If #o" ant to proess a state!ent (%o) !ore than one as %ong as a ondition is tr"e, #o" an progra! a %oop ith the DI state!ent as fo%%os.
S#nta@
=A*A. *6P I AU 0&
DI 10&
RI*. / &
N M 1&
Updated on - Apr 20, 2004 Page 3J of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 39/57
ABAP BASICS
<=DI&
*he s#ste! ontin"es proessing the state!ent (%o) introd"ed (# DI and on%"ded (#
<=DI state!ents as %ong as is %ess than 10 or "nti% the s#ste! finds an I*, S*;P&
*he s#ste! fie%d SYINE ontains the n"!(er of ti!es the %oop has (een proessed&
6o" an nest DI %oops an# n"!(er of ti!es and a%so o!(ine the! ith other %oops&
"##rnc '0n O loo* &n( WHILE is that in DI, ondition is he)ed first and if
ondition is tr"e then %oop is e@e"ted hi%e in =; %oop, the %oop gets e@e"ted first if #o" don:t
ha$e *IS option and then the ondition is he)ed Gif #o" ha$e an#H&
6o" an ha$e nested =; and DI or =; and I or I and I or an# possi(%e sit"ation&
Updated on - Apr 20, 2004 Page 39 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 40/57
ABAP BASICS
S'r"ng O*r&'"on%
AAP/4 pro$ides se$era% )e#ords for proessing data o(+ets of t#pe C, a%so )non as
harater strings&
S)"#' co,,&n(
*o shift the ontents of a fie%d, (# one position or one harater #o" an "se the SDI*
state!ent& Using SDI* a%%os #o" to shift fie%d ontents, (#te-(#-(#te or harater-(#-
harater&
ith the SDI* state!ent, #o" an e@e"te the fo%%oing.
String N OD;:&
String 1 N OA ; 6;U:&
String 2 N O;R DAR=:&
Shift string
Shift string1 (# 2 p%aes&
Shift string2 right&
Shift string1 (# 2 p%aes ir"%ar&
*he o"tp"t i%% (e
; # defa"%t if nothing is speified then string is shifted (# one position&
; 6;U Dere the string is shifted (# 2 p%aes&
W;R DAR= In this ase the string is shifted to right (# one p%ae Gith %eading (%an)sH
DAR=;R In this ase the string is shifted to the %eft so that 3 haraters on the %eft appear
on the right&
R*l&c co,,&n(
6o" "se the RPAC state!ent&
S#nta@
RPACstr%QI*Dstr2QI<*;Q<8*D1QT&
AAP/4 searhes the fie%d Q for the first o"rrene of the first, 1Q positions of the pattern
str1Q& If no %ength is speified, it searhes for the pattern str1Q in its f"%% %ength&
*hen, the state!ent rep%aes the first o"rrene of the pattern str1Q in fie%d Qith the string
str2Q& If a %ength %Q as speified, on%# the re%e$ant part of the pattern is rep%aed&
RPAC S*R1 I*D S*R2 I<*; S*RI<8&
Dere ho%e string is searhed for string1 and is rep%aes ith str2&
RPAC O': I*D O:
Updated on - Apr 20, 2004 Page 40 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 41/57
ABAP BASICS
Dere the s#ste! searhes string for ' and rep%aes it ith O:&
TRANSLATE co,,&n(
S#nta@
*RA<SA*Q *; UPPR CAS&
*RA<SA*Q *; ;R CAS&
*hese state!ents on$ert a%% %oer ase %etters in the fie%d Q to "pper ase or $ie $ersa&
6o" an "se *RA<SA* to s"(stit"te the haraters in a string %i)e rep%ae& "t the !ain
differene (eteen *rans%ate and Rep%ae is that Rep%ae state!ent rep%aes on%# one o"rrene
of parti"%ar harater hi%e *rans%ate rep%aes a%% the o"rrenes of the harater&
hen "sing s"(stit"tion r"%es, "se the fo%%oing s#nta@.
S#nta@
*RA<SA* Q USI<8 rQ&
STRLEN co,,&n(
*o deter!ine the %ength of a harater string "p to the %ast harater other than SPAC, "se the
("i%t-in f"ntion S*R< as fo%%os.
S#nta@
< N S*R< G S*R H&
Dere < is defined in =A*A state!ent as t#pe i&
S*R< proesses an# operand Q as a harater data t#pe, regard%ess of its rea% t#pe& <o
on$ersions are perfor!ed&
CONENSE co,,&n(
*o de%ete s"perf%"o"s (%an)s in harater fie%ds, "se the C;<=<S state!ent.
S#nta@
C;<=<S Q <;-8APST&
*his state!ent re!o$es an# %eading (%an)s in the fie%d Q and rep%aes other se"enes of
(%an)s (# e@at%# one (%an)& *he res"%t is a %eft-+"stified se"ene of ords, eah separated (#
one (%an)& If the addition <;-8APS is speified, a%% (%an)s are re!o$ed&
CONCATENATE co,,&n(
*o onatenate separate harater strings into one, "se the C;<CA*<A* state!ent.
S#nta@
C;<CA*<A* 1Q VnQ I<*; Q SPARA*= 6 sQT&
*his state!ent onatenates the harater fie%ds 1Q to nQ and assigns the res"%t to Q&
*rai%ing (%an)s are ignored d"ring this operation&
Updated on - Apr 20, 2004 Page 41 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 42/57
ABAP BASICS
C;<CA*<A* S*R O.: S*R2 I<*; S*RI<8&
Dere str, str2 and O.: is onatenated and res"%t is stored in string&
SPLIT co,,&n(
*o sp%it a harater string into to or !ore s!a%%er strings, "se the SPI* state!ent.
S#nta@
SPI* Q A* de%Q I<*; %QV&nQ&
*his state!ent searhes the harater fie%d Q for de%i!iter strings de%Q and the parts (efore
and after the de%i!iters are p%aed in the target fie%ds 1QV&nQ&
*o p%ae a%% frag!ents in different target fie%ds, #o" !"st speif# eno"gh target fie%ds&
;therise, the %ast target fie%d is fi%%ed ith the rest of the fie%d Q and sti%% ontains de%i!iters&
SPI* S*RI<8 A* O,: I<*; P1 P2 P3 P4&
Dere the string is sp%it at O,: and is p"t into strings p1, p2, p3, p4&
♦ In ABAP/4> +o1 c&n %*c"#+ o##%' 2&l1% #or l,n'&r+ (&'& o;c'% "n &ll %'&',n'%>
0)"c) *roc%% ')% (&'& o;c'%!
*o do so, speif# the na!e of a data o(+et in a state!ent as fo%%os.
S#nta@
fQMoQTG%QHT
*he operation of the state!ent is perfor!ed for the part of the fie%d fQ that (egins at position
oQM1 and has a %ength of %Q&
If the %ength %Q is not speified, the fie%d is proessed for a%% positions (eteen oQ and the end
of the fie%d&
String N string1M3G4H&
Ass"!ing that string1 N Oa(defg+):&
Dere string i%% ontain Odefg:&
Updated on - Apr 20, 2004 Page 42 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 43/57
ABAP BASICS
OPEN SL
In the R/3 S#ste!, %ong-%ife data is stored in re%ationa% data(ase ta(%es& Str"t"red K"er#
ang"age GSKH as reated for aessing re%ationa% =ata(ase& SK has to state!ent t#pes.
=ata =efinition ang"age G==H state!ents and =ata anip"%ation ang"age G=H
state!ents&
*; in%"de SK state!ents in an AAP/4 progra!, "se <ati$e SK& *o a$oid ino!pati(i%ities
(eteen different data(ase ta(%es and a%so to !a)e AAP/4 progra! independent of the
data(ase s#ste! in "se, SAP has reated a set of separate SK state!ents a%%ed ;pen SK&
;pen SK ontains a s"(set of standard SK state!ents as e%% as so!e enhane!ents, hih
are speifi to SAP& Using ;pen SK ena(%es #o" to aess an# data(ase ta(%es a$ai%a(%e to the
SAP s#ste! regard%ess of the !an"fat"rer (e it ;ra%e, Infor!i@ et&
*he differene (eteen ;pen SK and <ati$e SK is as fo%%os.
A data(ase interfae trans%ates SAP:s ;pen SK state!ents into SK o!!ands speifi to the
data(ase in "se& <ati$e SK state!ents aess the data(ase diret%#&
;pen SK )e#ords
e#ords Used for
• SC*. Reading =ata fro! =ata(ase *a(%es
• I<SR*. Adding ines to =ata(ase *a(%es
• UP=A*. Changing ines in =ata(ase *a(%es
• ;=I6. Adding or Changing ines
• =*. =e%eting ines fro! =ata(ase *a(%es
hen "sing ;pen SK state!ents in an AAP/4 progra!, #o" !"st ens"re the fo%%oing.
1H *he data(ase s#ste! (eing addressed !"st (e s"pported (# SAP&
2H *he data(ase ta(%es (eing addressed !"st (e defined in the AAP/4 =itionar#&
Updated on - Apr 20, 2004 Page 43 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 44/57
ABAP BASICS
Slc' %'&',n'
*he fo%%oing s#ste! fie%ds p%a# an i!portant ro%e in ;pen SK operations.
SYSUBRC
As ith other AAP/4 state!ents, the ret"rn ode $a%"e in the s#ste! fie%d S6-SURC
indiates after eah ;pen SK operation hether or not the operation as s"essf"%& If an
operation is s"essf"%, S6-SURC N 0& If an operation is "ns"essf"% S6-SURC Q 0
SYBCNT
*he $a%"e in the S6-=C<* fie%d indiates ho !an# %ines ere affeted (# the operation or
ho !an# %ines ha$e a%read# (een proessed&
*o read data fro! a data(ase ta(%e, "se the SC* o!!and&
S#nta@
SC*hatQ R; ta(%e na!eQ I<*; $aria(%e, another ta(%eQT DR
onditionQT&
*his state!ent has se$era% (asi %a"ses& ah %a"se is desri(ed in the fo%%oing ta(%e&
SC*hatQ R; ta(%e na!eQ I<*; $aria(%es or another ta(%eQ DR onditionQ
*he SC* %a"se defines hether the res"%t of the se%etion is a sing%e %ine or a ho%e ta(%e,
or fe o%"!ns&
R; ta(%e na!eQ
*he R; %a"se speifies the data(ase ta(%e or $ie so"reQ fro! hih the data is to (e
se%eted&
I<*; $aria(%e, another ta(%eQ
*he I<*; %a"se deter!ines the target area targetQ into hih the se%eted data is to (e read& It
an a%so (e p%aed (efore the R; %a"se& If #o" do not speif# an I<*; %a"se, the s#ste!
"ses the ta(%e or) area& T) '&l 0or &r& "% & )&(r l"n> 0)"c) "% &1'o,&'"c&ll+
cr&'( + ') TABLES %'&',n'!
DR onditionQ
Updated on - Apr 20, 2004 Page 44 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 45/57
ABAP BASICS
*he DR %a"se speifies hih %ines are to (e read (# speif#ing onditions for the
se%etion& Choosing the ines to (e Read&
or Se%eting A%% data fro! ta(%e.
i&e&, read a%% o%"!ns and a%% the ros fro! data(ase ta(%e
S#nta@
SC* R; ta(%eQ&
GDere #o" are not speif#ing DR onditionH
Se%eting A%% =ata fro! a Sing%e ine
*o read a%% o%"!ns of a sing%e %ine fro! a data(ase ta(%e, "se the SC* state!ent as
fo%%os .
S#nta@
SC* SI<8 R; ta(%eQ VV DR onditionQ VV
*he res"%t of this state!ent is a sing%e %ine& *o !a)e s"re #o" retrie$e desired "ni"e sing%e
reord, #o" !"st %in) a%% the fie%ds hih for! the pri!ar# )e# of the data(ase ta(%e (# A<= in
the DR ondition&
Prere"isite for SC* SI<8
1& Use a%% pri!ar# )e#s in DR ondition&
2& A%a#s he) for S6-SURC&
3& C%ear or)-area for ta(%e&
Aggrg&' E=*r%%"on%
# "sing aggregate e@pressions, #o" an e@trat harateristi data fro! a o%"!n aQ of the
data(ase ta(%e&
&A. ret"rns the !a@i!"! $a%"e of the o%"!n
&I<. ret"rns the !ini!"! $a%"e of the o%"!n
&A8. ret"rns the a$erage $a%"e of the o%"!n
&SU. ret"rns the s"! $a%"e of the o%"!n
Updated on - Apr 20, 2004 Page 45 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 46/57
ABAP BASICS
&C;U<*. o"nts $a%"es or %ines as fo%%os.
-C;U<*G H ret"rns the tota% n"!(er of %ines in the se%etion&
6o" !"st in%"de spaes (eteen the parentheses and the arg"!ents& *he arith!eti operators
A8 and SU an on%# or) ith n"!eri fie%ds&
So!eti!es #o" retrie$e fe o%"!ns for! data(ase ta(%e i&e& #o" ha$e %ist in the SC*
C%a"se and I<*; C%a"se&
If there is a %ist in the SC* %a"se, #o" !"st "se the I<*; %a"se ith the SC*
state!ent& 6o" an "se either a or) area aQ or an interna% ta(%e ita(Q or %ist of $aria(%es as
an arg"!ent,
S#nta@
*AS. SI8D*&=A*A . CARRI=I I SI8D* -CARRI=,
C;<<I= I SI8D* C;<<I=&
SC* CARRI= C;<<I= R; SI8D* I<*; GCARRI=1, C;<<I=1H& RI*. /
CARRI=%,C;<<I=1&
<=SC*&
an# ti!es #o" retrie$e re%ated data fro! to or !ore ta(%es& In s"h ases #o" "se nested
se%ets + l"n"ng '&l% 0"') co,,on *r",&r+ +% & "t as far as possi(%e a$oid "sing nested
se%ets as ti!e re"ired to aess nested ta(%e is $er# high&
S#nta@
*AS. SI8D*, S;;&
SC* R; SI8D* DR CARRI= N XDX&
SC* R; S;; DR CARRI= N SI8D* -CARRI= A<=
C;<<I= N SI8D* -C;<<II=&
RI*. / SSI8D*-CARRI=,SI8D*-C;<<I=,S;;-;;I=,
<=SC*&
<=SC*&
So!e perfor!ane hints for ;pen SK state!ents
♦ eep the se%eted dataset s!a%%
eep the n"!(er of se%eted data as s!a%% as possi(%e to a$oid "nneessar# netor)
transports& Use the respeti$e ;pen SK state!ents a%a#s ith the DR %a"se& A$oid
Updated on - Apr 20, 2004 Page 4> of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 47/57
ABAP BASICS
o!p%e@ DR %a"ses& *he s#ste! !"st sp%it "p those into sing%e state!ents for the
data(ase s#ste!&
=o not "se the %ogia% <;* in DR %a"ses ("t in$erted operators instead&
*he %ogia% <;* is s"pported (# the data(ase inde@es&
♦ eep the transferred data s!a%%
♦ *ransfer on%# those o%"!ns of a data(ase ta(%e that #o" rea%%# need& A$oid SC* if
#o" do not ant to read a%% o%"!ns of a data(ase& Use a %ist in the SC* %a"se instead&
Use aggregate e@pressions in the SC* %a"se to perfor! a%"%ations instead transporting
great a!o"nts of data and a%"%ating thereafter&
♦ eep the n"!(er of data(ase aesses s!a%%
♦ Use operations on pa)ages of data instead of operations on sing%e data if #o" ant toana%#Ee se%eted data !ore than one& *o do so, transfer the data in a sing%e operation
(eteen ta(%es and interna% ta(%es&
♦ A$oid nested SC* %oops& Instead, or) ith interna% ta(%es and SC* state!ents
"sing the ;R A <*RIS addition&
In%r' %'&',n'
I<SR* state!ent inserts a sing%e reord into the data(ase ta(%e&
S#nta@
*a(%es. sf%ight&
Sf%ight-arrid N OD:&
Sf%ight-onnid N O234:&
Insert sf%ight&
*a(%e sf%ight is inserted ith the reord& *he S6WSURC is ret"rned for this state!ent& If theentr# a%read# e@ists then the S6WSURC is set to non-Eero $a%"e and #o" an do proessing for
e@isting reord (# gi$ing so!e error !essage&
U*(&' %'&',n'
Updated on - Apr 20, 2004 Page 47 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 48/57
ABAP BASICS
*o "pdate data(ase ta(%e UP=A* state!ent is "sed& *his a%%os #o" to hange either a sing%e
reord or se$era% reords&
6o" an "se UP=A* hen #o" )no hih reord #o" ant to hange& "t if #o" do not
)no hether the pri!ar# )e# of the %ine #o" ant to insert a%read# e@ists or not, #o" an "se
the ;=I6 state!ent& *he ;=I6 state!ent hanges e@isting %ines and inserts %ines hih
do not e@ist&
Sf%ight-arrid N O<:&
Sf%ight-onnid N O454:&
UP=A* SI8D* here CARRI= N OD:&
;r
*AS SI8D*&
UP=A* SI8D* S* PRIC N 1100
DR CARRI= N OD:&
Dere prie of sf%ight i%% get "pdated ith ne prie 1100&
l' %'&',n'
*o de%ete reords fro! a data(ase ta(%e, #o" "se the =* state!ent&
=* R; SI8D* DR CARRI= N OD: A<= C;<<I= N O454:&
i%% de%ete the sing%e reord here onditions are !et fro! SI8D*&
6o" an de%ete the !"%tip%e reords fro! data(ase ta(%e (# p"tting a%% the reords, hih #o"
ant to de%ete in interna% ta(%e& or e@a!p%e
=* SI8D* R; *A I*A&
In this ase hate$er #o" ha$e in interna% ta(%e i%% (e de%eted fro! SID*&
<ote. append interna% ta(%e ith a%% the entries, hih #o" ant to de%ete&
Updated on - Apr 20, 2004 Page 4J of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 49/57
ABAP BASICS
EERCISES
SIMPLE WRITE STATEMENTS
1 rite a progra!, hih generates the !ode% %ist as shon
Use these s#ste! fie%ds in #o"r progra!&
S6-=A*U, S6-UI*, S6-U<A
aintain the %ist headings
12/12/97 IRS* PR;8RA
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
*his %ist is generated
on. 12/12/1997
at. 13.40.35
(#. AAP 1
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
2 Create a %ist as shon
---------------------------------------------------------------------------------------------------
6 Co& P$t& td&
=ate. *oda#:s date Page <o& 1
---------------------------------------------------------------------------------------------------
Progra! na!e. =;
Updated on - Apr 20, 2004 Page 49 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 50/57
ABAP BASICS
SYMBOLS> ICONS AN FORMATTING
1 rite a progra! to sho the fo%%oing "sing s#ste! $aria(%es
Ghint. "se in%"de s#!(o%Q and in%"de ionQ
S#!(o%s. Ions.
*e%ephone Che)edF o)a#,
a@ !ahine =e%ete,
Dand pointing %eft, Print
Dand pointing right,
Ca"tion,
g . rite s#!Wphone as s#!(o%, Ote%ephone:&
2 rite a progra! to sho a string ith different (a)gro"nd o%o"rs&
eg&
rite ODA=R: o%or o%Wheading&
Go%Wheading is a(ap/4 na!e for gra#ish (%"e o%o"r& ;ther o%o"rs are
o%W)e# for (%"ish green, o%Wnor!a% for (right gra#, o%W(a)gro"nd for
gra#, o%Wpositi$e for green, o%Wnegati$e for red, o%Wgro"p for $io%et and
o%Wtota% for #e%%oH
3 Use or!at intensified for!at intensified off&
or!at o%or o%orWna!eQ - for!at o%or off&
or!at in$erse or!at in$erse off
4 Sho "rrent ti!e and toda#:s date&
5 Sho a $a%"e O12345>: as 12.34.5> "sing O"sing edit !as):&
> *a)e a n"!(er as O0000011:& S"ppress a%% %eading Eeros&
7 S"ppress a sign (efore a n"!(er&
Updated on - Apr 20, 2004 Page 50 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 51/57
ABAP BASICS
GENERAL PROBLEMS
1 Create an adding !ahine for n"!(ers&
*he to $a%"es to (e added !"st (e entered on the se%etion sreen as
para!eters& ;"tp"t the res"%t&
2 Create the di$iding !ahine for n"!(ers&
*he to $a%"es !"st (e entered on the se%etion sreen as para!eters&
;"tp"t the res"%t&
3 Create #o"r o"tp"t as shon (e%o&
!
! !
! ! !! ! ! !
! ! ! ! !
4 rite a progra! to aept the to n"!(ers fro! the "ser and sap the $a%"es&
5 =e%are a string Oeho: and design #o"r o"tp"t
e
e
e h
e h o
e h
e
e
Updated on - Apr 20, 2004 Page 51 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 52/57
ABAP BASICS
OENO> IFELSEIFELSEENIF> CASEENCASE
1 rite a progra! ith =o nddo %oop&
=isp%a# s"ares of n"!(ers 1 to 10
1 1
2 4
3 9
2 rite a progra! to aept a n"!(er Gsa# 2H fro! "ser and reate a !"%tip%iation ta(%e&
2 @ 1 N 2
2 @ 2 N 4VVVV
2 @ 10 N 20
3 Aept a n"!(er fro! "ser and find atoria% of the sa!e& If the n"!(er is negati$e then
disp%a# so!e !essage&
4 rite a progra! ith =o nddo %oop for first 20 n"!(ers&
- ;"tp"t sho"%d ontain on%# $en n"!(er
- ;dd n"!(ers sho"%d not (e disp%a#ed
5 Aept n"!(ers and hoie O<: or O;==: fro! the "ser and disp%a# the n"!(ers in
that range aording to "ser:s hoie&
> rite a progra! ith =o nddo %oop for first 20 n"!(ers&
- ;dd n"!(ers ' $en n"!(ers sho"%d (e disp%a#ed ith a%ternate intensities& GUse
or!at intensified on offH
7 Create a a%"%ator, hih perfor!s the fo"r (asi t#pes of a%"%ations on to ho%e
n"!(ers& *he to $a%"es and the option are to (e entered on the se%etion sreen as para!eters& ;"tp"t the res"%t ith 2 dei!a% p%aes&
J rite separate progra!s "sing OC;<*I<U: and OI*: state!ents in =;-;;P&
Updated on - Apr 20, 2004 Page 52 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 53/57
ABAP BASICS
STRING OPERATIONS
1 Aept a string and deter!ine its %ength
2 Aept a string ' n"!(er& rite the string that !an# n"!(er of ti!es&
3 Aept to strings and sap their ontents&
4 Aept to strings and onatenate into one string&
5 Aept one string ith de%i!iter G , or F H and sp%it it into to strings&
> Aept a string Oa(def: and "se shift stringQ, shift stringQ right, shift stringQ "p to
Odef:&
7 Aept a string eg& App%e& Change first o"rrene of Op: to O(:&
G"se Orep%ae: o!!andH
J Aept a string eg& App%e& Change a%% o"rrenes of Op: to O(:&
G"se Otrans%ate: o!!andH
9 Aept to strings and o!pare the to strings "sing Oo:, Oa:, Os:
Op: Go"t p"t sha%% (e Otr"e: or Ofa%se: for eah o!parison&H
10 Aept a string OAC=:& ;"tp"t on%# O=: "sing offset o!!and&
11 Aept first na!e, %ast na!e and !idd%e na!e
eg& <anda!"ri *ara)a Ra!arao disp%a# as <&*&Ra!arao
12 Aept a string& Change a%% o"rrenes of a to (&
13 Aept a n"!(er and sap first and %ast digit of the sa!e&
14 Aept a string and disp%a# the string in re$erse order
15 Aept a string and he) for pa%indro!e
Updated on - Apr 20, 2004 Page 53 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 54/57
ABAP BASICS
ATE PROBLEMS
1 Aept a date ear%ier to toda#:s date and find the differene in n"!(er of da#s&
2 Aept a date fro! "ser and disp%a# first da# of the !onth and %ast da# of the pre$io"s
!onth&
3 Aept a date fro! "ser and add si@ !onths to the date&
4 Aept a date fro! "ser and on$ert !onth part to O+an:, Ofe(: et&, and disp%a# this date&
5 rite a progra! to aept !onth& =isp%a# n"!(er of da#s in tota% !onth&
a)e "se of
- *e@t e%e!ent for #o"r se%etion sreen (o@&- Se%etion te@t
> Aept (irth date fro! "ser and o"tp"t age in #ears, !onths and da#s&
Updated on - Apr 20, 2004 Page 54 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 55/57
ABAP BASICS
CHECK BOES AN RAIO BUTTONS
1 rite a progra! ith
- Para!eter as he)(o@es- If he)(o@ 1 is %i)ed rite &( 1 %i)ed e%se &( 1 not %i)ed&
- If he)(o@ 2 is %i)ed rite &( 2 %i)ed e%se &( 2 not %i)ed&- If he)(o@es 1 ' 2 are %i)ed rite &( 1 ' &(& 2 are %i)ed&- If he)(o@es 1 ' 2 are not %i)ed rite &( 1 ' &(& 2 are not %i)ed&
2 rite a progra! ith
- Para!eters as to gro"ps of Radio("ttons Gto Radio("ttons in eah gro"pH&- 8i$e detai%ed oding as a(o$e, to sho the Radio("ttons and gro"ps
- se%eted
3 rite a progra! ith
- Para!eter as he)(o@&
- If #o" %i) the he)(o@ then disp%a# first da# of the ne@t #ear&- If the he)(o@ is not %i)ed then disp%a# %ast da# of the "rrent #ear&
4& rite a progra! ith
- Para!eter as gro"p of 3 radio ("ttons- If first radio ("tton is %i)ed, disp%a# %ast da# of the "rrent !onth&
- If seond radio ("tton, disp%a# first da# of the ne@t !onth
- If third radio ("tton, disp%a# date after si@ !onths&
Updated on - Apr 20, 2004 Page 55 of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 56/57
ABAP BASICS
SELECT STATEMENTS
1 ist a%% the ros fro! the ta(%e A&
2 ist sing%e ro fro! the ta(%e P&
3 ist "p to 5 ros fro! the ta(%e SIS&
4 ist a%% R=A*s& or (etter reada(i%it# reate a o%"!n heading in the %ist
5 =isp%a# tota% a!o"nt for arrid OD:& G*a(%es. SI8D*H
> ist a%% the f%ights for hih (oo)ing date is greater than :01&0>&1995:&
7 ist a%% the f%ights for hih pa#!ents "rren# is O=:&
J ist a%% the f%ights here arrid is (eteen OD: and OSK:&
9 Se%et a sing%e reord here arrid N OD:, f%ight-no N O0400: and
f%date N :2J&02&199J:&
10 =isp%a# arrid, onnid, f%date and %"ggage eight !"%tip%ied (# 2
11 ist the !a@i!"! apait#, o"pied seats and tota% of "rrent (oo)ings for eah f%ight inthe fo%%oing for!at&
Carrier
id
a@& apait# ;"pied seats *ota% of "rrent (oo)ings
12 ro! the gi$en fro!-it# and to-it#, %ist a%% the a$ai%a(%e on this ro"te.
ro!. fro!-it#Q *o. to-it#Q Gsa# fro! ran)f"rt to adrasH
G*a(%es. SP1H
Carrierid
=epart"re *i!e Start Airport =estination Airport
Updated on - Apr 20, 2004 Page 5> of 57Created on - Apr 20, 2004
7/27/2019 01 ABAP Book - Basics
http://slidepdf.com/reader/full/01-abap-book-basics 57/57
ABAP BASICS
OPEN SL
1 Aept do"!ent no& fro! "ser and disp%a# parti"%ars of Sa%es do"!ent& G=efa"%t
do"!ent no& O0010000031:HG*a(%e. APH
Created on. @@@@@Created (#. @@@@@
*i!e. @@@@@
2 Aept Sa%es =o"!ent n"!(er fro! "ser and disp%a# orresponding !ateria%no, desription of that !ateria% and ite! ategor# G*a(%e . APH
3 Aept !ateria% no& ' ite! ategor# (# defa"%t PP100 and < respeti$e%#=isp%a# orresponding detai%s of sa%es do"!ent G*a(%e. APH
4 =isp%a# fie%ds fro! P&=o"!ent t#pe N OA: and
=o"!ent date N :05&02&199J:&
A%so disp%a# n"!(er of reords se%eted&
5 =isp%a# Co& ode, do&no&, a&t#pe, ta@ ode&
a)e "se of se%et-options to gi$e range of do"!ent t#pe&
=isp%a# tit%e of #o"r progra! at the end of progra!
> Aept do& no fro! "ser&
=isp%a# do&no&, do&stat"s, date of do&, do&t#pe&
7 =isp%a# sing%e reord for do"!ent here date N :05&02&199J:, t#pe ON OA and do"!ent
no& N O010000000>:&
J Aept p%ant fro! "ser eg& P*P&
=isp%a# do"!ent detai%s for that p%ant %i)e do&no&, do&stat"s, date of do"!ent et&,