You are on page 1of 57

ABAP BASICS

ABAP TRAINING MATERIAL

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 1 of 57

ABAP BASICS

TABLE OF CONTENTS SOME FACTS ABOUT SAP WORKING WITH R/3 SYSTEM 4 6

SAP R/3 logon Scr n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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' / S r2 r &rc)"' c'1r !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-3 T)r '" r &rc)"' c'1r o# R/3!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-3 -4 -6

ABAP/4 4E5ELOPMENT WORKBENCH 4ATA 4ICTIONARY

A6o1' 4&'& 4"c'"on&r+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-6 A(2&n'&g %!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-6 T&6l % "n ABAP/4 ("c'"on&r+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-7 Cr &'"on o# '&6l !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3. Cr &'"ng 4o,&"n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3. Cr &'"ng 4&'& El , n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3. GENERAL INTRO4UCTION TO ABAP/4 33

C)&r&c' r"%'"c% o# ') ABAP/4 *rogr&,,"ng l&ng1&g %!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!33 REPORTS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!34 4IALOG PROGRAMS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!38
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 2 of 57

ABAP BASICS 4ATA TYPES AN4 4ATA OB9ECTS 3:

4&'& T+* %!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3: 4&'& O6; c'%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3$ K"n(% o# 4&'& O6; c'%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3$ P&r&, ' r%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3. WRITE STATEMENT 33

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"') 4O %'&' , n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3$ Loo*"ng 0"') WHILE S'&' , n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!3$ TRANSLATE co,,&n(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!4In% r' %'&' , n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!4: U*(&' %'&' , n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!4: 4 l ' %'&' , n'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!4$

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 3 of 57

ABAP BASICS

So, F&c'% &6o1' SAP


After the Internet, SAP R/3 is one of the hottest topi s in the o!p"ter ind"str# and the o!pan# that de$e%oped it& It is targeted to !ost ind"stries, !an"fa t"ring, retai%, oi% ' gas, phar!a e"ti a%, (an)ing, ins"ran e, te%e o!!"ni ation, *ransport, he!i a% and so on& A%% !a+or hard,are -endors ,ere f"%%# engaged to partner ,ith SAP. A*'*, /U00, Co!pa1, I/2, 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, Pri e 3aterho"se 4 Cooper ' 0#(rand, 5rnst ' 6o"ng, 7P28 and !an# !ore& *he o!pan# (ehind R/3 is SAP A8, fo"nded (# fo"r for!er I/2 e!p%o#ees in 1972& *he o!pan#:s head1"arters are in 3a%%dorf, a s!a%% 8er!an to,n& *he o!pan# na!e, SAP stands for S6S*52S, APP0ICA*I;<S and PR;=UC*S in data pro essing& In 1992 R/3 ,as introd" ed and in 1995 SAP A8 ,as ran)ed fifth a!ong independent soft,are $endors& ;ne of the reasons for SAP:s s" ess is that sin e it is a standard pa )age, it an (e onfig"red in !"%tip%e areas and adapted to spe ifi 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? soft,are& 3ith s"(sidiaries in !ore than 50 o"ntries, the o!pan# is %isted on se$era% e@ hanges, in %"ding the Aran)f"rt sto ) e@ hange and <6S5 "nder the s#!(o% BSAPC& SAP has t,o !ain prod" ts in the ("siness soft,are !ar)et, 2ainfra!e s#ste! R/2 and C%ientser$er R/3& /oth are targeted to ("siness app%i ation so%"tions& Dere R indi ates R5A0 *I25& R/2 is SAP A8 !ainfra!e soft,are that r"ns on I/2, Sie!ens and other o!pati(%e e1"ip!ent& *his t#pe of so%"tion annot (e open, ("t ,ith A05 te hno%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%a ed 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% a eptan e of R/3 is not on%# (e a"se it aters a%% o!p%e@ needs of ("siness ("t a%so this internationa% a eptan e is (e a"se of R/3:s internationa% app%i a(i%it#& Aor SAP this does not !ean ha$ing soft,are a$ai%a(%e in different %ang"ages, ("t a%so o$ering "rren #, ta@es, 0ega% pra ti e on erning DR, I!port/e@port reg"%ations& SAP a%so $a%"es its "sto!ers and it is sho,n (# the o!prehensi$e set of 1"a%it# ser$i es p"t (# SAP to he%p "sto!ers d"ring the pro ess of i!p%e!enting and s"pporting the R/3 s#ste!s& *hese ser$i es in %"de prod" t infor!ationF training, insta%%ation and "pgrade ser$i e %i)e.
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 4 of 57

ABAP BASICS OSS< ;n%ine Ser$i e S#ste! is one of the pri!ar# so"r es of ser$i e and s"pport pro$ided (# SAP& 3ith ;SS, "sto!ers an sear h 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 S r2"c < ,ith re!ote ons"%ting ser$i e "sto!er re ei$es i!!ediate and "pdated te hni a% s"pport and ans,ers to their 1"estions& M&"n' n&nc % r2"c < *his is the (asi and !ost o!!on t#pe of s"pport for "sto!ers in te hni a% s"pport and ans,ers to their 1"estions& In#or,&'"on S r2"c < *hese are the $ario"s infor!ation so"r es for re ei$ing detai%ed infor!ation a(o"t the R/3 s#ste!, !ar)eting (ro h"res, s#ste! do "!entation, training infor!ation and !an# !ore things& Pr 2 n'"2 % r2"c %< *he pri!ar# one is the 5ar%# 3at h Ser$i e, ,hi h ens"res s" essf"% and effi ient insta%%ation of the R/3 s#ste! in a%% phases& *his ser$i e !a)es reg"%ar/perfor!an e 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 5ar%# 3at h session, SAP sends the "sto!er a report ,ith the res"%t of the ana%#sis and re o!!endations for a$oiding potentia% pro(%e!s s" h as data(ase (e o!ing f"%%& So o$era%% SAP R/3 is an open %ient/ser$er soft,are 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#, ,hi h !eans the data needs to (e entered +"st on e and the s#ste! a"to!ati a%%# "pdates other %ogi a%%# re%ated data&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 5 of 57

ABAP BASICS WORKING WITH R/3 %+%' , *he SAP R/3 presentation interfa e (eha$es $er# si!i%ar%# to an# other t#pi a% ,indo, app%i ation and is a%so )no,n as SAP8UI& *he first s reen that #o" o!e a ross in R/3 s#ste! is SAP %ogon s reen&

SAP R/3 logon Scr n


*his is the first s reen that appears ,hen #o" "se SAP %ogon "ti%it#& It has fo"r fie%ds. the %ient, the "ser, the pass,ord 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 identifi ation& Users of the SAP s#ste! are %ient-spe ifi , ,hi h !eans that "ser (e%onging to one %ient is $a%id to on%# the parti "%ar %ient& P&%%0or(< It is the pass,ord 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, ,hi h is $er# "sef"% for !"%tinationa% o!panies ,ith different (ran hes in se$era% o"ntries and possi(%# "sing different %ang"ages& After entering a%% the fie%ds press 5<*5R )e# and s#ste! ,i%% ta)e #o" to 2AI< 25<U s reen&
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page > of 57

ABAP BASICS User !ight get different s reens ,hen he %ogs on, depending "pon defa"%t settings of the "ser !aster re ord i&e&, if "ser is =5-50;P5R then the s reen ,hi h he often ,or)s on is editor s reen and he an go dire t%# to this s reen, if s#ste! ad!inistrator sets this s reen for the "ser& Main features of any R/3 window are as follows: R/3 standard ,indo, e%e!ents (eha$e e@a t%# the sa!e, as an# other standard ,indo, app%i ation ,o"%d, %i)e !ini!iEing a s reen, setting the a ti$e ,indo, et & Aro! *;P to /;**;2, R/3 ,indo, an ontain t#pi a% e%e!ents s" h as he ) (o@es, p"sh ("ttons, inp"t fie%ds and fo%%o,ing e%e!ents. M n1 6&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%i ation& *he t,o !en" options S6S*52 and D50P are a%,a#s present in e$er# R/3 ,indo,& S6S*52 !en" option ontains a%% "ti%ities and f"n tions, and is a$ai%a(%e to "ser at a%% the ti!es& *he D50P !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 6&r& *he se ond R/3 ,indo, e%e!ent "% *r % n' "n 2 r+ R/3 0"n(o0& It is nothing ("t a o%%e tion of i ons, ,hi h perfor! o!!on f"n tions %i)e sa$ing the o(+e t, e@it et & *he $ario"s i ons on std& *oo% (ar are as fo%%o,s Gfro! %eft to rightH. En' r Co,,&n( F" l( S&2 B&c/ E="' C&nc l Pr"n' F"n( F"n( N =' F"r%' P&g Pr 2"o1% P&g N =' P&g L&%' P&g H l* A%% i ons in R/3 ,indo, app%i ation s"pport A;CUS propert#& It !eans, if #o" p%a e "rsor o$er an i on, the s#ste! ,i%% sho, the f"n tion of the i on& A**l"c&'"on 'ool 6&r< *he ne@t part of the s reen ontains i ons !ost o!!on%# "sed in that parti "%ar tas) or transa tion& S'&'1% 6&r is the (otto! %ine of the s reen and "s"a%%# sho,s 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 6 '0 n &**l"c&'"on 'ool 6&r &n( %'&'1% 6&r +o1 )&2 0or/"ng &r &> 0)"c) "% different for different s reens&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 7 of 57

ABAP BASICS

Logg"ng O##
User an %og off the R/3 s#ste! fro! an# s reen& *here are three ,a#s of %ogging off the R/3 s#ste!, ,hi h are as fo%%o,s.

Aro! the 2en" (ar hoose S6S*52 0;8 ;AA& In this ase, #o" get the %og off dia%og (o@, ,hi h infor!s the "ser that an# data not sa$ed ,i%% (e %ost if ontin"ing ,ith the %og off pro ed"re& Use/<5I transa tion ode in the o!!and fie%d& *his is dangero"s, sin e it does not as) if #o" ,ant to sa$e the data& C%i )ing on the 5II* ("tton on the R/3 initia% s reen&

U%"ng Tr&n%&c'"on Co(


*he R/3 s#ste! pro$ides an a%ternati$e and effi ient ,a# of se%e ting !en" options for !o$ing aro"nd the tas)s and f"n tions of the SAP s#ste! (# "sing transa tion ode dire t%# in the o!!and fie%d& 3hen !o$ing ,ith transa tion, #o" an go to an# part of the s#ste! (# !ere%# t#ping a transa tion ode in the o!!and fie%d, pro$ided #o" ha$e a"thoriEation for that& *hat transa tion ode is the fo"r- hara ter ode asso iated ,ith an# tas)& /# t#ping the transa tion ode and pressing 5<*5R )e#, the s#ste! ta)es #o" dire t%# to the initia% s reen for transa tion& 3hene$er an# transa tion ode is entered in the o!!and fie%d, it gets stored in the ("ffer !e!or#& If #o" %i ) on drop do,n arro,, s#ste! disp%a#s %ist of transa tion ode a%read# entered and #o" an se%e t fro! this %ist or enter ne, one& *here are a%!ost t,e%$e tho"sand and ninet# fo"r transa tions in SAP& Aor e$er# tas), transa tion ode is asso iated and it an (e fo"nd (# SYSTEM STATUS Stat"s ,indo, is popped "p ,hi h ontains the transa tion ode in the trans fie%d& *hro"gh 4YNAMIC MENU! It gi$es the %ist of tas)s& If #o" %i ) on the top %ine of the app%i ation areas and pressing the sear h and sear h ne@t ("tton ,i%% gi$e #o" the transa tion ode& /N 0"ll '&/ +o1 'o "n"'"&l %cr n o# R/3

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page J of 57

ABAP BASICS

I!portant transa tion odes, ,hi h #o" ,i%% (e "sing often, are. E("'or% S537 S53J S541 S551 S571

A"n tion /"i%der A/AP/4 5ditor 2en" Painter S reen Painter Aor! Painter

4"c'"on&r+ S511 Initia% A/AP/4 di tionar# !aintain s reen& Bro0% r% S5J0 ;(+e t (ro,ser& S51> =ata (ro,ser& T %'"ng Tool% S530 R"nti!e Ana%#sis S*05 SK0 *ra e
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 9 of 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%i ation, for spe ifi f"n tion, for definitions of $ario"s ter!s "sed in SAP, i&e&, 8%ossar#, !essages, s reens, fie%ds et & 6o" o(tain D50P (# "sing an# of the fo%%o,ing options. H l* #1nc'"on fro! the R/3 ,indo,, ,hi h 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 A1 f"n tion )e#& Another ,a# in ,hi h 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 sho,s additiona% infor!ation a(o"t the !essage&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 10 of 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 CR5A*5 S5SSI;< o!es "nder S6S*52 !en" ,hi h 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%a e it in front of a%% other ,indo,s&

*o !o$e a!ong sessions L"st !o"se %i ) on an# part of the R/3 ,indo, to !a)e that session a ti$e& Co!(ination of A0* M *A/ )e#&

R/3 Arc)"' c'1r


*he o$era%% R/3 s#ste! in %"des the fo%%o,ing o!ponents. /"siness App%i ations

/asis S#ste! ;r 2idd%e 0a#er

;perating S#ste!

=ata /ase

<et,or)

*he UPPER %a#er, the f"n tiona% %a#er ontains the different ("siness app%i ation& *he integration of a%% app%i ation depends "pon (asis s#ste!& App%i ations are de$e%oped in A/AP/4 0ang& GAd$an ed /"siness App%i ation 4 the 4th generation %ang"ageH

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 11 of 57

ABAP BASICS *he R/3 (asis soft,are is the set of progra!s and too%s, ,hi h interfa es ,ith the operating, s#ste!, the "nder%#ing data(ase, proto o%s and the presentation interfa e& *his %a#er ena(%es a%% the app%i ation to ,or) e@a t%# 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 spe ifi +o(s, /ASIS s#ste! a%so ontains fo%%o,ing o!ponents and th"s pro$ides !ore additiona% feat"res& A/AP/4 de$e%op!ent ,or)(en h, ,hi h in t"rn in %"des !an# feat"res %i)e repositor#, data di tionar#, ,or)(en h organiEer, ,hi h ,i%% (e dis "ssed in %ater part of the topi s& A/AP/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!& 2ai% s#ste! #o" an send and re ei$e !ai% fro! the o"tside ,or%d GInternetH& Co!!"ni ation interfa e to e@terna% s#ste! fro! R/3 s#ste!. 2anages o!!"ni ation at the ;S %e$e% G*CP/IPH, at the data(ase %e$e% ' (et,een app%i ations too& GRAC, 5=I, and A05H =ata(ase interfa e 4 *his o!ponent s"pports different Re%ationa% data(ases fro! different $endors& *he !ain tas) of data(ase interfa e is to on$ert the SK0 re1"est fro! the SAP de$e%op!ent en$iron!ent to the data(ase:s o,n SK0 en$iron!ent& /a )gro"nd pro essing ,ith this fa i%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 fa i%itate the de$e%op!ent of %ient/ser$er ar hite t"re&

Cl" n' / S r2 r &rc)"' c'1r


C%ient/Ser$er ar hite t"re is !ain%# a soft,are on ept that in %"des a set of ser$i e pro$iders and ser$i e re1"esters& *he set of o!p"ters a ts as ser$i e pro$iders and is a%%ed as ser$er& *he sets of soft,are o!ponent, ,hi h a t as ser$i e re1"ester, are a%%ed as %ient& In the %ient/ser$er ar hite t"re, the data(ase a ts %i)e a %i(rar# %er) retrie$ing (oo)s fro! the she%f& *he "ser progra!s ha$e to re1"est data(ase for the data instead of sear hing 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 desired data 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 ar hite t"re is that the ser$er is a$ai%a(%e for a n"!(er of %ients and there is distri("tion of ,or) (et,een the %ients and the ser$er& *he "ser dire ts the re1"est to the %ientF the %ient in t"rn "nderstands the "ser:s re1"est and redire ts the re1"est to the ser$er& *he ser$er retrie$es the data, gi$es it to %ient&
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 12 of 57

ABAP BASICS 6o" an ha$e %ient and ser$er on the sa!e !a hine or on different !a hines& 5a h %ient has a orresponding pro ess inside the ser$er& ;ne of the !ost "sed %ient/ser$er onfig"rations ,ith the R/3 s#ste! is the 3 tiered ar hite t"re, ,hi h separates a s#ste!:s o!p"ter into 3 f"n tiona% gro"ps.

T)r

'" r &rc)"' c'1r o# R/3

=ata(ase Ser$er App%i ation Ser$er Presentation Ser$er GUn%i)e nor!a% C%ient/ser$er ar hite t"re ,here #o" ha$e on%# t,o %a#ers i&e&, %ient and ser$er&H Co!!"ni ation a!ong the 3 tiers is a o!p%ished (# standard proto o% ser$i es %i)e *CP/IP or CPIC GCo!!on Progra!!ing Interfa e Co!!"ni ationH& Database Server

Application Server

Application Server

Application Server

Presentation Server

Presentation Server

Presentation Server

Presentation Server

Presentation Server

Presentation Server

In a(o$e ase data(ase ser$er stores the data entra%%#& /asi a%%# ontains data(ase engine and asso iated pro esses& *he data(ase %a#ers ontain the data(ase s#ste! "sed (# a%% ser$ers& App%i ation ser$er ontains soft,are o!ponents to r"n the progra!& It ontains a SAP )erne%, ,hi h an r"n A/AP/4 progra!& *he presentation ser$er is #o"r %ient thro"gh ,hi h #o" send #o"r re1"est to app%i ation ser$er& It is a%so a%%ed as SAP graphi a% "ser interfa es )no,n as SAP8UI and is a$ai%a(%e in ,indo,s 3&1, 3indo,s <*, 3indo,s 95, and 2a intosh& *he# a%% %oo) si!i%ar ,hate$er "nder%#ing s#ste! the# are r"nning on& *he SAP8UI in %"des a%% graphi a% apa(i%ities of ,indo, interfa e ,ith !en" (ars, too% (ars, fo "s propert#, and the entire !o"se %i )ing operations& Updated on - Apr 20, 2004 Page 13 of 57
Created on - Apr 20, 2004

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!!"ni ation te hno%og#& It !eans that. R/3 s#ste! an r"n on an# operating s#ste! p%atfor! s" h as U<II, <*, 95, AS/400& It s"pports $ario"s R=/2S s" h as SK0 ser$er, ;ra %e, Infor!i@, =/2& Standard 8UIs s"pported (# R/3 are 3indo,s 95, <*, 3indo,s 3&1, and 2a intosh& SAP an "se standard o!!"ni ation proto o%s *CP/IP, CPIC, ;SA/=C5/=25 for net,or)&

ABAP/4 4 2 lo*, n' Wor/6 nc)


*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 di tionar#, and progra!!ing %ang"age& A"%% integration of a%% o!ponents !eans that hanges in an# part ha$e a dire t and i!!ediate effe t on a%% app%i ation "sing those o!ponents& *he s reen of A/AP/4 de$e%op!ent ,or)(en h %oo)s %i)e

Tool% o# ABAP/4 0or/6 nc) For *rogr&,,"ng<


Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 14 of 57

ABAP BASICS A/AP/4 di tionar# =efining, !aintaining and storing the data di tionar# of the SAP R/3 s#ste! stores a%% the di tionar# o(+e ts in %"ding ta(%es re%ationship and De%p infor!ation& *ransa tion ode for this is S511& A/AP/4 editor Creating and !aintaining the A/AP/4 progra!, editing f"n tion !od"%es, %ogi a% data(ase, and s reens& *ransa tion ode is S53J& A"n tion %i(rar# =efining and !aintaining the A/AP/4 f"n tion !od"%es& *ransa tion ode is S537& S reen painter =esigning and !aintaining the s reens in transa tion& *ransa tion Code is S551& 2en" painter =esigning and !aintaining the !eans for graphi a% "ser interfa e& *ransa tion ode S541& For N&2"g&'"ng< ;(+e t (ro,ser 2anaging and organiEing the de$e%op!ent o(+e t in a hierar hi a% for!& *ransa tion ode is S5J0& A/AP/4 repositor# infor!ation <a$igating and sear hing for the di tionar# ;(+e ts, de$e%op!ent o(+e ts and re%ationship o(+e ts& *ransa tion ode S5J4& =ata (ro,ser <a$igating in the data ta(%es of the data(ase& *ransa tion ode is S5 1>& For 4 61gg"ng< S;0 tra e tra )ing the data(ase a%%s fro! the s#ste! transa tion and progra!s& *ransa tion 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!an e the s#ste! a%%s *ransa tion ode is S530 For Org&n"@"ng< 3or)(en h organiEer ontro%%ing and )eeping tra ) of de$e%op!ent ,or) and tea! re%ated de$e%op!ent pro+e ts and !anaging $ersions of de$e%op!ent o(+e ts& *ransa tion ode is S509& *ransport s#ste! perfor!ing and !anaging the transport of de$e%op!ent o(+e t a ross different s#ste!& *ransa tion ode is S501

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 15 of 57

ABAP BASICS 4&'& 4"c'"on&r+ *he A/AP/4di tionar# is entra% ,or)(en h repositor# "ti%it# pro$iding the data definition and the infor!ation re%ationship that are %ater "sed in a%% the ("siness app%i ation ,ithin R/3 *he A/AP/4 di tionar# an (e seen as a %ogi a% representation or a s"perior %a#er o$er the ph#si a% "nder%#ing data(ase& *his data(ase !"st s"pport the re%ationa% data !ode%& *his !ode% is stri t%# fo%%o,ed (# data di tionar#&

A6o1' 4&'& 4"c'"on&r+


A =ata di tionar# in o!p"ting ter!s is the %o1rc o# "n#or,&'"on "n 0)"c) %+%' , (&'& "% ( #"n (& *he data di tionar# is the c n'r&l"@ ( &n( %'r1c'1r ( %o1rc o# "n#or,&'"on #or 61%"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 di tionar# are )no,n as !etadata& M '&(&'& "% ') ' r, #or ') (&'& 0)o% #1nc'"on "% 'o ( %cr"6 o') r (&'&! =ata in di tionar# is not the a t"a% data %i)e e!p& na!e or e!p& address ("t rather a t#pe of data ,hose f"n tion 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 di tionar# is a$oiding in onsisten ies ,hen defining data t#pe that ,i%% %ater (e "sed in different app%i ations& *his a$oids red"ndan ies& 3hen a t#pe is defined in the di tionar#, it is a$ai%a(%e to an# progra! in the app%i ation& A hange in the definition of a t#pe of data in the di tionar# a"to!ati a%%# affe ts an# other data or progra!, ,hi h has this data& Again, data di tionar# is a fast and effi ient ,a# to ans,er 1"estions s" h as ,hi h 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 Created on - Apr 20, 2004

Page 1> of 57

ABAP BASICS Ac'"2&'"on o# ("c'"on&r+ o6; c'% Aor a di tionar# o(+e t to (e effe ti$e at r"nti!e, that is, for a di tionar# o(+e t to (e a$ai%a(%e for "se ,ithin a progra!, transa tion, and so on, it !"st (e in a ti$e stat"s& Aor o(+e ts to (e o!e a ti$e, R/3 in %"des the AC*I-A*I;< f"n tion& 3hen a ta(%e or aggregated o(+e t is a ti$ated, it is p%a ed at the disposa% of the s#ste! as a r"nti!e o(+e t in a ,a# that !a)es it a$ai%a(%e 1"i )%# for the app%i ation progra! to a ess re%e$ant infor!ation of ne, a ti$ated o(+e ts& 3hen a di tionar# o(+e t is !odified, that !eans that the o(+e t pre$io"s%# e@isted and a ti$ated& 6o" need to rea ti$ate the o(+e t after !odifi ation& 3hen !ass a ti$ation is perfor!ed !assi$e%#, it !ight ta)e a 1"ite a %ong ti!e& *hen it sho"%d (e in the (a )gro"nd s#ste!& *his t#pe of a ti$ation is )no,n as (a )gro"nd a ti$ation& *he A/AP/4 =ata di tionar# is the entra% o!ponent of A/AP/4 repositor#& A =ata di tionar# is entra%iEed and str" t"red so"r e of infor!ation for ("siness app%i ation& *he A/AP/4 di tionar# is the ore of the R/3 de$e%op!ent s#ste!& It is the so"r e 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 s reen painter, !en" painter, and editor& So!e of the !ain a$ai%a(%e f"n tions in the A/AP/4 di tionar# are as fo%%o,s. Add, de%ete, !odif#, and !anage the definition of the di tionar# data& Preser$e the data integrit#& /e the entra% so"r e of infor!ation e&g& fro! the di tionar# #o" get the infor!ation a(o"t the defined re%ationship (et,een t,o ta(%es or e$en the dire tor# te%%s ,hether ta(%e is a ti$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(+e ts, #o" ,or) ,ith interna% representation of o(+e ts& 3ith this t#pe of operation the s#ste! perfor!an e is enhan ed and has the ad$antage that the de$e%op!ent too%s, s reen interpreters a%,a#s a ess "rrent data& 3hen an# of the data di tionar# o(+e ts are "sed in other parts of the de$e%op!ent ,or)(en h 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!ati a%%# )no,s a%% the properties and infor!ation of the fie%d&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 17 of 57

ABAP BASICS

*o a%% A/AP/4 di tionar#, fro! the !ain !en", Tool% ABAP/4 0or/6 nc) (&'& ("c'"on&r+ or n' r 'r&n%&c'"on SE--!

4&'& ("c'"on&r+ o6; c'%< T&6l < is a 2= data !atri@ ontaining ro,s and o%"!ns& Ro,s ontain data ,hi%e o%"!n indi ates fie%ds& *a(%e an ontain 0 or !"%tip%e ro,s& 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 ,hi h a ta(%e is reated& *he (asi differen e (et,een str" t"re and ta(%e is that the str" t"re does not e@ist at the "nder%#ing data(ase s#ste! %e$e%& Str" t"re e@ists as definition in the di tionar#& 5" 0%< A $ie, is an i!aginar# ta(%e& It ontains data, ,hi h is rea%%# stored in other ta(%es& *he ontents for the $ie, are d#na!i a%%# generated ,hen a%%ed fro! progra!& 4&'& l , n'< is definition of the properties and t#pe for a ta(%e fie%d& It is an inter!ediate o(+e t (et,een the o(+e t t#pe do!ain and the ta(%e fie%d& A fie%d in R/3 s#ste! is a%,a#s asso iated ,ith a data e%e!ent, ,hi h at the sa!e ti!e is re%ated to do!ain&
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 1J of 57

ABAP BASICS 4o,&"n< is for!a% definition of the data t#pe fro! a te hni a% point of $ie,& It sets the attri("tes s" h as data t#pe, %ength, possi(%e $a%"e range and so on& Loc/ o6; c'%< *hese t#pes of o(+e ts are "sed for %o )ing the a ess to data(ase re ords in ta(%e& *his !e hanis! is "sed to enfor e data integrit# that is t,o "sers annot "pdate the sa!e data at the sa!e ti!e& 3ith %o ) o(+e ts #o" an %o ) ta(%e-fie%d or ,ho%e ta(%e& S &rc) H l* O6; c'%< , ,hi h gi$es %ist of possi(%e $a%"es for either pri!ar# )e#s or nonpri!ar# )e#s&

T&6l % "n ABAP/4 ("c'"on&r+ *a(%es are the (asi o(+e ts in R/3 app%i ation& *here are a%!ost J000 ta(%es in R/3 s#ste!& Ao%%o,ing t#pes of ta(%es are a$ai%a(%e *ransparent ta(%es Poo% ta(%es C%"ster ta(%es

Aro! "ser point of $ie,, a%% ta(%es are "sed to store data ,hate$er (e the t#pe of ta(%e& *here is no differen e in the (eha$ior or operation of these ta(%es& A%% of the! an (e !anaged (# "sing standard ;P5< SK0& Do,e$er fro! an ad!inistrator point of $ie, transparent ta(%e do e@ists ,ith the sa!e str" t"re (oth in the di tionar# as ,e%% as in the data(ase, e@a t%# ,ith the sa!e data and fie%ds& 3hi%e other t,o are not transparent in the sense that the# are not !anagea(%e dire t%# "sing data(ase s#ste! too%s& 6o" an a ess these ta(%es in R/3 en$iron!ent fro! the A/AP/4 di tionar#& 6o" annot "se nati$e SK0 on these ta(%es& Poo% or %"ster ta(%es are %ogi a% ta(%es, ,hi h are arranged as re ords of transparent ta(%e& A ta(%e is !ade "p of ro,s and o%"!ns& 3hen the ta(%e is reated, its o%"!ns are na!edF data t#pe is s"pp%ied for ea h o%"!n& *here an (e on%# one data $a%"e in ea h o%"!n of ea h ro, in a ta(%e& Re ord or as it is a%%ed in different R=/2S is nothing ("t gro"p of fie%ds& 3hi%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#, ,hi h 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, ,hi h indefinites a sing%e "ni1"e re ord of the ta(%e& A ta(%e annot ha$e re ord ,ith d"p%i ate pri!ar# )e#& In an# R=/2S, ta(%es are re%ated to ea h other& /"t to re%ate ta(%e to ea h other it is ne essar# that one of the ta(%es ontain so!e infor!ation of other ta(%e& 2ost%# ta(%es are re%ated to ea h 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 pro ed"res a$ai%a(%e an !ini!iEe it& ;ne of the !ost i!portant f"n tions of foreign )e# is to ens"re data integrit#& Aor e@a!p%e sa# #o" ha$e Updated on - Apr 20, 2004 Page 19 of 57
Created on - Apr 20, 2004

ABAP BASICS 52P ta(%e, ,hi h has fie%ds. e!p& no&, e!p&na!e, dept& ode, sa%ar# and #o" ha$e =5P* ta(%es, ,hi h has dept& ode and dept&des & *hen in =5P* ta(%e dept& ode is pri!ar# )e# ,hi%e dept& ode in 52P ta(%e is foreign )e#& If #o" enter dept& ode for parti "%ar e!p%o#ee in 52P ta(%e the dept& ode sho"%d e@ist in =5P* ta(%e& S#ste! ,i%% he ) the $a%"e for dept& ode in =5P* ta(%e, and if does not e@ist then ,i%% f%ash error& In this ase =5P* is a%%ed he ) ta(%e ,hi%e 52P is foreign )e# ta(%e&

Cr &'"on o# '&6l Steps to reate a ta(%e Create do!ain Create data e%e!ent Create a t"a% ta(%e

Cr &'"ng 4o,&"n =o!ain as a%read# e@p%ained defines the te hni a% properties of a fie%d s" h as t#pe and $a%"e range& A do!ain an (e reated fro! initia% s reen of data di tionar# (# %i )ing on reate and %i )ing do!ain Radio("tton& Para!eters to (e passed are. =ata t#pe. 3here #o" need to enter the data t#pe a$ai%a(%e in SAP& Aie%d %ength. Aie%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& ;n e the do!ain is reated, sa$e and a ti$ate it, so that it an (e "sed for f"rther o(+e ts G(asi r"%e of di tionar#H&

Cr &'"ng 4&'& El , n' *he se ond step of ta(%e reation is to reate data e%e!ent& It assigns a ertain !eaning to the ta(%e fie%d, ,hi h 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%%o,s a%% fie%ds ,ith sa!e te hni a% 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. 2andator# fie%d&
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 20 of 57

ABAP BASICS =o!ain. A !andator# fie%d& If the do!ain does not e@ist, SAP an ta)e #o" dire t%# to do!ain definition s reen& *e@t e%e!ent. 6o" an enter des ription 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 a ti$ate& Cr &'"on o# &c'1&l '&6l Para!eters to (e passed for reation of ta(%e. Short des ription. =e%i$er# %ass. *a(%e fie%ds. e%e!ent& =ata %ass. SiEe ategor#. 2andator# fie%d& As per User Re1"ire!ent Spe if# ,hether pri!ar# )e#& In this ase it is !andator# to enter data 5sta(%ishes the ph#si a% area of the data(ase& A%%o,s #o" to spe if# esti!ated spa e re1"ire!ent for the ta(%e&

A"rther do,n "nder ("ffering s1"are (o@, the s#ste! a%%o,s spe if#ing ,hether ta(%e is going to (e ("ffered& 3hen a ta(%e is ("ffered, it is %oaded into the ta(%e ("ffer fro! the app%i ation ser$er !e!or# and it ,i%% re!ain there "nti% #o" s,it h off or re(oot s#ste!& If the ta(%e is to (e ("ffered, #o" need to spe if# the t#pe of ("ffering& A"%% is for entire ta(%e ,hi%e partia% is for on%# those re ords ,hi h are (eing a essed& ;n e the ta(%e is reated, it has to (e generated or a ti$ated to (e a(%e to a ess (# other o(+e ts %i)e progra!s&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 21 of 57

ABAP BASICS G n r&l In'ro(1c'"on 'o ABAP/4 SAP origina%%# de$e%oped the progra!!ing %ang"age A/AP/4 GAd$an ed /"siness App%i ation 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 in reasing re1"ire!ents of the ("siness app%i ations& At present, A/AP/4 is the on%# too% for de$e%oping app%i ations at SAP& SAP "sto!ers "se A/AP/4 for their o,n de$e%op!ents& *he A/AP/4 =e$e%op!ent 3or)(en h ontains a%% too%s #o" need to reate and !aintain A/AP/4 progra!s& A/AP/4 progra!s are not o!p%ied ("t generated& ="ring generation, the s#ste! reates a so- a%%ed r"nti!e o(+e t fro! the so"r e ode and the progra! attri("tes& 3hen #o" start the progra!, the s#ste! e@e "tes the r"nti!e o(+e t& A/AP/4, a fo"rth generation %ang"age, ontains a%% "s"a% ontro% str" t"res and !od"%ariEing on epts for str" t"red progra!!ing& *he three parts of the A/AP/4 %ang"age are. Str" t"re and e@e "tion of A/AP/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%# se1"entia% progra!!ing %ang"ages s" h as A;R*RA<, PASCA0, or C& A/AP/4 instead shares ertain si!i%arities ,ith !od"%ar, e$ent-orient progra!!ing %ang"ages s" h as -is"a% /asi or LA-A& *he t,o !ost i!portant state!ents on erning str" t"re and e@e "tion are. An A/AP/4 progra! has a !od"%ar str" t"re& Aor e@e "tion, #o" need a spe ia% r"nti!e en$iron!ent& *his !eans, that A/AP/4 so"r e te@ts a%,a#s onsist of a o%%e tion of progra! !od"%es Gone sing%e !od"%e in the easiest aseH or the se1"entia% set of state!ents& *he indi$id"a% progra! !od"%es onsist of se1"entia% e%e!ents& *he set of state!ents of a progra! !od"%e is a%so a%%ed pro essing (%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, ,hi h an o!!"ni ate ,ith t e list processor or t e dialog processor, depending on the progra! t#pe& Progra! f%o, ,ithin the indi$id"a% pro essing (%o )s is se1"entia%, as #o" )no, it fro! other se1"entia% progra!!ing %ang"ages Gfor e@a!p%e, A;R*RA<, PASCA0 and CH& 3ithin the pro essing (%o )s, #o" an "se the genera% ontro% state!ents for the progra! f%o,, s" h as IA, =;5S, 3DI05, A/AP/4 does not ontain 8;*; e%e!ents&
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 22 of 57

ABAP BASICS 3e !ain%# "se progra!s that onsist of a sing%e pro essing (%o ) on%# and, therefore, (eha$e !ost %i)e%# %i)e progra!s of other se1"entia% progra!!ing %ang"ages& Aor progra!!ing app%i ations, the entire%# se1"entia% on ept is not s"ffi ient& SAP disting"ishes (et,een t,o genera% t#pes of app%i ation progra!s. R *or'%< 6o" "se reports to read data(ases and represent the res"%ts in %ists& Reports are o%%e tions of pro essing (%o )s that the s#ste! a%%s depending on e$ents& 4"&log *rogr&,%< 6o" an dia%og progra!s to e@e "te transa tions, ,hi h "s"a%%# read and hange data(ases& =ia%og progra!s are o%%e tions of pro essing (%o )s Gso- a%%ed !od"%e poo%sH that are a%%ed (# a s reen f%o, %ogi & *he third part of the User:s 8"ide des ri(es dia%og progra!!ing in detai%& R *or'% c&n c&ll ("&log *rogr&,% &n( 2"c 2 r%&! In its easiest $ersion, an A/AP/4 progra! ontains one sing%e se1"entia% pie e of oding and, th"s, one sing%e pro essing (%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% pro essing f%o,& A/AP/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& A/AP/4 s"pports ("siness-re%ated data t#pes and operations& 6o" an e@e "te a% "%ations "sing spe ia% data and ti!e fie%ds& *he s#ste! a"to!ati a%%# e@e "tes a%% ne essar# t#pe on$ersions& A/AP/4 pro$ides a n"!(er of f"n tions for pro essing hara ter strings& A/AP/4 a%%o,s #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& A/AP/4 ontains a spe ia% t#pe of s"(ro"tine, a%%ed f"n tion !od"%e& A"n tion !od"%es are stored and !aintained in a entra% %i(rar#& *he# ha$e %ear%# defined data interfa es to the a%%ing progra!& 6o" an test f"n tion !od"%es in a stand-a%one !ode independent of the a%%ing progra!& A/AP/4 ontains an SK0 s"(set a%%ed ;P5< SK0& ;P5< SK0 a%%o,s #o" to read and hange data(ase ta(%es independent of the "nder%#ing data(ase s#ste!& A/AP/4 a%%o,s #o" to define and pro ess interna% ta(%es that e@ist on%# for the e@e "tion period of the progra!& Interna% ta(%es effi ient%# 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 Created on - Apr 20, 2004

Page 23 of 57

ABAP BASICS A/AP/4 a%%o,s #o" to store data not on%# in data(ases ("t a%so as se1"entia% fi%es on app%i ation and presentation ser$ers&

REPORTS Reports are A/AP/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 s reen or printed for!& Reports are stand-a%one progra!s& *he "ser an e@e "te reports dire t%# $ia the progra! na!e, for e@a!p%e, (# hoosing S#ste! ? Uti%ities ? Reporting& A report progra! ontains a o%%e tion of pro essing (%o )s for different e$ents that are a%,a#s triggered e@terna%%#& In a report, #o" an rea t on e$ents (# progra!!ing the orresponding pro essing (%o )s or ignore the e$ents (# not ,riting the orresponding pro essing (%o )s& A report itse%f ne$er reates e$ents& Reports an "se %ogi a% data(ases or se%e t state!ents defined (# de$e%oper& Aor ea h app%i ation, SAP s"pp%ies %ogi a% data(ases& ;r #o" an easi%# reate %ogi a% data(ase #o"rse%f& 5$ent ontro% of a report orresponds to a ertain s he!e. 3hen a report is e@e "ted, the A/AP/4 pro essor reates together ,ith the %ogi a% data(ase "sed Gif an#H a se1"en e of ertain e$ents for ,hi h #o" an progra! pro essing (%o )s& *he hrono%og# of the e$ents is G!ore or %essH Steps in$o%$ed in reating a Report. -! Proc %%"ng ') % l c'"on %cr n After starting a report, the se%e tion s reen a%%o,s the "ser to enter %i!its or ontro% $a%"es for f"rther report pro essing& *he report an ontain se$era% pro essing (%o )s for e$ents d"ring se%e tion s reen pro essing, for e@a!p%e, for he )ing the inp"t $a%"es& 3! R &("ng ') (&'&6&% After se%e tion s reen pro essing o!e the e$ents for reading the data(ase& 5ither the report reads data fro! re%ationa% data(ases it "sing the orresponding A/AP/4 state!ents Gopen SK0H or %ea$es this tas) to a %ogi a% data(ase& In the %atter ase, the %ogi a% data(ase reates a se1"en e 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 Created on - Apr 20, 2004

Page 24 of 57

ABAP BASICS *he %ast part of the pro essing se1"en e ontro%%ed (# the A/AP/4 pro essor is the %ist o"tp"t on the s reen or printer& 3hen disp%a#ing the %ist on the s reen, "ser an trigger other reports, that are intera ti$e and are e$ent dri$en& Aor e@a!p%e, (# %i )ing the !o"se& /# progra!!ing pro essing (%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 pro essing (%o ), ,hi h is a%%ed (# a standard e$ent& *his standard e$ent is triggered dire t%# after pro essing the se%e tion s reen&

4IALOG PROGRAMS 6o" "se dia%og progra!s to e@e "te transa tions& *he "sers of dia%og progra!s in dia%og sessions read and hange data(ase ta(%es& Apart fro! the a t"a% data pro essing G;pen SK0H, "pdate and en1"e"e on epts are of great i!portan e ,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 s reen that itse%f is %in)ed to a transa tion ode& *he transa tion ode deter!ines the initia% s reen ,ith ,hi h the dia%og session starts& =ia%og progra!s are ontro%%ed (# s reen f%o, %ogi *he a t"a% A/AP/4 dia%og progra! is a so- a%%ed !od"%e poo%& A !od"%e poo% ontains a o%%e tion of dia%og !od"%es that are a%%ed (# the s reen f%o, %ogi & *o ea h !od"%e poo%, at %east one, ("t "s"a%%# se$era% s reens are a%%o ated& 5a h s reen has f%o, %ogi & *he f%o, %ogi onsists of P/; Gpro ess /efore o"tp"tH and PAI Gpro ess After Inp"tH (%o )s& *his f%o, %ogi does not "se the A/AP/4 progra!!ing %ang"age and the A/AP/4 5ditor too%, ("t a spe ia% state!ent set and the S reen Painter too%, ,hi h #o" a%so "se to %a#o"t s reens& *he f%o, %ogi !ain%# ontains the hrono%ogi a%%# 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& 5a h s reen of a dia%og session th"s is the $isi(%e part of a d#npro, to ,hi h a%so the f%o, %ogi (e%ongs& *he pro essing %ogi of a dia%og session is stored in the orresponding !od"%e poo% in the for! of A/AP/4 !od"%es& *he A/AP/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 ea h d#npro of a !od"%e poo% an a%% ea h P/; or PAI !od"%e of this !od"%e poo%& 6o" an "se A/AP/4 state!ents in the pro essing %ogi of the !od"%e poo% to ontro% the hrono%og# of the different d#npros& After starting a dia%og session $ia the transa tion ode, ,hi h is fir!%# onne ted to a d#npro of the !od"%e poo%, the s reen f%o, %ogi passes "ser entries to the pro essing %ogi in the A/AP/4 !od"%e poo%& *he pro essing %ogi pro esses
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 25 of 57

ABAP BASICS the "ser entries Gdata(ase a essesH and, if re1"ired, defines the appropriate s"(se1"ent s reens&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 2> of 57

ABAP BASICS 4&'& T+* % &n( 4&'& O6; c'% =ata t#pes and data o(+e ts are essentia% o!ponents of the A/AP/4 t#pe on epts& /oth an (e de %ared and !aintained (# "ser& Un%i)e other progra!!ing %ang"ages in A/AP/4 #o" an reate =A*A *6P5S independent%#& 4&'& T+* % Are p"re des riptions <o !e!or# is asso iated ,ith data t#pes& =es ri(es the te hni a% properties of data o(+e ts& Str" t"re and definition %assif# data t#pes& Can (e of. 1& 5%e!entar# or str" t"red 2& Predefined or "ser defined Pr ( #"n ( 50525<*AR6 C, =, A, I, <, P, *, I U% rA( #"n ( /ased "pon e%e!entar# =ata t#pes& 5&g&, *6P5S. n"!(er t#pes I& Can:t a%%o ate !e!or# to t#pes& User defined str" t"red t#pes are Aie%d String and interna% ta(%es&

6o" an "se dire t%#

S*RUC*UR5=

Predefined t#pes are *A/05S

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 27 of 57

ABAP BASICS 4&'& O6; c'% =ata o(+e ts are "nits reated d"ring r"nti!e& =ata o(+e t annot e@ist ,itho"t data t#pe& ; "pies !e!or# spa e& K"n(% o# 4&'& O6; c'% -! INTERNAL 4ATA OB9ECTS

L"' r&l A %itera% has a fi@ed $a%"e& 5@ 3RI*5. B3;R7 DAR=C 5&r"&6l % =A*A state!ent is "sed to reate $aria(%es 5@ =A*A. <U2 *6P5 I <U2 is a $aria(%e de %ared (# =A*A state!ent& An# $aria(%e, ,hi h #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(+e t& 5@& 3e ha$e a%read# de %ared <U2 (# =A*A state!ent& =A*A. PRIC5 0I75 <U2& Dere $aria(%e is de %ared (# "sing 0I75 para!eter, ,hi h te%%s s#ste! that pri e has a%% the attri("tes of data o(+e t <U2 i&e&, PRIC5 is a%so of t#pe I& *he !ain differen e (et,een *6P5 and 0I75 para!eter ,hen defining or de %aring the o(+e t is that *6P5 is "sed to refer e@isting =A*A *6P5 Ge%e!entar# or str" t"red or "ser definedH ,hi%e 0I75 is "sed to de %are data o(+e ts ,ith referen e to e@isting =A*A ;/L5C*S& Con%'&n' Constant is a data o(+e t, ,hi h ontains fi@ed $a%"e thro"gh o"t the progra!& Constant an (e de %ared in progra! (# "sing C;<S*A<* state!ent& 5@& C;<S*A<*. I<* *6P5 I -A0U5 15&
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 2J of 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& 3! EBTERNAL 4ATA OB9ECTS Are defined in ta(%es i&e&, in A/AP/4 di tionar#& 6o" an a ess this data fro! ta(%e& *A/05S. SA0I8D* =A*A. S5A*S 0I75 SA0I8D*-S5A*S2AI& 3! SYSTEMA4EFINE4 4ATA OB9ECTS SPAC5 ' S6S*52 -ARIA/05S %i)e s#-"na!e, s#-dat"!, ' s#-repid& 4! SPECIAL 4ATA OB9ECTS PARA25*5RS. are $aria(%e, ,hi h an a ept $a%"e fro! "ser& S505C*I;<S CRI*5RIA. are spe ia% interna% ta(%es to a ept $a%"e range fro! "ser&

N ( #or 4&'& '+* %< Consider the fo%%o,ing 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 ea h and e$er# state!ent& /"t onsider the fo%%o,ing ase ,here *6P5S has (een "sed& *6P5S.strG20H =A*A.fna!e t#pe str,
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 29 of 57

ABAP BASICS 2na!e t#pe str, 0na!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%e ted for a%% the fie%ds& If #o" define a%% the t#pes in *6P5-P;;0 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 a ept inp"t fro! "ser& PARA25*5R state!ent is "sed ,hen #o" ,ant "ser to enter data and depending "pon ,hat he enters #o" need to ta)e a tion& *he para!eter state!ent de %ares the $aria(%e and a%so a%%o,s s#ste! to a ept 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%e tion s reen on ,hi h "ser enters the data i&e&, in this ase n"! is de %ared of t#pe I and "ser an enter an# n"!(er& 5ntered $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 2 N n"! 4 5 3rite. / 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%e tion s reen is disp%a#ed the defa"%t $a%"e is disp%a#ed& User an either "se sa!e $a%"e or o$er,rite the $a%"e& Para!eter of t#pe hara ter 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& 3hen para!eter is defined as Radio("tton, it needs to (e atta hed to one gro"p& ;n%# one Radio("tton of one gro"p an (e %i )ed&
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 30 of 57

ABAP BASICS 5$er# para!eter an (e asso iated ,ith %ang"age dependent te@t that is disp%a#ed on the se%e tion s reen& *his an (e done ,ith the he%p of te@t e%e!ents&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 31 of 57

ABAP BASICS WRITE S'&' , n' *he (asi APA//4 state!ent for o"tp"tting data on the s reen is 3RI*5& S#nta@. 3RI*5 Pfie%dQ PoptionQ& *his state!ent o"tp"ts the fie%d PfQ to the "rrent %ist in its standard o"tp"t for!at& /# defa"%t, the %ist is disp%a#ed on the s reen& *he fie%d Pfie%dQ an (e an# $aria(%e or ta(%e fie%d or +"st %itera%& PR;8RA2 R=52; 3RI*5. /OD500;:& 3hen #o" start this progra!, the s#ste! %ea$es the "rrent s reen i&e&, #o"r editor s reen and (ran hes to the o"tp"t s reen, ,hi h is a%so a%%ed as %ist s reen. *he %ist s reen has the sa!e na!e as the tit%e of the progra! spe ified in the progra! attri("tes& Airst %ine on the s reen 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%%o,ed (# one %ine and then the o"tp"t is disp%a#ed& 3rite . OD500;:& 3rite . O3;R7 DAR=: ;n the s reen, the o"tp"t is nor!a%%# %eft +"stified& /"t in a(o$e ase, (e a"se ,e ha$e "sed t,o 3RI*5 state!ents, the o"tp"t fie%ds are disp%a#ed one after the other, ea h separated (# one o%"!n Gi&e&, one (%an)H& If there is not eno"gh spa e 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 A0;A*, I<*585R, and PAC75= i&e&, n"!(er fie%d& *he n"!eri data t#pes A, P, and I are right +"stified and padded ,ith (%an)s on the %eft& If there is s"ffi ient spa e, tho"sands of separators are a%so o"tp"t& If a t#pe P fie%d ontains de i!a% p%a es, the defa"%t o"tp"t %ength is in reased (# one& 3ith the data t#pe =, the interna% for!at of a date differs fro! its o"tp"t for!at& 3hen #o" "se the 3RI*5 state!ent for o"tp"tting data, the s#ste! a"to!ati a%%# o"tp"ts dates of t#pe = in the for!at spe ified in the "ser:s !aster re ord Ge&g& ==/22/6666 or 22/==/6666H&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 32 of 57

ABAP BASICS For,&''"ng o1'*1' 6o" an position the o"tp"t of a 3RI*5 state!ent on the s reen (# !a)ing a for!at spe ifi ation (efore the fie%d na!e as fo%%o,s. S#nta@. 3RI*5 A* S/TSPposQTSGP%enQHT PfQ, 3here Othe s%ash:/O denotes a ne, %ine, PposQ is a n"!(er or $aria(%e denoting the position on the s reen, P%enQ is a n"!(er or $aria(%e %ong denoting the o"tp"t %ength&

Aor $aria(%es #o" need to !ention the A*, for dire t $a%"es it is not ne essar#& =A*A. 05< *6P5 I -A0U5 10, P;S *6P5 I -A0U5 11, *5I* G10H -A0U5 O12345>7J90: 3RI*5 A* P;S G05<H *5I*& *his prod" es the fo%%o,ing o"tp"t on the s reenF *he te@t 4 12345>7J90 4 appears in the te@t& If the o"tp"t %ength P%enQ is too short, fe,er hara ters are disp%a#ed& <"!eri fie%ds are tr"n ated on the %eft and prefi@ed ,ith an asteris) GUH& A%% other fie%ds are tr"n ated on the right, ("t no indi ation is gi$en that the fie%d is shorter& =A*A. <U2/5R *6P5 I -A0U5 12345>7J90, *5I* G10H -A0U5 Oa( defghi+:& 3RI*5. G5H <U2/5R, /G5H *5I*& *his prod" es the fo%%o,ing o"tp"t. 7J90 a( de In the defa"%t setting, #o" annot reate e!pt# %ines ,ith the 3RI*5 state!ent& 3RI*5. O;ne:, /O :, / O*,o:
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 33 of 57

ABAP BASICS

*he o"tp"t %oo)s as fo%%o,s. ;ne *,o *he s#ste! s"ppresses %ines that ontain nothing ("t e!pt# spa es& 6o" an "se $ario"s for!atting options ,ith the 3RI*5 state!ent& S#nta@ 3RI*5VVVV Pfie%dQ PoptionQ For,&''"ng o*'"on% #or &ll (&'& '+* % "ption 05A*-LUS*IAI5= C5<*5R5= RI8D*-LUS*IAI5= <;-8AP <;-R5R; Purpose ;"tp"t is %eft +"stified& ;"tp"t is entered& ;"tp"t is right +"stified& *he (%an) after the fie%d PfQ is o!itted& If a fie%d ontains on%# Eeros, these are rep%a ed (# (%an)s& Aor t#pe C and < fie%ds, %eading Eeros are rep%a ed a"to!ati a%%#&

For,&''"ng o*'"on% #or n1, r"c #" l(% O*'"on <;-SI8< =5CI2A0S PdQ 5IP;<5<* PeQ R;U<= PrQ CURR5<C6 P Q U<I* P"Q P1r*o% *he %eading sign is not o"tp"t& PdQ defines the n"!(er of digits after the de i!a% point& In t#pe A fie%ds, the e@ponent is defined in PeQ *#pe P fie%ds are !"%tip%ied (# 10UUG-rH and then ro"nded Aor!at a ording to "rren # P Q in ta(%e *CURI& *he n"!(er of de i!a% p%a es is fi@ed a ording to the "nit P"Q spe ified in ta(%e *00> for t#pe P fie%ds& Page 34 of 57

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

ABAP BASICS

Hor"@on'&l l"n % 6o" an generate horiEonta% %ines on the o"tp"t s reen (# "sing the fo%%o,ing s#nta@. S#nta@ U0I<5 3i%% dra, a horiEonta% %ine& U0I<5 G10H 3i%% start dra,ing horiEonta% %ine fro! 10th o%"!n position& 3RI*5 at 10G40H S6-U0I<5 *his state!ent dra,s a horiEonta% %ine fro! 10th position& 5 r'"c&l l"n % 6o" generate $erti a% %ines one the o"tp"t s reen (# "sing the fo%%o,ing s#nta@. S#nta@ 3RI*5 SA* S/T SPposQTT S6--0I<5& Bl&n/ l"n % 6o" an generate (%an) %ines on the s reen (# "sing the fo%%o,ing s#nta@ . S#nta@ S7IP SPn"!(erQT Starting on the "rrent %ine, this state!ent generates Pn"!(erQ (%an) %ines on the o"tp"t s reen& If no $a%"e is spe ified for Pn"!(erQ, one (%an) %ine is o"tp"t& In the standard setting, #o" annot reate e!pt# %ines ,ith the 3RI*5 state!ent a%one& *o position the o"tp"t on a spe ifi %ine on the s reen "se. S#nta@ S7IP *; 0I<5 Pn"!(erQ *his state!ent a%%o,s #o" to !o$e the o"tp"t position "p,ards or do,n,ards&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 35 of 57

ABAP BASICS Br&nc) % 0i)e other higher progra!!ing %ang"ages, A/AP/4 pro$ides standard )e#,ords to ontro% the f%o, of a progra!& Us"a%%# A/AP/4 progra!s get e@e "ted state!ent (# state!ent& 2an# 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 (#. 6r&nc)"ng CIF> CASED loo*"ng C4O> WHILED Do,e$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& 5$ents are generated either fro! other A/AP/4 progra!s or fro! intera ti$e "ser inp"t G%i)e, for e@a!p%e, "sing the !o"se to %i ) on the s reenH& *he s#ste! does not ne essari%# pro ess the state!ents in the sa!e se1"en e as the# are %isted in an A/AP/4 progra!& *his !a)es A/AP/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 IA state!ent a%%o,s #o" to ("2 r' ') *rogr&, #lo0 'o & *&r'"c1l&r %'&' , n' (%o ), depending on a ondition& *his state!ent (%o ) onsists of a%% the o!!ands ,hi h o "r (et,een an IA state!ent and the ne@t 50S5IA, 50S5, or 5<=IA state!ent& S#nta@ IAP ondition1Q Pstate!ent (%o )Q 50S5 Pstate!ent (%o )Q 5<=IA 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 pro essing after the 5<=IA state!ent&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 3> of 57

ABAP BASICS *o introd" e a%ternati$e onditions, #o" an "se 50S5IA state!ents& If the first ondition is fa%se, the s#ste! pro esses the fo%%o,ing 50S5IA state!ent in the sa!e ,a# as the IA state!ent& 50S5 (egins a state!ent (%o ) ,hi h is pro essed if none of the IA and 50S5IA onditions is tr"e& *he end of the %ast state!ent (%o ) !"st a%,a#s (e on %"ded ,ith 5<=IA& IA P ondition1Q& Pstate!ent (%o )Q 50S5IA P ondition2Q& Pstate!ent (%o )Q 50S5IA P ondition3Q& Pstate!ent (%o )Q 50S5& Pstate!ent (%o )Q 5<=IA& A/AP/4 a%%o,s "n%i!ited nesting of IA 4 5<=IA state!ent (%o )s, ("t the# !"st ter!inate ,ithin the sa!e pro essing (%o )& In other ,ords, an IA 4 5<=IA (%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 IA state!ent or the CAS5 state!ent as fo%%o,s. S#nta@ CAS5 PfQ& 3D5< Pf1Q& Pstate!ent (%o )Q 3D5< Pf2Q& Pstate!ent (%o )Q 3D5< Pf3Q& Pstate!ent (%o )Q 3D5< ;*D5RS& Pstate!ent (%o )Q 5<=CAS5& *he s#ste! e@e "tes the state!ent (%o ) after the 3D5< state!ent if the ontents of PfQ e1"a%s the ontents of PfiQ, and ontin"es pro essing after the 5<=CAS5 state!ent& *he state!ent (%o ) after the optiona% 3D5< ;*D5RS state!ent is e@e "ted if the ontents of PfQ do not e1"a% an# of the PfiQ ontents& *he %ast state!ent (%o ) !"st (e on %"ded ,ith 5<=CAS5& *he onditiona% (ran hing "sing CAS5 is a shorter and si!p%er for! of si!i%ar pro essing ,ith IA& 3hen #o" ha$e !an# onditions IA (e o!es !ore o!p%i ated in s" h ases CAS5 is "sed& Updated on - Apr 20, 2004 Page 37 of 57
Created on - Apr 20, 2004

ABAP BASICS

LOOPING Loo*"ng 0"') 4O %'&' , n'


If #o" ,ant to ,rite #o"r na!e sa# for 10 ti!es, #o" need to ,rite 3RI*5 state!ent for 10 ti!es& 3hen #o" ,ant to pro ess a state!ent !ore than on e, #o" an ,rite this state!ent ,ithin a %oop ,ith the =; state!ent as fo%%o,s. S#nta@ =; 5 ti!es& 3rite . / na!e& 5<==;& *he s#ste! ontin"es pro essing the state!ent (%o ) for 5 ti!es introd" ed (# =; and on %"ded (# 5<==;& *he s#ste! fie%d S6-I<=5I ontains the n"!(er of ti!es the %oop has (een pro essed 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! 3RI*5 state!ent for 5 ti!es& /"t that is not the ase a%,a#s& 2an# ti!es #o" need to ter!inate the %oop depending "pon ertain onditions& *his an (e done, (# "sing EBIT or STOP state!ent& *he i!portant point to re!e!(er ,hen #o" don:t #o" "se *I25S option, is to a$oid end%ess %oops ,hen ,or)ing ,ith the =; state!ent& If #o" do not "se the *I25S option, in %"de at %east one 5II*, S*;P state!ent so that the s#ste! an %ea$e the %oop& 5II* and S*;P ta)es #o" o"t of that %oop& Loo*"ng 0"') WHILE S'&' , n' If #o" ,ant to pro ess a state!ent (%o ) !ore than on e as %ong as a ondition is tr"e, #o" an progra! a %oop ,ith the 3DI05 state!ent as fo%%o,s. S#nta@ =A*A. 2 *6P5 I -A0U5 0& 3DI05 2 P 10& 3RI*5. / 2& 2 N 2 M 1&
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 3J of 57

ABAP BASICS 5<=3DI05& *he s#ste! ontin"es pro essing the state!ent (%o ) introd" ed (# 3DI05 and on %"ded (# 5<=3DI05 state!ents as %ong as 2 is %ess than 10 or "nti% the s#ste! finds an 5II*, S*;P& *he s#ste! fie%d SYAIN4EB ontains the n"!(er of ti!es the %oop has (een pro essed& 6o" an nest 3DI05 %oops an# n"!(er of ti!es and a%so o!(ine the! ,ith other %oops& 4"## r nc 6 '0 n 4O loo* &n( WHILE is that in 3DI05, 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 *I25S option and then the ondition is he )ed Gif #o" ha$e an#H& 6o" an ha$e nested =; and 3DI05 or =; and IA or IA and IA or an# possi(%e sit"ation&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 39 of 57

ABAP BASICS S'r"ng O* r&'"on% A/AP/4 pro$ides se$era% )e#,ords for pro essing data o(+e ts of t#pe C, a%so )no,n as hara ter strings& S)"#' co,,&n( *o shift the ontents of a fie%d, (# one position or one hara ter #o" an "se the SDIA* state!ent& Using SDIA* a%%o,s #o" to shift fie%d ontents, (#te-(#-(#te or hara ter-(#hara ter& 3ith the SDIA* state!ent, #o" an e@e "te the fo%%o,ing. String N OD500;:& String 1 N OA00 ;A 6;U:& String 2 N O3;R7 DAR=:& Shift string Shift string1 (# 2 p%a es& Shift string2 right& Shift string1 (# 2 p%a es ir "%ar& *he o"tp"t ,i%% (e 500; 4 /# defa"%t if nothing is spe ified then string is shifted (# one position& 0 ;A 6;U 4 Dere the string is shifted (# 2 p%a es& W3;R7 DAR= 4 In this ase the string is shifted to right (# one p%a e G,ith %eading (%an)sH 7 DAR=3;R 4 In this ase the string is shifted to the %eft so that 3 hara ters on the %eft appear on the right& R *l&c co,,&n( 6o" "se the R5P0AC5 state!ent& S#nta@ R5P0AC5Pstr%Q3I*DPstr2QI<*;P QS05<8*DP1QT& A/AP/4 sear hes the fie%d P Q for the first o "rren e of the first, P1Q positions of the pattern Pstr1Q& If no %ength is spe ified, it sear hes for the pattern Pstr1Q in its f"%% %ength& *hen, the state!ent rep%a es the first o "rren e of the pattern Pstr1Q in fie%d P Q,ith the string Pstr2Q& If a %ength P%Q ,as spe ified, on%# the re%e$ant part of the pattern is rep%a ed& R5P0AC5 S*R1 3I*D S*R2 I<*; S*RI<8& Dere ,ho%e string is sear hed for string1 and is rep%a es ,ith str2& R5P0AC5 O': 3I*D O2:
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 40 of 57

ABAP BASICS Dere the s#ste! sear hes string for ' and rep%a es it ,ith O2:& TRANSLATE co,,&n( S#nta@ *RA<S0A*5P Q *; UPP5R CAS5& *RA<S0A*5P Q *; 0;35R CAS5& *hese state!ents on$ert a%% %o,er ase %etters in the fie%d P Q to "pper ase or $i e $ersa& 6o" an "se *RA<S0A*5 to s"(stit"te the hara ters in a string %i)e rep%a e& /"t the !ain differen e (et,een *rans%ate and Rep%a e is that Rep%a e state!ent rep%a es on%# one o "rren e of parti "%ar hara ter ,hi%e *rans%ate rep%a es a%% the o "rren es of the hara ter& 3hen "sing s"(stit"tion r"%es, "se the fo%%o,ing s#nta@. S#nta@ *RA<S0A*5 P Q USI<8 PrQ& STRLEN co,,&n( *o deter!ine the %ength of a hara ter string "p to the %ast hara ter other than SPAC5, "se the ("i%t-in f"n tion S*R05< as fo%%o,s. S#nta@ < N S*R05< G S*R H& Dere < is defined in =A*A state!ent as t#pe i& S*R05< pro esses an# operand P Q as a hara ter data t#pe, regard%ess of its rea% t#pe& <o on$ersions are perfor!ed& CON4ENSE co,,&n( *o de%ete s"perf%"o"s (%an)s in hara ter fie%ds, "se the C;<=5<S5 state!ent. S#nta@ C;<=5<S5 P Q S<;-8APST& *his state!ent re!o$es an# %eading (%an)s in the fie%d P Q and rep%a es other se1"en es of (%an)s (# e@a t%# one (%an)& *he res"%t is a %eft-+"stified se1"en e of ,ords, ea h separated (# one (%an)& If the addition <;-8APS is spe ified, a%% (%an)s are re!o$ed& CONCATENATE co,,&n( *o on atenate separate hara ter strings into one, "se the C;<CA*5<A*5 state!ent. S#nta@ C;<CA*5<A*5 P 1Q VP nQ I<*; P Q SS5PARA*5= /6 PsQT& *his state!ent on atenates the hara ter fie%ds P 1Q to P nQ and assigns the res"%t to P Q& *rai%ing (%an)s are ignored d"ring this operation&
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 41 of 57

ABAP BASICS C;<CA*5<A*5 S*R O.: S*R2 I<*; S*RI<8& Dere str, str2 and O.: is on atenated and res"%t is stored in string& SPLIT co,,&n( *o sp%it a hara ter string into t,o or !ore s!a%%er strings, "se the SP0I* state!ent. S#nta@ SP0I* P Q A* Pde%Q I<*; P %QV&P nQ& *his state!ent sear hes the hara ter fie%d P Q for de%i!iter strings Pde%Q and the parts (efore and after the de%i!iters are p%a ed in the target fie%ds P 1QV&P nQ& *o p%a e a%% frag!ents in different target fie%ds, #o" !"st spe if# eno"gh target fie%ds& ;ther,ise, the %ast target fie%d is fi%%ed ,ith the rest of the fie%d P Q and sti%% ontains de%i!iters& SP0I* 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+ (&'& o6; c'% "n &ll %'&' , n'%> 0)"c) *roc %% ') % (&'& o6; c'%! *o do so, spe if# the na!e of a data o(+e t in a state!ent as fo%%o,s. S#nta@ PfQSMPoQTSGP%QHT *he operation of the state!ent is perfor!ed for the part of the fie%d PfQ that (egins at position PoQM1 and has a %ength of P%Q& If the %ength P%Q is not spe ified, the fie%d is pro essed for a%% positions (et,een PoQ 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 Created on - Apr 20, 2004

Page 42 of 57

ABAP BASICS OPEN SEL In the R/3 S#ste!, %ong-%ife data is stored in re%ationa% data(ase ta(%es& Str" t"red K"er# 0ang"age GSK0H ,as reated for a essing re%ationa% =ata(ase& SK0 has t,o state!ent t#pes. =ata =efinition 0ang"age G==0H state!ents and =ata 2anip"%ation 0ang"age G=20H state!ents& *; in %"de SK0 state!ents in an A/AP/4 progra!, "se <ati$e SK0& *o a$oid in o!pati(i%ities (et,een different data(ase ta(%es and a%so to !a)e A/AP/4 progra! independent of the data(ase s#ste! in "se, SAP has reated a set of separate SK0 state!ents a%%ed ;pen SK0& ;pen SK0 ontains a s"(set of standard SK0 state!ents as ,e%% as so!e enhan e!ents, ,hi h are spe ifi to SAP& Using ;pen SK0 ena(%es #o" to a ess an# data(ase ta(%es a$ai%a(%e to the SAP s#ste! regard%ess of the !an"fa t"rer (e it ;ra %e, Infor!i@ et & *he differen e (et,een ;pen SK0 and <ati$e SK0 is as fo%%o,s. A data(ase interfa e trans%ates SAP:s ;pen SK0 state!ents into SK0 o!!ands spe ifi to the data(ase in "se& <ati$e SK0 state!ents a ess the data(ase dire t%#& ;pen SK0 )e#,ords 7e#,ords Used for S505C*. Reading =ata fro! =ata(ase *a(%es I<S5R*. Adding 0ines to =ata(ase *a(%es UP=A*5. Changing 0ines in =ata(ase *a(%es 2;=IA6. Adding or Changing 0ines =505*5. =e%eting 0ines fro! =ata(ase *a(%es 3hen "sing ;pen SK0 state!ents in an A/AP/4 progra!, #o" !"st ens"re the fo%%o,ing. 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 A/AP/4 =i tionar#&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 43 of 57

ABAP BASICS S l c' %'&' , n' *he fo%%o,ing s#ste! fie%ds p%a# an i!portant ro%e in ;pen SK0 operations. SYASUBRC As ,ith other A/AP/4 state!ents, the ret"rn ode $a%"e in the s#ste! fie%d S6-SU/RC indi ates after ea h ;pen SK0 operation ,hether or not the operation ,as s" essf"%& If an operation is s" essf"%, S6-SU/RC N 0& If an operation is "ns" essf"% 4 S6-SU/RC PQ 0 SYA4BCNT *he $a%"e in the S6-=/C<* fie%d indi ates ho, !an# %ines ,ere affe ted (# the operation or ho, !an# %ines ha$e a%read# (een pro essed& *o read data fro! a data(ase ta(%e, "se the S505C* o!!and& S#nta@ S505C*P,hatQ AR;2 Pta(%e na!eQ SI<*; P$aria(%e, another ta(%eQT S3D5R5 P onditionQT& *his state!ent has se$era% (asi %a"ses& 5a h %a"se is des ri(ed in the fo%%o,ing ta(%e& S505C*P,hatQ AR;2 Pta(%e na!eQ I<*; P$aria(%es or another ta(%eQ 3D5R5 P onditionQ *he S505C* %a"se defines ,hether the res"%t of the se%e tion is a sing%e %ine or a ,ho%e ta(%e, or fe, o%"!ns& AR;2 Pta(%e na!eQ *he AR;2 %a"se spe ifies the data(ase ta(%e or $ie, Pso"r eQ fro! ,hi h the data is to (e se%e ted& I<*; P$aria(%e, another ta(%eQ *he I<*; %a"se deter!ines the target area PtargetQ into ,hi h the se%e ted data is to (e read& It an a%so (e p%a ed (efore the AR;2 %a"se& If #o" do not spe if# an I<*; %a"se, the s#ste! "ses the ta(%e ,or) area& T) '&6l 0or/ &r & "% & ) &( r l"n > 0)"c) "% &1'o,&'"c&ll+ cr &' ( 6+ ') TABLES %'&' , n'! 3D5R5 P onditionQ
Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 44 of 57

ABAP BASICS

*he 3D5R5 %a"se spe ifies ,hi h %ines are to (e read (# spe if#ing onditions for the se%e tion& Choosing the 0ines to (e Read& Aor Se%e ting A%% data fro! ta(%e. i&e&, read a%% o%"!ns and a%% the ro,s fro! data(ase ta(%e S#nta@ S505C* U AR;2 Pta(%eQ& GDere #o" are not spe if#ing 3D5R5 onditionH Se%e ting A%% =ata fro! a Sing%e 0ine *o read a%% o%"!ns of a sing%e %ine fro! a data(ase ta(%e, "se the S505C* state!ent as fo%%o,s . S#nta@ S505C* SI<805 U AR;2 Pta(%eQ VV 3D5R5 P onditionQ VV *he res"%t of this state!ent is a sing%e %ine& *o !a)e s"re #o" retrie$e desired "ni1"e sing%e re ord, #o" !"st %in) a%% the fie%ds ,hi h for! the pri!ar# )e# of the data(ase ta(%e (# A<= in the 3D5R5 ondition& Prere1"isite for S505C* SI<805 1& 2& 3& Use a%% pri!ar# )e#s in 3D5R5 ondition& A%,a#s he ) for S6-SU/RC& C%ear ,or)-area for ta(%e&

Aggr g&' E=*r %%"on% /# "sing aggregate e@pressions, #o" an e@tra t hara teristi data fro! a o%"!n PaQ of the data(ase ta(%e& &2AI. ret"rns the !a@i!"! $a%"e of the o%"!n &2I<. ret"rns the !ini!"! $a%"e of the o%"!n &A-8. ret"rns the a$erage $a%"e of the o%"!n &SU2. ret"rns the s"! $a%"e of the o%"!n Updated on - Apr 20, 2004 Page 45 of 57
Created on - Apr 20, 2004

ABAP BASICS &C;U<*. o"nts $a%"es or %ines as fo%%o,s. -C;U<*G U H ret"rns the tota% n"!(er of %ines in the se%e tion& 6o" !"st in %"de spa es (et,een the parentheses and the arg"!ents& *he arith!eti operators A-8 and SU2 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 S505C* C%a"se and I<*; C%a"se& If there is a %ist in the S505C* %a"se, #o" !"st "se the I<*; %a"se ,ith the S505C* state!ent& 6o" an "se either a ,or) area P,aQ or an interna% ta(%e Pita(Q or %ist of $aria(%es as an arg"!ent, S#nta@ *A/05S. SA0I8D*& =A*A . CARRI=I 0I75 SA0I8D* -CARRI=, C;<<I= 0I75 SA0I8D* 4C;<<I=& S505C* CARRI= C;<<I= AR;2 SA0I8D* I<*; GCARRI=1, C;<<I=1H& 3RI*5. / CARRI=%,C;<<I=1& 5<=S505C*& 2an# ti!es #o" retrie$e re%ated data fro! t,o or !ore ta(%es& In s" h ases #o" "se nested se%e ts 6+ l"n/"ng '&6l % 0"') co,,on *r",&r+ / +% & /"t as far as possi(%e a$oid "sing nested se%e ts as ti!e re1"ired to a ess nested ta(%e is $er# high& S#nta@ *A/05S. SA0I8D*, S/;;7& S505C* U AR;2 SA0I8D* 3D5R5 CARRI= N X0DX& S505C* U AR;2 S/;;7 3D5R5 CARRI= N SA0I8D* -CARRI= A<= C;<<I= N SA0I8D* -C;<<II=& 3RI*5. / SA0SI8D*-CARRI=,SA0I8D*-C;<<I=,S/;;7-/;;7I=, 5<=S505C*& 5<=S505C*& So!e perfor!an e hints for ;pen SK0 state!ents 7eep the se%e ted dataset s!a%% 7eep the n"!(er of se%e ted data as s!a%% as possi(%e to a$oid "nne essar# net,or) transports& Use the respe ti$e ;pen SK0 state!ents a%,a#s ,ith the 3D5R5 %a"se& A$oid Updated on - Apr 20, 2004 Page 4> of 57
Created on - Apr 20, 2004

ABAP BASICS o!p%e@ 3D5R5 %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 %ogi a% <;* in 3D5R5 %a"ses ("t in$erted operators instead& *he %ogi a% <;* is s"pported (# the data(ase inde@es& 7eep the transferred data s!a%% *ransfer on%# those o%"!ns of a data(ase ta(%e that #o" rea%%# need& A$oid S505C*U if #o" do not ,ant to read a%% o%"!ns of a data(ase& Use a %ist in the S505C* %a"se instead& Use aggregate e@pressions in the S505C* %a"se to perfor! a% "%ations instead transporting great a!o"nts of data and a% "%ating thereafter& 7eep the n"!(er of data(ase a esses s!a%% Use operations on pa )ages of data instead of operations on sing%e data if #o" ,ant to ana%#Ee se%e ted data !ore than on e& *o do so, transfer the data in a sing%e operation (et,een ta(%es and interna% ta(%es& A$oid nested S505C* %oops& Instead, ,or) ,ith interna% ta(%es and S505C* state!ents "sing the A;R A00 5<*RI5S addition&

In% r' %'&' , n'


I<S5R* state!ent inserts a sing%e re ord into the data(ase ta(%e& S#nta@ *a(%es. sf%ight& Sf%ight- arrid N O0D:& Sf%ight- onnid N O234:& Insert sf%ight& *a(%e sf%ight is inserted ,ith the re ord& *he S6WSU/RC is ret"rned for this state!ent& If the entr# a%read# e@ists then the S6WSU/RC is set to non-Eero $a%"e and #o" an do pro essing for e@isting re ord (# gi$ing so!e error !essage&

U*(&' %'&' , n'

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 47 of 57

ABAP BASICS *o "pdate data(ase ta(%e UP=A*5 state!ent is "sed& *his a%%o,s #o" to hange either a sing%e re ord or se$era% re ords& 6o" an "se UP=A*5 ,hen #o" )no, ,hi h re ord #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 2;=IA6 state!ent& *he 2;=IA6 state!ent hanges e@isting %ines and inserts %ines ,hi h do not e@ist& Sf%ight- arrid N O2<:& Sf%ight- onnid N O454:& UP=A*5 SA0I8D* ,here CARRI= N O0D:& ;r *A/05S SA0I8D*& UP=A*5 SA0I8D* S5* PRIC5 N 1100 3D5R5 CARRI= N O0D:& Dere pri e of sf%ight ,i%% get "pdated ,ith ne, pri e 1100&

4 l ' %'&' , n'


*o de%ete re ords fro! a data(ase ta(%e, #o" "se the =505*5 state!ent& =505*5 AR;2 SA0I8D* 3D5R5 CARRI= N O0D: A<= C;<<I= N O454:& 3i%% de%ete the sing%e re ord ,here onditions are !et fro! SA0I8D*& 6o" an de%ete the !"%tip%e re ords fro! data(ase ta(%e (# p"tting a%% the re ords, ,hi h #o" ,ant to de%ete in interna% ta(%e& Aor e@a!p%e =505*5 SA0I8D* AR;2 *A/05 I*A/& In this ase ,hate$er #o" ha$e in interna% ta(%e ,i%% (e de%eted fro! SA0ID*& <ote. append interna% ta(%e ,ith a%% the entries, ,hi h #o" ,ant to de%ete&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 4J of 57

ABAP BASICS

EBERCISES SIMPLE WRITE STATEMENTS 1 3rite a progra!, ,hi h generates the !ode% %ist as sho,n Use these s#ste! fie%ds in #o"r progra!& S6-=A*U2, S6-UR5I*, S6-U<A25 2aintain the %ist headings

12/12/97 AIRS* PR;8RA2 WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW *his %ist is generated on. 12/12/1997 at. 13.40.35 (#. A/AP 1 WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW 2 Create a %ist as sho,n --------------------------------------------------------------------------------------------------I6R Co& P$t& 0td& =ate. *oda#:s date Page <o& 1 --------------------------------------------------------------------------------------------------Progra! na!e. R=52;

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 49 of 57

ABAP BASICS SYMBOLS> ICONS AN4 FORMATTING 1 3rite a progra! to sho, the fo%%o,ing "sing s#ste! $aria(%es Ghint. "se in %"de Ps#!(o%Q and in %"de Pi onQ S#!(o%s. I ons. *e%ephone Che )edF o)a#, Aa@ !a hine =e%ete, Dand pointing %eft, Print Dand pointing right, Ca"tion, 5g . 3rite s#!Wphone as s#!(o%, Ote%ephone:& 2 3rite a progra! to sho, a string ,ith different (a )gro"nd o%o"rs& eg& ,rite OD5A=5R: o%or o%Wheading& G o%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%%o,H 3 Use Aor!at intensified 4 for!at intensified off& Aor!at o%or P o%orWna!eQ - for!at o%or off& Aor!at in$erse 4 Aor!at in$erse off Sho, "rrent ti!e and toda#:s date& 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& S"ppress a sign (efore a n"!(er&

4 5 > 7

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 50 of 57

ABAP BASICS GENERAL PROBLEMS 1 Create an adding !a hine for n"!(ers& *he t,o $a%"es to (e added !"st (e entered on the se%e tion s reen as para!eters& ;"tp"t the res"%t& Create the di$iding !a hine for n"!(ers& *he t,o $a%"es !"st (e entered on the se%e tion s reen as para!eters& ;"tp"t the res"%t& Create #o"r o"tp"t as sho,n (e%o,& ! ! ! ! ! 4 5

! ! ! ! ! ! ! ! ! !

3rite a progra! to a ept the t,o n"!(ers fro! the "ser and s,ap the $a%"es& =e %are a string Oe ho: and design #o"r o"tp"t e e e e e e e

h h o h

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 51 of 57

ABAP BASICS

4OAEN44O> IFAELSEIFAELSEAEN4IF> CASEAEN4CASE 1 3rite a progra! ,ith =o 4 5nddo %oop& =isp%a# s1"ares of n"!(ers 1 to 10 1 2 3 2 1 4 9

3rite a progra! to a ept a n"!(er Gsa# 2H fro! "ser and reate a !"%tip%i ation ta(%e& 2@1N2 2@2N4 VVVV 2 @ 10 N 20

A ept a n"!(er fro! "ser and find Aa toria% of the sa!e& If the n"!(er is negati$e then disp%a# so!e !essage& 3rite a progra! ,ith =o 4 5nddo %oop for first 20 n"!(ers& - ;"tp"t sho"%d ontain on%# 5$en n"!(er - ;dd n"!(ers sho"%d not (e disp%a#ed A ept n"!(ers and hoi e O5-5<: or O;==: fro! the "ser and disp%a# the n"!(ers in that range a ording to "ser:s hoi e& 3rite a progra! ,ith =o 4 5nddo %oop for first 20 n"!(ers& - ;dd n"!(ers ' 5$en n"!(ers sho"%d (e disp%a#ed ,ith a%ternate intensities& GUse Aor!at intensified 4 on 4 offH Create a a% "%ator, ,hi h perfor!s the fo"r (asi t#pes of a% "%ations on t,o ,ho%e n"!(ers& *he t,o $a%"es and the option are to (e entered on the se%e tion s reen as para!eters& ;"tp"t the res"%t ,ith 2 de i!a% p%a es& 3rite separate progra!s "sing OC;<*I<U5: and O5II*: state!ents in =;-0;;P&

>

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 52 of 57

ABAP BASICS STRING OPERATIONS 1 2 3 4 5 > 7 J 9 10 11 A ept a string and deter!ine its %ength A ept a string ' n"!(er& 3rite the string that !an# n"!(er of ti!es& A ept t,o strings and s,ap their ontents& A ept t,o strings and on atenate into one string& A ept one string ,ith de%i!iter G , or F H and sp%it it into t,o strings& A ept a string Oa( def: and "se shift PstringQ, shift PstringQ right, shift PstringQ "p to Odef:& A ept a string eg& App%e& Change first o "rren e of Op: to O(:& G"se Orep%a e: o!!andH A ept a string eg& App%e& Change a%% o "rren es of Op: to O(:& G"se Otrans%ate: o!!andH A ept t,o strings and o!pare the t,o strings "sing O o:, O a:, O s: O p: Go"t p"t sha%% (e Otr"e: or Ofa%se: for ea h o!parison&H A ept a string OA/C=5A:& ;"tp"t on%# O=5A: "sing offset o!!and& A ept first na!e, %ast na!e and !idd%e na!e eg& <anda!"ri *ara)a Ra!arao disp%a# as <&*&Ra!arao A ept a string& Change a%% o "rren es of a to (& A ept a n"!(er and s,ap first and %ast digit of the sa!e& A ept a string and disp%a# the string in re$erse order A ept a string and he ) for pa%indro!e

12 13 14 15

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 53 of 57

ABAP BASICS 4ATE PROBLEMS 1 2 3 4 5 A ept a date ear%ier to toda#:s date and find the differen e in n"!(er of da#s& A ept a date fro! "ser and disp%a# first da# of the !onth and %ast da# of the pre$io"s !onth& A ept a date fro! "ser and add si@ !onths to the date& A ept a date fro! "ser and on$ert !onth part to O+an:, Ofe(: et &, and disp%a# this date& 3rite a progra! to a ept !onth& =isp%a# n"!(er of da#s in tota% !onth& 2a)e "se of - *e@t e%e!ent for #o"r se%e tion s reen (o@& - Se%e tion te@t A ept (irth date fro! "ser and o"tp"t age in #ears, !onths and da#s&

>

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 54 of 57

ABAP BASICS CHECK BOBES AN4 RA4IO BUTTONS 1 3rite 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& 3rite a progra! ,ith - Para!eters as t,o gro"ps of Radio("ttons Gt,o Radio("ttons in ea h gro"pH& - 8i$e detai%ed oding as a(o$e, to sho, the Radio("ttons and gro"ps - se%e ted 3rite 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& 3rite 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 se ond radio ("tton, disp%a# first da# of the ne@t !onth - If third radio ("tton, disp%a# date after si@ !onths&

4&

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 55 of 57

ABAP BASICS SELECT STATEMENTS 1 2 3 4 5 > 7 J 9 10 11 0ist a%% the ro,s fro! the ta(%e -/A7& 0ist sing%e ro, fro! the ta(%e /7PA& 0ist "p to 5 ro,s fro! the ta(%e /SIS& 0ist a%% 5R=A*s& Aor (etter reada(i%it# reate a o%"!n heading in the %ist =isp%a# tota% a!o"nt for arrid O0D:& G*a(%es. SA0I8D*H 0ist a%% the f%ights for ,hi h (oo)ing date is greater than :01&0>&1995:& 0ist a%% the f%ights for ,hi h pa#!ents "rren # is O=52:& 0ist a%% the f%ights ,here arrid is (et,een O0D: and OSK:& Se%e t a sing%e re ord ,here arrid N O0D:, f%ight-no N O0400: and f%date N :2J&02&199J:& =isp%a# arrid, onnid, f%date and %"ggage ,eight !"%tip%ied (# 2 0ist the !a@i!"! apa it#, o "pied seats and tota% of "rrent (oo)ings for ea h f%ight in the fo%%o,ing for!at& Carrier id 12 2a@& apa it# ; "pied seats *ota% of "rrent (oo)ings

Aro! the gi$en fro!- it# and to- it#, %ist a%% the a$ai%a(%e on this ro"te. Aro!. Pfro!- it#Q *o. Pto- it#Q Gsa# fro! Aran)f"rt to 2adrasH G*a(%es. SPA01H Carrier id =epart"re *i!e Start Airport =estination Airport

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 5> of 57

ABAP BASICS OPEN SEL 1 A ept do "!ent no& fro! "ser and disp%a# parti "%ars of Sa%es do "!ent& do "!ent no& O0010000031:H G*a(%e. -/APH Created on.@@@@@ Created (#. @@@@@ *i!e. @@@@@ 2 3 4 A ept Sa%es =o "!ent n"!(er fro! "ser and disp%a# orresponding !ateria% no, des ription of that !ateria% and ite! ategor# G*a(%e . -/APH A ept !ateria% no& ' ite! ategor# (# defa"%t PP100 and 72< respe ti$e%# =isp%a# orresponding detai%s of sa%es do "!ent G*a(%e. -/APH =isp%a# fie%ds fro! /7PA& =o "!ent t#pe N OA/: and =o "!ent date N :05&02&199J:& A%so disp%a# n"!(er of re ords se%e ted& =isp%a# Co& ode, do &no&, a &t#pe, ta@ ode& 2a)e "se of se%e t-options to gi$e range of do "!ent t#pe& =isp%a# tit%e of #o"r progra! at the end of progra! A ept do & no fro! "ser& =isp%a# do &no&, do &stat"s, date of do &, do &t#pe& =isp%a# sing%e re ord for do "!ent ,here date N :05&02&199J:, t#pe ON OA/ and do "!ent no& N O010000000>:& A ept p%ant fro! "ser eg& P0*P& =isp%a# do "!ent detai%s for that p%ant %i)e do &no&, do &stat"s, date of do "!ent et &, G=efa"%t

> 7 J

Updated on - Apr 20, 2004 Created on - Apr 20, 2004

Page 57 of 57

You might also like