213303337 01 abap book intelli basics
TRANSCRIPT
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
1/57
ABAP BASICSIntelligroup Asia Private Limited
ABAP TRAINING MATERIAL
Updated on - Apr 20, 2004 Proprietary & Confidential Page 1 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
2/57
ABAP BASICSIntelligroup Asia Private Limited
TABLE OF CONTENTS
SOME FACTS ABOUT SAP 4
OR!ING IT" R#$ S%STEM
SAP R#$ lo'on S(reen))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
Lo''in' Off)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))*
U+in' Tran+a(tion Code))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))*
Gettin' ,elp in t,e R#$ +y+te-))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))./
or0in' 1it, R#$ 2+er +e++ion+))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))..
R#$ ARC"ITECTURE ..
Client # Ser3er ar(,ite(t2re))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))).
T,ree tier ar(,ite(t2re of R#$))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))).$
ABAP#4 5E6ELOPMENT OR!BENC" .4
5ATA 5ICTIONAR% .
A7o2t 5ata 5i(tionary)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))).
Ad3anta'e+)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))).
Ta7le+ in ABAP#4 di(tionary)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))).8
Creation of ta7le)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))/
Creatin' 5o-ain))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))/
Creatin' 5ata Ele-ent))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))/
GENERAL INTRO5UCTION TO ABAP#4
C,ara(teri+ti(+ of t,e ABAP#4 pro'ra--in' lan'2a'e+)))))))))))))))))))))))))))))))))))))))))))))))))))))))))$
REPORTS)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))4
5IALOG PROGRAMS)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))9
Updated on - Apr 20, 2004 Proprietary & Confidential Page 2 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
3/57
ABAP BASICSIntelligroup Asia Private Limited
5ATA T%PES AN5 5ATA OB:ECTS ;
5ata Type+))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
5ata O7
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
4/57
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
5/57
ABAP BASICSIntelligroup Asia Private Limited
OSS= =nline $ervi'e $(stem is one of t#e primar( sour'es of servi'e and support provided +(
$AP) it# =$$, 'ustomers 'an sear'# t#e $AP information data+ase and find solutions for
errors and pro+lems /it# %&" s(stems) 8ou 'an also su+mit (our pro+lems to $AP)
Con+2ltin' Ser3i(e= /it# remote 'onsulting servi'e 'ustomer re'eives immediate and updated
te'#ni'al support and ans/ers to t#eir 3uestions)
Maintenan(e +er3i(e= #is is t#e +asi' and most 'ommon t(pe of support for 'ustomers in
te'#ni'al support and ans/ers to t#eir 3uestions)
Infor-ation Ser3i(e= #ese are t#e various information sour'es for re'eiving detailed
information a+out t#e %&" s(stem, mareting +ro'#ures, s(stem do'umentation, training
information and man( more t#ings)
Pre3enti3e +er3i(e+= #e primar( one is t#e arl( at'# $ervi'e, /#i'# ensures su''essful andeffi'ient installation of t#e %&" s(stem in all p#ases) #is servi'e maes regular&performan'e
'#e's and anal(Fes t#e s(stem to identif( potential pro+lems, #elp s(stem managers and $AP
administrators to tune t#e s(stem) $oon after t#e arl( at'# session, $AP sends t#e 'ustomer a
report /it# t#e result of t#e anal(sis and re'ommendations for avoiding potential pro+lems su'#
as data+ase +e'oming full)
$o overall $AP %&" is an open 'lient&server soft/are s(stem, designed to manage +usiness
information needs of an entire enterprise) #e /#ole dataflo/ of $AP %&" /ors in an
integrated /a(, /#i'# means t#e data needs to +e entered .ust on'e and t#e s(stem automati'all(
updates ot#er logi'all( related data)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 5 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
6/57
ABAP BASICSIntelligroup Asia Private Limited
OR!ING IT" R#$ +y+te-
#e $AP %&" presentation interfa'e +e#aves ver( similarl( to an( ot#er t(pi'al /indo/
appli'ation and is also no/n as $AP:UI) #e first s'reen t#at (ou 'ome a'ross in %&" s(stem
is $AP logon s'reen)
SAP R#$ lo'on S(reen
#is is t#e first s'reen t#at appears /#en (ou use $AP logon utilit() It #as four fields t#e 'lient,
t#e user, t#e pass/ord and t#e language)
Client= Eere (ou enter t#e 'lient num+er) #e 'lient is group of users /#o #as similar rig#ts) It
'an +e group of users in a +usiness entit( or a /#ole +usiness entit( or a /#ole 'ompan()
♦ U+er= #e name of t#e $AP user identifi'ation) Users of t#e $AP s(stem are 'lient-spe'ifi',
/#i'# means t#at user +elonging to one 'lient is valid to onl( t#e parti'ular 'lient)♦ Pa++1ord= It is t#e pass/ord t#at #as +een assigned +( t#e s(stem administrator)
♦ Lan'2a'e= $AP %&" s(stem supports multinational language on t#e same s(stem at t#e same
time, /#i'# is ver( useful for multinational 'ompanies /it# different +ran'#es in several
'ountries and possi+l( using different languages)
After entering all t#e fields press >% e( and s(stem /ill tae (ou to AI> >U s'reen)
Updated on - Apr 20, 2004 Proprietary & Confidential Page ! of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
7/57
ABAP BASICSIntelligroup Asia Private Limited
User mig#t get different s'reens /#en #e logs on, depending upon default settings of t#e user
master re'ord i)e), if user is ?L=P% t#en t#e s'reen /#i'# #e often /ors on is editor
s'reen and #e 'an go dire'tl( to t#is s'reen, if s(stem administrator sets t#is s'reen for t#e user)
Main features of any R/3 window are as follows:
♦ %&" standard /indo/ elements +e#ave ea'tl( t#e same, as an( ot#er standard /indo/
appli'ation /ould, lie minimiFing a s'reen, setting t#e a'tive /indo/ et')
♦ Brom =P to ==, %&" /indo/ 'an 'ontain t(pi'al elements su'# as '#e' +oes,
pus# +uttons, input fields and follo/ing elements
♦ Men2 7ar is t#e first element of t#e ever( %&" /indo/) It 'ontains t#e menu item
'orresponding to t#e parti'ular %&" appli'ation) #e t/o menu options $8$ and ELP
are al/a(s present in ever( %&" /indo/) $8$ menu option 'ontains all utilities and
fun'tions, and is availa+le to user at all t#e times) #e ELP menu 'ontains all t#e availa+le
options for t#e different t(pes and met#ods of o+taining online #elp in t#e s(stem)
♦ Standard tool 7ar) #e se'ond %&" /indo/ element i+ pre+ent in e3ery R#$ 1indo1) It isnot#ing +ut a 'olle'tion of i'ons, /#i'# perform 'ommon fun'tions lie saving t#e o+.e't,
eit et') #e various i'ons on std) ool +ar are as follo/s Hfrom left to rig#t
Enter Co--and Field Sa3e Ba(0
E>it Can(el Print Find
Find Ne>t Fir+t Pa'e Pre3io2+ Pa'e Ne>t Pa'e
La+t Pa'e "elp
All i'ons in %&" /indo/ appli'ation support B=CU$ propert() It means, if (ou pla'e 'ursor
over an i'on, t#e s(stem /ill s#o/ t#e fun'tion of t#e i'on)
♦ Appli(ation tool 7ar= #e net part of t#e s'reen 'ontains i'ons most 'ommonl( used in t#at
parti'ular tas or transa'tion)
♦ Stat2+ 7ar is t#e +ottom line of t#e s'reen and usuall( s#o/s errors or information messages
to t#e user) It also in'ludes ot#er information su'# as s(stem id, session num+er, 'lient,
server name and t#e response time)
In 7et1een appli(ation tool 7ar and +tat2+ 7ar yo2 ,a3e 1or0in' area? 1,i(, i+ different for
different s'reens)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 7 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
8/57
ABAP BASICSIntelligroup Asia Private Limited
Lo''in' Off
User 'an log off t#e %&" s(stem from an( s'reen) #ere are t#ree /a(s of logging off t#e %&" s(stem,
/#i'# are as follo/s
♦ Brom t#e enu +ar '#oose $8$ → L=: =BB) In t#is 'ase, (ou get t#e log off dialog
+o, /#i'# informs t#e user t#at an( data not saved /ill +e lost if 'ontinuing /it# t#e log off
pro'edure)
♦ Use&>J transa'tion 'ode in t#e 'ommand field) #is is dangerous, sin'e it does not as if
(ou /ant to save t#e data)
♦ Cli'ing on t#e JI +utton on t#e %&" initial s'reen)
U+in' Tran+a(tion Code
#e %&" s(stem provides an alternative and effi'ient /a( of sele'ting menu options for moving
around t#e tass and fun'tions of t#e $AP s(stem +( using transa'tion 'ode dire'tl( in t#e'ommand field)
#en moving /it# transa'tion, (ou 'an go to an( part of t#e s(stem +( merel( t(ping a
transa'tion 'ode in t#e 'ommand field, provided (ou #ave aut#oriFation for t#at) #at
transa'tion 'ode is t#e four-'#ara'ter 'ode asso'iated /it# an( tas) ( t(ping t#e transa'tion
'ode and pressing >% e(, t#e s(stem taes (ou dire'tl( to t#e initial s'reen for transa'tion)
#enever an( transa'tion 'ode is entered in t#e 'ommand field, it gets stored in t#e +uffer
memor() If (ou 'li' on drop do/n arro/, s(stem displa(s list of transa'tion 'ode alread(
entered and (ou 'an sele't from t#is list or enter ne/ one) #ere are almost t/elve t#ousand and
ninet( four transa'tions in $AP) Bor ever( tas, transa'tion 'ode is asso'iated and it 'an +e
found +(
♦ S%STEM STATUS
$tatus /indo/ is popped up /#i'# 'ontains t#e transa'tion 'ode in t#e trans field)
♦ #roug# 5%NAMIC MENU) It gives t#e list of tass) If (ou 'li' on t#e top line of t#e
appli'ation areas and pressing t#e sear'# and sear'# net +utton /ill give (ou t#e transa'tion
'ode) #N 1ill ta0e yo2 to initial +(reen of R#$
Updated on - Apr 20, 2004 Proprietary & Confidential Page K of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
9/57
ABAP BASICSIntelligroup Asia Private Limited
Important transa'tion 'odes, /#i'# (ou /ill +e using often, are
Editor+
• $"7 Bun'tion uilder
• $"K AAP&4 ditor
• $41 enu Painter
• $51 $'reen Painter
• $71 Borm Painter
5i(tionary
• $11 Initial AAP&4 di'tionar( maintain s'reen)
Bro1+er+
• $K0 =+.e't +ro/ser)
• $1! ?ata +ro/ser)
Te+tin' Tool+
• $"0 %untime Anal(sis
• $05 $L ra'e
Updated on - Apr 20, 2004 Proprietary & Confidential Page ; of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
10/57
ABAP BASICSIntelligroup Asia Private Limited
Gettin' ,elp in t,e R#$ +y+te-
%&" in'ludes man( possi+ilities to get online #elp for almost ever( element of t#e s(stem, users
'an get #elp for entire appli'ation, for spe'ifi' fun'tion, for definitions of various terms used in
$AP, i)e), :lossar(, messages, s'reens, fields et')
8ou o+tain ELP +( using an( of t#e follo/ing options
♦ "elp f2n(tion from t#e %&" /indo/, /#i'# is 'ompulsor( menu item of ever( %&" /indo/)
♦ @ I(on of standard tool +ar)
♦ F. f2n(tion 0ey)
#e $AP s(stem provides #elp on most fields t#at appear on t#e %&" s(stem) o get #elp on
parti'ular field, position t#e 'ursor over it and press #elp +utton or B1 fun'tion e()
Anot#er /a( in /#i'# %&" s(stem provides #elp is /#en s(stem displa(s error messages in t#e
status +ar) ?ou+le 'li'ing on t#e status +ar s#o/s additional information a+out t#e message)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 10 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
11/57
ABAP BASICSIntelligroup Asia Private Limited
or0in' 1it, R#$ 2+er +e++ion+
A ver( important feature provided +( $AP) In %&" s(stem (ou 'an /or /it# more t#an one tas
at an( given point of time, +( means of opening sessions) 8ou 'an 'all sessions as independent
%&" /indo/ /#ere (ou 'an perform ot#er tass)
( default, a user 'an open NINE sessions simultaneousl( and 'an /or or move around /it# all
sessions at t#e same time) $essions 'an +e 'losed at an( time, /it#out #aving to log off t#e
s(stem)
User 'an 'reate ne/ sessions from an(/#ere as C%A $$$I=> 'omes under $8$
menu /#i'# is availa+le in ever( %&" /indo/)
S%STEM CREATE SESSION =r #O in (o--and field
#is /ill open a ne/ session or /indo/ and /ill pla'e it in front of all ot#er /indo/s)
o move among sessions
♦ ust mouse 'li' on an( part of t#e %&" /indo/ to mae t#at session a'tive)
♦ Com+ination of AL M A e()
R#$ Ar(,ite(t2re#e overall %&" s(stem in'ludes t#e follo/ing 'omponents
#e UPPER la(er, t#e fun'tional la(er 'ontains t#e different +usiness appli'ation) #e
integration of all appli'ation depends upon +asis s(stem) Appli'ations are developed in AAP&4
Lang) HAdvan'ed usiness Appli'ation 6 t#e 4t# generation language
Updated on - Apr 20, 2004 Proprietary & Confidential Page 11 of 57Created on - an 01, 200!
=perating $(stem ?ata ase >et/or
asis $(stem
=r
iddle La(er
usiness
Appli'ations
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
12/57
ABAP BASICSIntelligroup Asia Private Limited
#e %&" +asis soft/are is t#e set of programs and tools, /#i'# interfa'es /it# t#e operating,
s(stem, t#e underl(ing data+ase, proto'ols and t#e presentation interfa'e) #is la(er ena+les all
t#e appli'ation to /or ea'tl( t#e same /a( no matter /#at operating s(stem or data+ase, t#e
s(stem is installed on) It is an independent la(er and ensures t#e integration of all modules)
esides all t#ese spe'ifi' .o+s, A$I$ s(stem also 'ontains follo/ing 'omponents and t#us
provides more additional features)
♦ AAP&4 development /or+en'#, /#i'# in turn in'ludes man( features lie repositor(, data
di'tionar(, /or+en'# organiFer, /#i'# /ill +e dis'ussed in later part of t#e topi's)
♦ AAP&4 language, s(stem administrative tools, all t#ese 'omponents are used to 'ontrol,
tune t#e %&" s(stem)
♦ $pool s(stem manages t#e formatting of data for printing and passing it to t#e #ost spool
s(stem)
♦ ail s(stem (ou 'an send and re'eive mail from t#e outside /orld HInternet)
♦ Communi'ation interfa'e to eternal s(stem from %&" s(stem anages 'ommuni'ation att#e =$ level HCP&IP, at t#e data+ase level * +et/een appli'ations too) H%BC, ?I, and
AL
♦ ?ata+ase interfa'e 6 #is 'omponent supports different %elational data+ases from different
vendors) #e main tas of data+ase interfa'e is to 'onvert t#e $L re3uest from t#e $AP
development environment to t#e data+ase
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
13/57
ABAP BASICSIntelligroup Asia Private Limited
8ou 'an #ave 'lient and server on t#e same ma'#ine or on different ma'#ines) a'# 'lient #as a
'orresponding pro'ess inside t#e server)
=ne of t#e most used 'lient&server 'onfigurations /it# t#e %&" s(stem is t#e " tiered ar'#ite'ture,
/#i'# separates a s(stem
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
14/57
ABAP BASICSIntelligroup Asia Private Limited
#e %&" s(stem is open s(stem in t#e sense t#at it 'an run on an( operating s(stem or an(
data+ase and an( 'ommuni'ation te'#nolog() It means t#at
♦ %&" s(stem 'an run on an( operating s(stem platform su'# as U>IJ, >, ;5, A$&400)
♦ It supports various %?$ su'# as $L server, =ra'le, Informi, ?2)
♦ $tandard :UIs supported +( %&" are indo/s ;5, >, indo/s ")1, and a'intos#)
♦ $AP 'an use standard 'ommuni'ation proto'ols CP&IP, CPIC, =$B&?C&? for net/or)
ABAP#4 5e3elop-ent or07en(,
#e development environment of $AP %&" s(stem is full( integrated set of various development
tools, data di'tionar(, and programming language) Bull integration of all 'omponents means t#at
'#anges in an( part #ave a dire't and immediate effe't on all appli'ation using t#ose
'omponents)
#e s'reen of AAP&4 development /or+en'# loos lie
Tool+ of ABAP#4 1or07en(,
For pro'ra--in'=
Updated on - Apr 20, 2004 Proprietary & Confidential Page 14 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
15/57
ABAP BASICSIntelligroup Asia Private Limited
♦ AAP&4 di'tionar( ?efining, maintaining and storing t#e data di'tionar( of t#e $AP %&"
s(stem stores all t#e di'tionar( o+.e'ts in'luding ta+les relations#ip and Eelp information)
ransa'tion 'ode for t#is is $11)
♦ AAP&4 editor Creating and maintaining t#e AAP&4 program, editing fun'tion modules,
logi'al data+ase, and s'reens) ransa'tion 'ode is $"K)
♦ Bun'tion li+rar( ?efining and maintaining t#e AAP&4 fun'tion modules) ransa'tion 'ode
is $"7)
♦ $'reen painter ?esigning and maintaining t#e s'reens in transa'tion) ransa'tion Code is
$51)
♦ enu painter ?esigning and maintaining t#e means for grap#i'al user interfa'e) ransa'tion
'ode $41)
For Na3i'atin'=
♦ =+.e't +ro/ser anaging and organiFing t#e development o+.e't in a #ierar'#i'al form)
ransa'tion 'ode is $K0)
♦ AAP&4 repositor( information >avigating and sear'#ing for t#e di'tionar( =+.e'ts,
development o+.e'ts and relations#ip o+.e'ts) ransa'tion 'ode $K4)
♦ ?ata +ro/ser >avigating in t#e data ta+les of t#e data+ase) ransa'tion 'ode is $ 1!)
For 5e72''in'=
♦ $=L tra'e tra'ing t#e data+ase 'alls from t#e s(stem transa'tion and programs) ransa'tion
'ode is $05)
♦ ?e+ugger $topping t#e program and anal(Fing t#e results of t#e ee'ution of ever( program
statement)
♦ %untime Anal(sis Anal(Fing t#e performan'e t#e s(stem 'alls ransa'tion 'ode is $"0
For Or'aniin'=
♦ or+en'# organiFer 'ontrolling and eeping tra' of development /or and team related
development pro.e'ts and managing versions of development o+.e'ts) ransa'tion 'ode is
$0;)
♦
ransport s(stem performing and managing t#e transport of development o+.e't a'rossdifferent s(stem) ransa'tion 'ode is $01
Updated on - Apr 20, 2004 Proprietary & Confidential Page 15 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
16/57
ABAP BASICSIntelligroup Asia Private Limited
5ata 5i(tionary
#e AAP&4di'tionar( is 'entral /or+en'# repositor( utilit( providing t#e data definition and
t#e information relations#ip t#at are later used in all t#e +usiness appli'ation /it#in %&"
#e AAP&4 di'tionar( 'an +e seen as a logi'al representation or a superior la(er over t#e
p#(si'al underl(ing data+ase) #is data+ase must support t#e relational data model) #is model
is stri'tl( follo/ed +( data di'tionar()
A7o2t 5ata 5i(tionary
A ?ata di'tionar( in 'omputing terms is t#e +o2r(e of infor-ation in 1,i(, +y+te- data i+
defined) #e data di'tionar( is t#e (entralied and +tr2(t2red +o2r(e of infor-ation for
72+ine++ appli(ation+) 8ou 'an sa( t#at it is 'ore of a /ell-stru'tured development environment)
#e elements t#at mae up a di'tionar( are no/n as metadata) Metadata i+ t,e ter- for t,e
data 1,o+e f2n(tion i+ to de+(ri7e ot,er data) ?ata in di'tionar( is not t#e a'tual data lie
emp) name or emp) address +ut rat#er a t(pe of data /#ose fun'tion is to define t#e properties of
t#e data su'# as t(pe, lengt#, and relations#ip)
Ad3anta'e+
Advantage of using data di'tionar( is avoiding in'onsisten'ies /#en defining data t(pe t#at /ill
later +e used in different appli'ations) #is avoids redundan'ies)
#en a t(pe is defined in t#e di'tionar(, it is availa+le to an( program in t#e appli'ation) A
'#ange in t#e definition of a t(pe of data in t#e di'tionar( automati'all( affe'ts an( ot#er data or
program, /#i'# #as t#is data)
Again, data di'tionar( is a fast and effi'ient /a( to ans/er 3uestions su'# as /#i'# entries eist
in a ta+le of t#e data+ase, /#at t#e stru'ture of ta+le is)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 1! of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
17/57
ABAP BASICSIntelligroup Asia Private Limited
A(ti3ation of di(tionary o7
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
18/57
ABAP BASICSIntelligroup Asia Private Limited
o 'all AAP&4 di'tionar(, from t#e main menu, Tool+ ABAP#4 1or07en(, data
di(tionary or enter tran+a(tion SE..)
5ata di(tionary o7
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
19/57
ABAP BASICSIntelligroup Asia Private Limited
♦ 5o-ain= is formal definition of t#e data t(pe from a te'#ni'al point of vie/) It sets t#e
attri+utes su'# as data t(pe, lengt#, possi+le value range and so on)
♦ Lo(0 o7
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
20/57
ABAP BASICSIntelligroup Asia Private Limited
P ta+le, /#i'# #as fields emp) no), emp)name, dept)'ode, salar( and (ou #ave ?P ta+les,
/#i'# #as dept)'ode and dept)des') #en in ?P ta+le dept)'ode is primar( e( /#ile
dept)'ode in P ta+le is foreign e() If (ou enter dept)'ode for parti'ular emplo(ee in P
ta+le t#e dept)'ode s#ould eist in ?P ta+le) $(stem /ill '#e' t#e value for dept)'ode in
?P ta+le, and if does not eist t#en /ill flas# error) In t#is 'ase ?P is 'alled '#e' ta+le
/#ile P is foreign e( ta+le)
Creation of ta7le
$teps to 'reate a ta+le
♦ Create domain
♦ Create data element
♦ Create a'tual ta+le
Creatin' 5o-ain
?omain as alread( eplained defines t#e te'#ni'al properties of a field su'# as t(pe and value
range) A domain 'an +e 'reated from initial s'reen of data di'tionar( +( 'li'ing on 'reate and
'li'ing domain %adio+utton) Parameters to +e passed are
?ata t(pe #ere (ou need to enter t#e data t(pe availa+le in $AP)
Bield lengt# Bield lengt# is t#e num+er of valid position)
alue ta+le >ame of a ta+le to +e entered) #e fields referring to t#is domain ma( onl( assume
values 'ontained in t#e value ta+le)
=n'e t#e domain is 'reated, save and a'tivate it, so t#at it 'an +e used for furt#er o+.e'ts H+asi'
rule of di'tionar()
Creatin' 5ata Ele-ent
#e se'ond step of ta+le 'reation is to 'reate data element) It assigns a 'ertain meaning to t#eta+le field, /#i'# are defined using t#at data element) A ?ata element al/a(s needs to +e defined
over a domain and field is al/a(s defined over a data element) #is allo/s all fields /it# same
te'#ni'al properties to use t#e same data element)
Parameters to +e passed /#en 'reating a data element
$#ort tet andator( field)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 20 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
21/57
ABAP BASICSIntelligroup Asia Private Limited
?omain A mandator( field) If t#e domain does not eist, $AP 'an tae (ou dire'tl( to
domain definition s'reen)
et element 8ou 'an enter des'ription is s#ort or long tet for t#e field) #is tet is used /#en
entering data for t#ese fields)
$ave and a'tivate)
Creation of a(t2al ta7le
Parameters to +e passed for 'reation of ta+le
$#ort des'ription andator( field)
?eliver( 'lass As per User %e3uirement
a+le fields $pe'if( /#et#er primar( e() In t#is 'ase it is mandator( to enter data
element)
?ata 'lass sta+lis#es t#e p#(si'al area of t#e data+ase)$iFe 'ategor( Allo/s (ou to spe'if( estimated spa'e re3uirement for t#e ta+le)
Burt#er do/n under +uffering s3uare +o, t#e s(stem allo/s spe'if(ing /#et#er ta+le is going to
+e +uffered) #en a ta+le is +uffered, it is loaded into t#e ta+le +uffer from t#e appli'ation
server memor( and it /ill remain t#ere until (ou s/it'# off or re+oot s(stem)
If t#e ta+le is to +e +uffered, (ou need to spe'if( t#e t(pe of +uffering) Bull is for entire ta+le
/#ile partial is for onl( t#ose re'ords /#i'# are +eing a''essed)
=n'e t#e ta+le is 'reated, it #as to +e generated or a'tivated to +e a+le to a''ess +( ot#er o+.e'ts
lie programs)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 21 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
22/57
ABAP BASICSIntelligroup Asia Private Limited
General Introd2(tion to ABAP#4
$AP originall( developed t#e programming language AAP&4 HAdvan'ed usiness Appli'ation
Programming for internal use to provide +est /oring 'onditions for developers) $AP
'onstantl( improves t#e language to adapt to t#e in'reasing re3uirements of t#e +usiness
appli'ations) At present, AAP&4 is t#e onl( tool for developing appli'ations at $AP)
$AP 'ustomers use AAP&4 for t#eir o/n developments) #e AAP&4 ?evelopment
or+en'# 'ontains all tools (ou need to 'reate and maintain AAP&4 programs) AAP&4
programs are not 'omplied +ut generated) ?uring generation, t#e s(stem 'reates a so-'alled
runtime o+.e't from t#e sour'e 'ode and t#e program attri+utes) #en (ou start t#e program, t#e
s(stem ee'utes t#e runtime o+.e't)
AAP&4, a fourt# generation language, 'ontains all usual 'ontrol stru'tures and modulariFing
'on'epts for stru'tured programming) #e t#ree parts of t#e AAP&4 language are
$tru'ture and ee'ution of AAP&4 programs
asi' language elements
Programming reports
Programming dialogs
Structure and execution of ABAP/4 programs are essentiall( different from entirel( se3uential
programming languages su'# as B=%%A>, PA$CAL, or C) AAP&4 instead s#ares 'ertain
similarities /it# modular, event-orient programming languages su'# as isual asi' or AA)
#e t/o most important statements 'on'erning stru'ture and ee'ution are
An AAP&4 program #as a modular stru'ture)
Bor ee'ution, (ou need a spe'ial runtime environment)
#is means, t#at AAP&4 sour'e tets al/a(s 'onsist of a 'olle'tion of program modules Hone
single module in t#e easiest 'ase or t#e se3uential set of statements) #e individual program
modules 'onsist of se3uential elements) #e set of statements of a program module is also 'alled
pro'essing +lo')
#e runtime environment is responsi+le for 'alling t#e individual program modules one after t#e
ot#er) #e runtime environment is t#e ABAP/4 processor, /#i'# 'an 'ommuni'ate /it# te list processor or te dialog processor , depending on t#e program t(pe)
Program flo/ /it#in t#e individual pro'essing +lo's is se3uential, as (ou no/ it from ot#er
se3uential programming languages Hfor eample, B=%%A>, PA$CAL and C) it#in t#e
pro'essing +lo's, (ou 'an use t#e general 'ontrol statements for t#e program flo/, su'# as IB,
?=$, EIL, AAP&4 does not 'ontain :== elements)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 22 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
23/57
ABAP BASICSIntelligroup Asia Private Limited
e mainl( use programs t#at 'onsist of a single pro'essing +lo' onl( and, t#erefore, +e#ave
most liel( lie programs of ot#er se3uential programming languages) Bor programming
appli'ations, t#e entirel( se3uential 'on'ept is not suffi'ient) $AP distinguis#es +et/een t/o
general t(pes of appli'ation programs
Report+= 8ou use reports to read data+ases and represent t#e results in lists) %eports are
'olle'tions of pro'essing +lo's t#at t#e s(stem 'alls depending on events)
5ialo' pro'ra-+= 8ou 'an dialog programs to ee'ute transa'tions, /#i'# usuall( read and
'#ange data+ases) ?ialog programs are 'olle'tions of pro'essing +lo's Hso-'alled module
pools t#at are 'alled +( a s'reen flo/ logi') #e t#ird part of t#e User $L) =P> $L allo/s (ou to read and
'#ange data+ase ta+les independent of t#e underl(ing data+ase s(stem)
♦ AAP&4 allo/s (ou to define and pro'ess internal ta+les t#at eist onl( for t#e ee'ution
period of t#e program) Internal ta+les effi'ientl( support t#e usage of data+ase ta+les and
allo/ (ou to implement 'omple data stru'tures in a program)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 2" of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
24/57
ABAP BASICSIntelligroup Asia Private Limited
♦ AAP&4 allo/s (ou to store data not onl( in data+ases +ut also as se3uential files on
appli'ation and presentation servers)
REPORTS
♦ %eports are AAP&4 programs)
♦ 8ou use reports to evaluation data from data+ase ta+les) #e results of su'# an evaluation
'an +e displa(ed on t#e s'reen or printed form)
♦ %eports are stand-alone programs)
♦ #e user 'an ee'ute reports dire'tl( via t#e program name, for eample, +( '#oosing
$(stem @ Utilities @ %eporting)
♦ A report program 'ontains a 'olle'tion of pro'essing +lo's for different events t#at are
al/a(s triggered eternall() In a report, (ou 'an rea't on events +( programming t#e
'orresponding pro'essing +lo's or ignore t#e events +( not /riting t#e 'orresponding pro'essing +lo's) A report itself never 'reates events)
♦ %eports 'an use logi'al data+ases or sele't statements defined +( developer)
♦ Bor ea'# appli'ation, $AP supplies logi'al data+ases) =r (ou 'an easil( 'reate logi'al
data+ase (ourself)
♦ vent 'ontrol of a report 'orresponds to a 'ertain s'#eme
#en a report is ee'uted, t#e AAP&4 pro'essor 'reates toget#er /it# t#e logi'al data+ase
used Hif an( a se3uen'e of 'ertain events for /#i'# (ou 'an program pro'essing +lo's) #e
'#ronolog( of t#e events is Hmore or less
$teps involved in 'reating a %eport
.) Pro(e++in' t,e +ele(tion +(reen
After starting a report, t#e sele'tion s'reen allo/s t#e user to enter limits or 'ontrol
values for furt#er report pro'essing) #e report 'an 'ontain several pro'essing +lo's for
events during sele'tion s'reen pro'essing, for eample, for '#e'ing t#e input values)
) Readin' t,e data7a+e
After sele'tion s'reen pro'essing 'ome t#e events for reading t#e data+ase) it#er t#e
report reads data from relational data+ases it using t#e 'orresponding AAP&4 statements
Hopen $L or leaves t#is tas to a logi'al data+ase) In t#e latter 'ase, t#e logi'al data+ase'reates a se3uen'e of events to allo/ t#e report to 'op( t#e data)
$) E3al2atin' data and (reatin' li+t+
?uring or after reading t#e data+ase t#e report 'reates t#e output list) ?uring list 'reation,
several events allo/ (ou to la(out t#e output list Hfor eample, la(out t#e page #eader)
4) O2tp2ttin' a li+t
Updated on - Apr 20, 2004 Proprietary & Confidential Page 24 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
25/57
ABAP BASICSIntelligroup Asia Private Limited
#e last part of t#e pro'essing se3uen'e 'ontrolled +( t#e AAP&4 pro'essor is t#e list
output on t#e s'reen or printer) #en displa(ing t#e list on t#e s'reen, user 'an trigger
ot#er reports, t#at are intera'tive and are event driven) Bor eample, +( 'li'ing t#e
mouse) ( programming pro'essing +lo's for t#ese events, (ou '#ange a normal report
to a so-'alled Intera(ti3e report) If a report does not 'ontain event e(/ords, t#e entire
'oding of t#e report +elongs to a single pro'essing +lo', /#i'# is 'alled +( a standard
event) #is standard event is triggered dire'tl( after pro'essing t#e sele'tion s'reen)
5IALOG PROGRAMS
♦ 8ou use dialog programs to ee'ute transa'tions) #e users of dialog programs in dialog
sessions read and '#ange data+ase ta+les) Apart from t#e a'tual data pro'essing H=pen
$L, update and en3ueue 'on'epts are of great importan'e /#en programming dialogs)♦ ?ialog programs are not stand- alone
♦ o ee'ute dialog programs, t#e( must +e lined to at least one s'reen t#at itself is lined to
a transa'tion 'ode) #e transa'tion 'ode determines t#e initial s'reen /it# /#i'# t#e dialog
session starts)
♦ ?ialog programs are 'ontrolled +( s'reen flo/ logi'
♦ #e a'tual AAP&4 dialog program is a so-'alled module pool) A module pool 'ontains a
'olle'tion of dialog modules t#at are 'alled +( t#e s'reen flo/ logi')
♦ o ea'# module pool, at least one, +ut usuall( several s'reens are allo'ated) a'# s'reen #as
flo/ logi') #e flo/ logi' 'onsists of P= Hpro'ess efore output and PAI Hpro'ess After
Input +lo's) #is flo/ logi' does not use t#e AAP&4 programming language and t#e
AAP&4 ditor tool, +ut a spe'ial statement set and t#e $'reen Painter tool, /#i'# (ou also
use to la(out s'reens) #e flo/ logi' mainl( 'ontains t#e '#ronologi'all( ordered 'alls of t#e
modules in t#e 'orresponding module pool)
♦ !e collection of PB" flow logic, screen, and PA# flow logic is called $ynamic program
%$ynpro&) A module pool must #ave at least one d(npro) a'# s'reen of a dialog session
t#us is t#e visi+le part of a d(npro, to /#i'# also t#e flo/ logi' +elongs) #e pro'essing logi'
of a dialog session is stored in t#e 'orresponding module pool in t#e form of AAP&4
modules)
♦ #e AAP&4 modules in t#e module pool are separated into P= and PAI modules) #e
P= or PAI +lo's of t#e flo/ logi' of ea'# d(npro of a module pool 'an 'all ea'# P= or
PAI module of t#is module pool)
♦ 8ou 'an use AAP&4 statements in t#e pro'essing logi' of t#e module pool to 'ontrol t#e
'#ronolog( of t#e different d(npros) After starting a dialog session via t#e transa'tion 'ode,
/#i'# is firml( 'onne'ted to a d(npro of t#e module pool, t#e s'reen flo/ logi' passes user
entries to t#e pro'essing logi' in t#e AAP&4 module pool) #e pro'essing logi' pro'esses
Updated on - Apr 20, 2004 Proprietary & Confidential Page 25 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
26/57
ABAP BASICSIntelligroup Asia Private Limited
t#e user entries Hdata+ase a''esses and, if re3uired, defines t#e appropriate su+se3uent
s'reens)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 2! of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
27/57
ABAP BASICSIntelligroup Asia Private Limited
5ata Type+ and 5ata O7
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
28/57
ABAP BASICSIntelligroup Asia Private Limited
5ata O7U 8P I
>U is a varia+le de'lared +( ?AA statement) An( varia+le, /#i'# (ou use in program,
need to +e de'lared +efore (ou use it and 'an +e done +( ?AA statement)
Eere varia+le is de'lared +( referring to eisting data t(pe)
aria+le 'an also +e de'lared +( referring eisting data o+.e't)
) e #ave alread( de'lared >U +( ?AA statement)
?AA P%IC LI9 >U)
Eere varia+le is de'lared +( using LI9 parameter, /#i'# tells s(stem t#at pri'e #as all t#e
attri+utes of data o+.e't >U i)e), P%IC is also of t(pe I)
#e main differen'e +et/een 8P and LI9 parameter /#en defining or de'laring t#e
o+.e't is t#at 8P is used to refer eisting ?AA 8P Helementar( or stru'tured or user
defined /#ile LI9 is used to de'lare data o+.e'ts /it# referen'e to eisting ?AA
=C$)
♦ Con+tant
Constant is a data o+.e't, /#i'# 'ontains fied value t#roug# out t#e program) Constant 'an
+e de'lared in program +( using C=>$A> statement)
) C=>$A> I> 8P I ALU 15)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 2K of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
29/57
ABAP BASICSIntelligroup Asia Private Limited
In program value of I> 'annot +e '#anged) If (ou give a statement lie I> N 20)
In t#is 'ase s(stem /ill give error)
) ETERNAL 5ATA OB:ECTS
Are defined in ta+les i)e), in AAP&4 di'tionar() 8ou 'an a''ess t#is data from ta+le)
AL$ $BLI:E
?AA $A$ LI9 $BLI:E-$A$AJ)
$) S%STEM5EFINE5 5ATA OB:ECTS
$PAC * $8$ A%IAL$ lie s(-uname, s(-datum, * s(-repid)
4) SPECIAL 5ATA OB:ECTS
PA%A%$ are varia+le, /#i'# 'an a''ept value from user)
$LCI=>$ C%I%IA are spe'ial internal ta+les to a''ept value range from user)
Need for 5ata type+=
Consider t#e follo/ing eample)
?AA fnameH20,
mnameH20,
lnameH20,
add1H20,
add2H20,
add"H20)
If (ou #ave ?AA statement lie a+ove, and if (ou need to '#ange t#e lengt# of all t#e fields sa(from 20 to 25, t#en (ou need to '#ange all t#e fields i)e), going t#roug# ea'# and ever(
statement)
ut 'onsider t#e follo/ing 'ase /#ere 8P$ #as +een used)
8P$strH20
?AAfname t(pe str,
Updated on - Apr 20, 2004 Proprietary & Confidential Page 2; of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
30/57
ABAP BASICSIntelligroup Asia Private Limited
name t(pe str,
Lname t(pe str,
Add1 t(pe str,
Add2 t(pe str,
Add" t(pe str)
In t#is 'ase if (ou need to '#ange t#e lengt# of all fields from 20 to 25) #en .ust '#ange t#e
lengt# of $% and '#ange /ill +e refle'ted for all t#e fields)
If (ou define all t#e t(pes in 8P-P==L i)e), glo+al definition of all t#e t(pes, (ou 'an use
t#ese t(pes an(/#ere and in an( program)
Para-eter+
Parameter statement is used to a''ept input from user) PA%A% statement is used /#en(ou /ant user to enter data and depending upon /#at #e enters (ou need to tae a'tion) #e
parameter statement de'lares t#e varia+le and also allo/s s(stem to a''ept data into t#at
varia+le)
$(nta)
Parameters num t(pe I)
Eere parameter statement de'lares t#e varia+le and 'reates t#e sele'tion s'reen on /#i'# user
enters t#e data i)e), in t#is 'ase num is de'lared of t(pe I and user 'an enter an( num+er) ntered
value is stored in t#e same varia+le and 'an +e used in program)
?ata m t(pe I
Parameters num t(pe I
N num 6 5
rite & O#e num+er is
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
31/57
ABAP BASICSIntelligroup Asia Private Limited
ver( parameter 'an +e asso'iated /it# language dependent tet t#at is displa(ed on t#e
sele'tion s'reen) #is 'an +e done /it# t#e #elp of tet elements)
Updated on - Apr 20, 2004 Proprietary & Confidential Page "1 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
32/57
ABAP BASICSIntelligroup Asia Private Limited
RITE State-ent
#e +asi' APA&4 statement for outputting data on t#e s'reen is %I)
$(nta
%I fieldQ optionQ)
#is statement outputs t#e field fQ to t#e 'urrent list in its standard output format)
( default, t#e list is displa(ed on t#e s'reen)
#e field fieldQ'an +e an( varia+le or ta+le field or .ust literal)
P%=:%A R?=
%I &OELL=
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
33/57
ABAP BASICSIntelligroup Asia Private Limited
For-attin' o2tp2t
8ou 'an position t#e output of a %I statement on t#e s'reen +( maing a format
spe'ifi'ation +efore t#e field name as follo/s
$(nta
%I A S&TSposQTSHlenQT fQ,
#ere
• Ot#e slas#
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
34/57
ABAP BASICSIntelligroup Asia Private Limited
#e output loos as follo/s
=ne
/o
#e s(stem suppresses lines t#at 'ontain not#ing +ut empt( spa'es)
8ou 'an use various formatting options /it# t#e %I statement)
$(nta
%IVVVV fieldQ optionQ
For-attin' option+ for all data type+
"ption Purpose
LB-U$IBI? =utput is left .ustified)
C>%? =utput is 'entered)
%I:E-U$IBI? =utput is rig#t .ustified)
>=-:AP #e +lan after t#e field fQ is omitted)
>=-R%= If a field 'ontains onl( Feros, t#ese are
repla'ed +( +lans) Bor t(pe C and >
fields, leading Feros are repla'ed
automati'all()
For-attin' option+ for n2-eri( field+
Option P2rpo+e
>=-$I:> #e leading sign is not output)
?CIAL$ dQ dQ defines t#e num+er of digits after t#e
de'imal point)
JP=>> eQ In t(pe B fields, t#e eponent is defined in
eQ
%=U>? rQ (pe P fields are multiplied +( 10H-r
and t#en roundedCU%%>C8 'Q Bormat a''ording to 'urren'( 'Q in ta+le
CU%J)
U>I uQ #e num+er of de'imal pla'es is fied
a''ording to t#e unit
uQ spe'ified in ta+le 00! for t(pe P
fields)
Updated on - Apr 20, 2004 Proprietary & Confidential Page "4 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
35/57
ABAP BASICSIntelligroup Asia Private Limited
"oriontal line+
8ou 'an generate #oriFontal lines on t#e output s'reen +( using t#e follo/ing s(nta
$(nta
ULI>
ill dra/ a #oriFontal line)
ULI> H10
ill start dra/ing #oriFontal line from 10t# 'olumn position)
%I at 10H40 $8-ULI>
#is statement dra/s a #oriFontal line from 10t# position)
6erti(al line+
8ou generate verti'al lines one t#e output s'reen +( using t#e follo/ing s(nta
$(nta
%I SA S&T SposQTT $8-LI>)
Blan0 line+
8ou 'an generate +lan lines on t#e s'reen +( using t#e follo/ing s(nta
$(nta
$9IP Snum+erQT
$tarting on t#e 'urrent line, t#is statement generates num+erQ +lan lines on t#e output s'reen)
If no value is spe'ified for num+erQ, one +lan line is output) In t#e standard setting, (ou
'annot 'reate empt( lines /it# t#e %I statement alone)
o position t#e output on a spe'ifi' line on t#e s'reen use
$(nta
$9IP = LI> num+erQ
#is statement allo/s (ou to move t#e output position up/ards or do/n/ards)
Updated on - Apr 20, 2004 Proprietary & Confidential Page "5 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
36/57
ABAP BASICSIntelligroup Asia Private Limited
Bran(,e+
Lie ot#er #ig#er programming languages, AAP&4 provides standard e(/ords to 'ontrol t#e
flo/ of a program)
Usuall( AAP&4 programs get ee'uted statement +( statement) an( times (ou need to sip
fe/ statements depending upon 'ertain 'onditions i)e), (ou '#ange t#e flo/ of program) #is
'an +e done +(
♦ 7ran(,in' DIF? CASE
♦ loopin' D5O? "ILE
Eo/ever, unlie ot#er language /#ere (ou #ave onl( internal 'ontrol, ABAP#4 ,a+ internal
(ontrol and e>ternal (ontrol of t,e pro'ra- flo1)
♦ #e internal (ontrol is steered +( standard e(/ords as mentioned a+ove) 8ou define t#is
in (our program 'ode)
♦ #e e>ternal (ontrol is stored +( events) vents are generated eit#er from ot#er AAP&4
programs or from intera'tive user input Hlie, for eample, using t#e mouse to 'li' on t#e
s'reen) #e s(stem does not ne'essaril( pro'ess t#e statements in t#e same se3uen'e as t#e(
are listed in an AAP&4 program) #is maes AAP&4 an event-driven programming
language) #e eternal 'ontrol pla(s an important role mainl( for report programs)
Bran(,in' 1it, IF +tate-ent
#e IB statement allo/s (ou to di3ert t,e pro'ra- flo1 to a parti(2lar +tate-ent +lo',
depending on a 'ondition) #is statement +lo' 'onsists of all t#e 'ommands /#i'# o''ur
+et/een an IB statement and t#e net L$IB, L$, or >?IB statement)
$(nta
IB'ondition1Q
statement +lo'Q
L$ statement +lo'Q
>?IB
If t#e first 'ondition is true, t#e s(stem ee'utes all t#e statements up to t#e end of t#e first
statement +lo' and t#en 'ontinues pro'essing after t#e >?IB statement)
Updated on - Apr 20, 2004 Proprietary & Confidential Page "! of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
37/57
ABAP BASICSIntelligroup Asia Private Limited
o introdu'e alternative 'onditions, (ou 'an use L$IB statements) If t#e first 'ondition is
false, t#e s(stem pro'esses t#e follo/ing L$IB statement in t#e same /a( as t#e IB statement)
L$ +egins a statement +lo' /#i'# is pro'essed if none of t#e IB and L$IB 'onditions is
true) #e end of t#e last statement +lo' must al/a(s +e 'on'luded /it# >?IB)
IB 'ondition1Q)
statement +lo'Q
L$IB 'ondition2Q)
statement +lo'Q
L$IB 'ondition"Q)
statement +lo'Q
L$)
statement +lo'Q
>?IB)
AAP&4 allo/s unlimited nesting of IB 6 >?IB statement +lo's, +ut t#e( must terminate
/it#in t#e same pro'essing +lo') In ot#er /ords, an IB 6 >?IB +lo' 'annot 'ontain an evente(/ord)
Bran(,in' 1it, CASE +tate-ent
o ee'ute different statement +lo's depending on t#e 'ontents of parti'ular data fields, (ou 'an
eit#er use IB statement or t#e CA$ statement as follo/s
$(nta
CA$ fQ)
E> f1Q)
statement +lo'Q
E> f2Q)
statement +lo'Q
E> f"Q)
statement +lo'Q
E> =E%$)
statement +lo'Q
>?CA$)
#e s(stem ee'utes t#e statement +lo' after t#e E> statement if t#e 'ontents of fQ e3uals
t#e 'ontents of fiQ, and 'ontinues pro'essing after t#e >?CA$ statement) #e statement
+lo' after t#e optional E> =E%$ statement is ee'uted if t#e 'ontents of fQ do not
e3ual an( of t#e fiQ 'ontents) #e last statement +lo' must +e 'on'luded /it# >?CA$)
#e 'onditional +ran'#ing using CA$ is a s#orter and simpler form of similar pro'essing /it#
IB) #en (ou #ave man( 'onditions IB +e'omes more 'ompli'ated in su'# 'ases CA$ is used)
Updated on - Apr 20, 2004 Proprietary & Confidential Page "7 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
38/57
ABAP BASICSIntelligroup Asia Private Limited
LOOPING
Loopin' 1it, 5O +tate-ent
If (ou /ant to /rite (our name sa( for 10 times, (ou need to /rite %I statement for 10
times)
#en (ou /ant to pro'ess a statement more t#an on'e, (ou 'an /rite t#is statement /it#in a
loop /it# t#e ?= statement as follo/s
$(nta
?= 5 times)
rite & name)
>??=)
#e s(stem 'ontinues pro'essing t#e statement +lo' for 5 times introdu'ed +( ?= and
'on'luded +( >??=)
#e s(stem field $8-I>?J 'ontains t#e num+er of times t#e loop #as +een pro'essed so in t#is
'ase /#en t#e loop is over value of s(-inde /ill +e 5)
In t#is 'ase (ou no/ t#at, (ou /ant to perform %I statement for 5 times) ut t#at is not
t#e 'ase al/a(s) an( times (ou need to terminate t#e loop depending upon 'ertain 'onditions)
#is 'an +e done, +( using EIT or STOP statement)
#e important point to remem+er /#en (ou don
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
39/57
ABAP BASICSIntelligroup Asia Private Limited
>?EIL)
#e s(stem 'ontinues pro'essing t#e statement +lo' introdu'ed +( EIL and 'on'luded +(
>?EIL statements as long as is less t#an 10 or until t#e s(stem finds an JI, $=P)
#e s(stem field S%IN5E 'ontains t#e num+er of times t#e loop #as +een pro'essed)
8ou 'an nest EIL loops an( num+er of times and also 'om+ine t#em /it# ot#er loops)
5ifferen(e 7et1een 5O loop and "ILE is t#at in EIL, 'ondition is '#e'ed first and if
'ondition is true t#en loop is ee'uted /#ile in ?= loop, t#e loop gets ee'uted first if (ou don
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
40/57
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
41/57
ABAP BASICSIntelligroup Asia Private Limited
Eere t#e s(stem sear'#es string for * and repla'es it /it# O$LA'Q = UPP% CA$)
%A>$LA'Q = L=% CA$)
#ese statements 'onvert all lo/er 'ase letters in t#e field 'Q to upper 'ase or vi'e versa)
8ou 'an use %A>$LA to su+stitute t#e '#ara'ters in a string lie repla'e) ut t#e main
differen'e +et/een ranslate and %epla'e is t#at %epla'e statement repla'es onl( one o''urren'e
of parti'ular '#ara'ter /#ile ranslate repla'es all t#e o''urren'es of t#e '#ara'ter)
#en using su+stitution rules, use t#e follo/ing s(nta
$(nta
%A>$LA 'Q U$I>: rQ)
STRLEN (o--and
o determine t#e lengt# of a '#ara'ter string up to t#e last '#ara'ter ot#er t#an $PAC, use t#e
+uilt-in fun'tion $%L> as follo/s
$(nta
> N $%L> H $% )
Eere > is defined in ?AA statement as t(pe i)
$%L> pro'esses an( operand 'Q as a '#ara'ter data t(pe, regardless of its real t(pe) >o
'onversions are performed)
CON5ENSE (o--and
o delete superfluous +lans in '#ara'ter fields, use t#e C=>?>$ statement
$(nta
C=>?>$ 'Q S>=-:AP$T)
#is statement removes an( leading +lans in t#e field 'Q and repla'es ot#er se3uen'es of
+lans +( ea'tl( one +lan) #e result is a left-.ustified se3uen'e of /ords, ea'# separated +(
one +lan) If t#e addition >=-:AP$ is spe'ified, all +lans are removed)
CONCATENATE (o--and
o 'on'atenate separate '#ara'ter strings into one, use t#e C=>CA>A statement
$(nta
C=>CA>A '1Q V'nQ I>= 'Q S$PA%A? 8 sQT)
#is statement 'on'atenates t#e '#ara'ter fields '1Q to 'nQ and assigns t#e result to 'Q)
railing +lans are ignored during t#is operation)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 41 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
42/57
ABAP BASICSIntelligroup Asia Private Limited
C=>CA>A $% O< $%2 I>= $%I>:)
Eere str, str2 and O< is 'on'atenated and result is stored in string)
SPLIT (o--and
o split a '#ara'ter string into t/o or more smaller strings, use t#e $PLI statement
$(nta
$PLI 'Q A delQ I>= 'lQV)'nQ)
#is statement sear'#es t#e '#ara'ter field 'Q for delimiter strings delQ and t#e parts +efore
and after t#e delimiters are pla'ed in t#e target fields '1QV)'nQ)
o pla'e all fragments in different target fields, (ou must spe'if( enoug# target fields)
=t#er/ise, t#e last target field is filled /it# t#e rest of t#e field 'Q and still 'ontains delimiters)
$PLI $%I>: A O,< I>= P1 P2 P" P4)
Eere t#e string is split at O,< and is put into strings p1, p2, p", p4)
♦ In ABAP#4? yo2 (an +pe(ify off+et 3al2e+ for ele-entary data o7
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
43/57
ABAP BASICSIntelligroup Asia Private Limited
OPEN SL
In t#e %&" $(stem, long-life data is stored in relational data+ase ta+les) $tru'tured uer(
Language H$L /as 'reated for a''essing relational ?ata+ase) $L #as t/o statement t(pes
?ata ?efinition Language H??L statements and ?ata anipulation Language H?L
statements)
= in'lude $L statements in an AAP&4 program, use >ative $L) o avoid in'ompati+ilities
+et/een different data+ase ta+les and also to mae AAP&4 program independent of t#e
data+ase s(stem in use, $AP #as 'reated a set of separate $L statements 'alled =pen $L)
=pen $L 'ontains a su+set of standard $L statements as /ell as some en#an'ements, /#i'#
are spe'ifi' to $AP) Using =pen $L ena+les (ou to a''ess an( data+ase ta+les availa+le to t#e
$AP s(stem regardless of t#e manufa'turer +e it =ra'le, Informi et')
#e differen'e +et/een =pen $L and >ative $L is as follo/s
A data+ase interfa'e translates $AP$% Adding Lines to ?ata+ase a+les
• UP?A C#anging Lines in ?ata+ase a+les
• =?IB8 Adding or C#anging Lines
• ?L ?eleting Lines from ?ata+ase a+les
#en using =pen $L statements in an AAP&4 program, (ou must ensure t#e follo/ing
1 #e data+ase s(stem +eing addressed must +e supported +( $AP)
2 #e data+ase ta+les +eing addressed must +e defined in t#e AAP&4 ?i'tionar()
Updated on - Apr 20, 2004 Proprietary & Confidential Page 4" of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
44/57
ABAP BASICSIntelligroup Asia Private Limited
Sele(t +tate-ent
#e follo/ing s(stem fields pla( an important role in =pen $L operations
S%SUBRC
As /it# ot#er AAP&4 statements, t#e return 'ode value in t#e s(stem field $8-$U%C
indi'ates after ea'# =pen $L operation /#et#er or not t#e operation /as su''essful) If an
operation is su''essful, $8-$U%C N 0) If an operation is unsu''essful 6 $8-$U%C Q 0
S%5BCNT
#e value in t#e $8-?C> field indi'ates #o/ man( lines /ere affe'ted +( t#e operation or
#o/ man( lines #ave alread( +een pro'essed)
o read data from a data+ase ta+le, use t#e $LC 'ommand)
$(nta
$LC/#atQ B%= ta+le nameQ SI>= varia+le, anot#er ta+leQT SE%
'onditionQT)
#is statement #as several +asi' 'lauses) a'# 'lause is des'ri+ed in t#e follo/ing ta+le)
$LC/#atQ B%= ta+le nameQ I>= varia+les or anot#er ta+leQ E% 'onditionQ
#e $LC 'lause defines /#et#er t#e result of t#e sele'tion is a single line or a /#ole ta+le,
or fe/ 'olumns)
B%= ta+le nameQ
#e B%= 'lause spe'ifies t#e data+ase ta+le or vie/ sour'eQ from /#i'# t#e data is to +e
sele'ted)
I>= varia+le, anot#er ta+leQ
#e I>= 'lause determines t#e target area targetQ into /#i'# t#e sele'ted data is to +e read) It
'an also +e pla'ed +efore t#e B%= 'lause) If (ou do not spe'if( an I>= 'lause, t#e s(stem
uses t#e ta+le /or area) T,e ta7le 1or0 area i+ a ,eader line? 1,i(, i+ a2to-ati(ally
(reated 7y t,e TABLES +tate-ent)
E% 'onditionQ
Updated on - Apr 20, 2004 Proprietary & Confidential Page 44 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
45/57
ABAP BASICSIntelligroup Asia Private Limited
#e E% 'lause spe'ifies /#i'# lines are to +e read +( spe'if(ing 'onditions for t#e
sele'tion) C#oosing t#e Lines to +e %ead)
Bor $ele'ting All data from ta+le
i)e), read all 'olumns and all t#e ro/s from data+ase ta+le
$(nta
$LC B%= ta+leQ)
HEere (ou are not spe'if(ing E% 'ondition
$ele'ting All ?ata from a $ingle Line
o read all 'olumns of a single line from a data+ase ta+le, use t#e $LC statement as
follo/s
$(nta
$LC $I>:L B%= ta+leQ VV E% 'onditionQ VV
#e result of t#is statement is a single line) o mae sure (ou retrieve desired uni3ue single
re'ord, (ou must lin all t#e fields /#i'# form t#e primar( e( of t#e data+ase ta+le +( A>? in
t#e E% 'ondition)
Prere3uisite for $LC $I>:L
1) Use all primar( e(s in E% 'ondition)
2) Al/a(s '#e' for $8-$U%C)
") Clear /or-area for ta+le)
A''re'ate E>pre++ion+
( using aggregate epressions, (ou 'an etra't '#ara'teristi' data from a 'olumn aQ of t#e
data+ase ta+le)
)AJ returns t#e maimum value of t#e 'olumn
)I> returns t#e minimum value of t#e 'olumn
)A: returns t#e average value of t#e 'olumn
)$U returns t#e sum value of t#e 'olumn
Updated on - Apr 20, 2004 Proprietary & Confidential Page 45 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
46/57
ABAP BASICSIntelligroup Asia Private Limited
)C=U> 'ounts values or lines as follo/s
-C=U>H returns t#e total num+er of lines in t#e sele'tion)
8ou must in'lude spa'es +et/een t#e parent#eses and t#e arguments) #e arit#meti' operators
A: and $U 'an onl( /or /it# numeri' fields)
$ometimes (ou retrieve fe/ 'olumns form data+ase ta+le i)e) (ou #ave list in t#e $LC
Clause and I>= Clause)
If t#ere is a list in t#e $LC 'lause, (ou must use t#e I>= 'lause /it# t#e $LC
statement) 8ou 'an use eit#er a /or area /aQ or an internal ta+le ita+Q or list of varia+les as
an argument,
$(nta
AL$ $BLI:E)?AA CA%%I?I LI9 $BLI:E -CA%%I?,
C=>>I? LI9 $BLI:E 6C=>>I?)
$LC CA%%I? C=>>I? B%= $BLI:E I>= HCA%%I?1, C=>>I?1) %I &
CA%%I?l,C=>>I?1)
>?$LC)
an( times (ou retrieve related data from t/o or more ta+les) In su'# 'ases (ou use nested
sele'ts 7y lin0in' ta7le+ 1it, (o--on pri-ary 0ey+ ) ut as far as possi+le avoid using nested
sele'ts as time re3uired to a''ess nested ta+le is ver( #ig#)
$(nta
AL$ $BLI:E, $==9)
$LC B%= $BLI:E E% CA%%I? N XLEX)
$LC B%= $==9 E% CA%%I? N $BLI:E -CA%%I? A>?
C=>>I? N $BLI:E -C=>>II?)
%I & $BL$I:E-CA%%I?,$BLI:E-C=>>I?,$==9-==9I?,
>?$LC)
>?$LC)
$ome performan'e #ints for =pen $L statements
♦ 9eep t#e sele'ted dataset small
9eep t#e num+er of sele'ted data as small as possi+le to avoid unne'essar( net/or
transports) Use t#e respe'tive =pen $L statements al/a(s /it# t#e E% 'lause) Avoid
Updated on - Apr 20, 2004 Proprietary & Confidential Page 4! of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
47/57
ABAP BASICSIntelligroup Asia Private Limited
'omple E% 'lauses) #e s(stem must split up t#ose into single statements for t#e
data+ase s(stem)
?o not use t#e logi'al >= in E% 'lauses +ut inverted operators instead)
#e logi'al >= is supported +( t#e data+ase indees)
♦ 9eep t#e transferred data small
♦ ransfer onl( t#ose 'olumns of a data+ase ta+le t#at (ou reall( need) Avoid $LC if
(ou do not /ant to read all 'olumns of a data+ase) Use a list in t#e $LC 'lause instead)
Use aggregate epressions in t#e $LC 'lause to perform 'al'ulations instead transporting
great amounts of data and 'al'ulating t#ereafter)
♦ 9eep t#e num+er of data+ase a''esses small
♦ Use operations on pa'ages of data instead of operations on single data if (ou /ant toanal(Fe sele'ted data more t#an on'e) o do so, transfer t#e data in a single operation
+et/een ta+les and internal ta+les)
♦ Avoid nested $LC loops) Instead, /or /it# internal ta+les and $LC statements
using t#e B=% ALL >%I$ addition)
In+ert +tate-ent
I>$% statement inserts a single re'ord into t#e data+ase ta+le)
$(nta
a+les sflig#t)
$flig#t-'arrid N OLE
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
48/57
ABAP BASICSIntelligroup Asia Private Limited
o update data+ase ta+le UP?A statement is used) #is allo/s (ou to '#ange eit#er a single
re'ord or several re'ords)
8ou 'an use UP?A /#en (ou no/ /#i'# re'ord (ou /ant to '#ange) ut if (ou do not
no/ /#et#er t#e primar( e( of t#e line (ou /ant to insert alread( eists or not, (ou 'an use
t#e =?IB8 statement) #e =?IB8 statement '#anges eisting lines and inserts lines /#i'#
do not eist)
$flig#t-'arrid N O>? C=>>I? N O454
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
49/57
ABAP BASICSIntelligroup Asia Private Limited
EERCISES
SIMPLE RITE STATEMENTS
1 rite a program, /#i'# generates t#e model list as s#o/n
Use t#ese s(stem fields in (our program)
$8-?AU, $8-URI, $8-U>A
aintain t#e list #eadings
12&12&;7 BI%$ P%=:%A
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
#is list is generated
on 12&12&1;;7
at 1"40"5
+( AAP 1
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
2 Create a list as s#o/n
---------------------------------------------------------------------------------------------------
J8R Co) Pvt) Ltd)
?ate oda(o) 1
---------------------------------------------------------------------------------------------------
Program name R?=
Updated on - Apr 20, 2004 Proprietary & Confidential Page 4; of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
50/57
ABAP BASICSIntelligroup Asia Private Limited
S%MBOLS? ICONS AN5 FORMATTING
1 rite a program to s#o/ t#e follo/ing using s(stem varia+les
H#int use in'lude s(m+olQ and in'lude i'onQ
$(m+ols I'ons
elep#one C#e'edG oa(,
Ba ma'#ine ?elete,
Eand pointing left, Print
Eand pointing rig#t,
Caution,
g rite s(mWp#one as s(m+ol, Otelep#one
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
51/57
ABAP BASICSIntelligroup Asia Private Limited
GENERAL PROBLEMS
1 Create an adding ma'#ine for num+ers)
#e t/o values to +e added must +e entered on t#e sele'tion s'reen as
parameters) =utput t#e result)
2 Create t#e dividing ma'#ine for num+ers)
#e t/o values must +e entered on t#e sele'tion s'reen as parameters)
=utput t#e result)
" Create (our output as s#o/n +elo/)
)
) )
) ) )) ) ) )
) ) ) ) )
4 rite a program to a''ept t#e t/o num+ers from t#e user and s/ap t#e values)
5 ?e'lare a string Oe'#o< and design (our output
e
e '
e ' #
e ' # o
e ' #
e '
e
Updated on - Apr 20, 2004 Proprietary & Confidential Page 51 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
52/57
ABAP BASICSIntelligroup Asia Private Limited
5OEN55O? IFELSEIFELSEEN5IF? CASEEN5CASE
1 rite a program /it# ?o 6 nddo loop)
?ispla( s3uares of num+ers 1 to 10
1 1
2 4
" ;
2 rite a program to a''ept a num+er Hsa( 2 from user and 'reate a multipli'ation ta+le)
2 1 N 2
2 2 N 4VVVV
2 10 N 20
" A''ept a num+er from user and find Ba'torial of t#e same) If t#e num+er is negative t#en
displa( some message)
4 rite a program /it# ?o 6 nddo loop for first 20 num+ers)
- =utput s#ould 'ontain onl( ven num+er
- =dd num+ers s#ould not +e displa(ed
5 A''ept num+ers and '#oi'e O>< or O=??< from t#e user and displa( t#e num+ers in
t#at range a''ording to userI>U< and OJI< statements in ?=-L==P)
Updated on - Apr 20, 2004 Proprietary & Confidential Page 52 of 57Created on - an 01, 200!
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
53/57
ABAP BASICSIntelligroup Asia Private Limited
STRING OPERATIONS
1 A''ept a string and determine its lengt#
2 A''ept a string * num+er) rite t#e string t#at man( num+er of times)
" A''ept t/o strings and s/ap t#eir 'ontents)
4 A''ept t/o strings and 'on'atenate into one string)
5 A''ept one string /it# delimiter H , or G and split it into t/o strings)
! A''ept a string Oa+'def< and use s#ift stringQ, s#ift stringQ rig#t, s#ift stringQ up to
Odef
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
54/57
ABAP BASICSIntelligroup Asia Private Limited
5ATE PROBLEMS
1 A''ept a date earlier to toda(
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
55/57
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
56/57
ABAP BASICSIntelligroup Asia Private Limited
SELECT STATEMENTS
1 List all t#e ro/s from t#e ta+le A9)
2 List single ro/ from t#e ta+le 9PB)
" List up to 5 ro/s from t#e ta+le $I$)
4 List all %?As) Bor +etter reada+ilit( 'reate a 'olumn #eading in t#e list
5 ?ispla( total amount for 'arrid OLE
-
8/9/2019 213303337 01 ABAP Book Intelli Basics
57/57
ABAP BASICSIntelligroup Asia Private Limited
OPEN SL
1 A''ept do'ument no) from user and displa( parti'ulars of $ales do'ument) H?efault
do'ument no) O00100000"1