8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 1/87
ABAP in 4 Hours
Krishna Rungta
Published by SapTrainingHub.com
Copyright 2012 Krishna Rungta
Smashwords Edition
Smashwords Edition, License Notes
This ebook is icense! "or your persona en#oyment ony. This ebook may not be re$so! or
gi%en a&ay to other peope. '" you &ou! ike to share this book &ith another person( pease purchase an a!!itiona copy "or each recipient. '" you)re rea!ing this book an! !i! not purchase
it( or it &as not purchase! "or your use ony( then pease return to Smash&or!s.com an! purchaseyour o&n copy. Thank you "or respecting the har! &ork o" this author..
Chapter 1 – Introduction to AAPABAP stan!s "or * A!%ance! Business Appication Programming. 't is a programming
anguage "or !e%eoping appications "or the SAP R+, system.The atest %ersion o" ABAP is cae! ABAP -b#ects an! supports ob#ect$oriente!
programming. SAP &i run appications &ritten using ABAP+4( the earier ABAP %ersion( as&e as appications using ABAP -b#ects.ithout "urther a!o( et)s !i%e into ABAP./ote( this hapter &i not go into etensi%e
!etais on ABAP anguage constructs &hich become %ery boring to rea!3 but uicky intro!uce
key concepts to get you starte! so you can "ocus your attention on more important topics.
!ata "ypes
Synta to !ecare a %ariabe in ABAP $
DATA Variable_Name Type Variable_Type .
5ampe6
DATA employee_number Type I .
The "oo&ing is a ist o" 7ata Types supporte! by ABAP
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 2/87
# Assigning $alues
a=16.
move 16 to a.
write a to b.
# Arithmetic %perations
compute a = a*100.
Control Statements
8oo&ing contro statements can be use! $'" 9 5n!'" :oop
if not! e"p an# $ or not! e"p !.
%%..
el&eif e"p.
.......!
el&e.
.......!
'n#if.
Case statement
(a&e variable.
w)en value1.
%%%
w)en value.
%%%
w)en ot)er&.
.........!
'n#ca&e.
!o&#'hile loop
+)ile ,lo-ical e"pre&&ion.
%..
%..
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 3/87
'n#w)ile.
Do loop
Do ,n time&.
%..
%..
'n##o.
Logical %perator
A li&t of lo-ical operator&
/' or =
/T or
' or ,=
T or ,
' or =
N' or ,
AAP() Editor
8inay( here is &here you &i spent most o" your time as a !e%eoper creating + mo!i"ying programs. Transaction SE*+
;;;;Chapter – !ata !ictionary
A !ata !ictionary is a centra source o" in"ormation "or the !ata in a in"ormation
management system. 'ts main "unction is to support the creation an! management o" !ata
!e"initions or <meta!ata=3.
What is Data dictionary used for?
• >anagement o" !ata !e"initions
• Pro%ision o" in"ormation "or e%auations
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 4/87
• Support "or so"t&are !e%eopment
• Support "or !ocumentation
• 5nsuring that !ata !e"initions are "eibe an! up$to$!ate
-b#ects in the ABAP 7ictionary resi!e! on three e%es that support their re$usabiity. These
e%es are6Tabes an! structures7ata eements
7omains
:et)s ook into them in !etai $
!omains
7escribes the technica characteristics o" a tabe "ie!
Speci"ies a %aue range &hich !escribes ao&e! !ata %aues "or the "ie!s
8ie!s re"erring to the same !omain %ia the !ata eements assigne! to them3 are change! &hen achange is ma!e to the !omain
5nsures consistency
'" . Purchasing !ocument number 5B5:/3
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 5/87
!ata Elements
7escribes the roe paye! by a "ie! in a technica contet
8ie!s o" same semantic meaning can re"er to the same !ata eement
ontains the "ie! in"ormationE-. Purchasing !ocument number 5B5:/3
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 6/87
"ablesRepresent the 7atabase Tabes &here !ata actuay resi!es.Tabes can be !e"ine! in!epen!enty o" the !atabase in the ABAP 7ictionary.
The "ie!s o" the tabe are !e"ine! &ith their !atabase$in!epen!ent3 SAP ABAP !ata types an!
engths.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 7/87
Structures
Are recor! !ecarations that !o /-T correspon! to a 7atabase Tabe.
?ust ike user$!e"ine! !ata type.
7e"ine! ike a tabe an! can then be a!!resse! "rom ABAP programs.Structures contain !ata ony !uring the runtime o" a program.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 8/87
Aggregated %b.ects o/ AAP !ictionaryAggregate! means consisting o" se%era components. 'n the ABAP 7ictionary( aggregate!
ob#ects are ob#ects &hich come "rom se%era !i""erent transparent tabes.@ie&s
Search Hep
:ock -b#ects:et)s ook into them in !etai
$iews
@ie&s in SAP ABAP are use! to summarie !ata &hich is !istribute! among se%era tabes
The !ata o" a %ie& is not actuay physicay store!. The !ata o" a %ie& is instea! !eri%e! "rom
one or more other tabes't is taiore! to the nee!s o" a speci"ic appication
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 9/87
Search 0elp
A Search hep is a too to hep you search "or !ata recor!s in the system
An e""icient an! user$"rien!y search assists users &here the key o" a recor! is unkno&n
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 10/87
Loc %b.ects
Simutaneous accessing o" the same !ata recor! by t&o users in the SAP system is synchronie! by a ock mechanism.
:ocks are set an! reease! by caing certain "unction mo!ues. These "unction mo!ues aregenerate! automaticay "rom the !e"inition o" so$cae! ock ob#ects in the ABAP+4 7ictionary
6
'n2ueue_,ob3 name 4 to loc5 t)e table
#e2ueue_,ob3 name 4 to relea&e t)e loc5
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 11/87
'mportant Transactions
'11 7 Data Dictionary Initial creen 8'1 Di&play only9
'1: 7 A;A< Dictionary 7 Tec)nical ettin-&
'1 7 Databa&e >tility
'1? 7 @epo&itory Information y&tem
'16 7 Data ;row&er
'1 7 /eneral table Di&play
'?? 7 Table View Baintenance
B:0 7 Table Baintenance
;;;;Chapter * – 2odularity in AAP3 2acro, Include, Subroutines, 4unction
2odules 5 6roups
hen you mo!uarie source co!e( you pace a seuence o" ABAP statements in a mo!ue.
Then( instea! o" pacing a o" the statements in your main program( you #ust ca the mo!ue.
hen the program is generate!( the source co!e in the mo!uariation unit is treate! as though it&ere actuay physicay present in the main program.
/ee! o" >o!uariation
• 'mpro%e the structure o" the program.
• 5asy to rea! the co!e
• 5asy to maintain the co!e
• A%oi! re!un!ancy an! promotes co!e reuse
@arious >o!uariation Techniues
• Cse o" >acros
• Cse o" incu!e "ies
• Subroutines
• 8unction >o!ues
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 12/87
:et)s ook into each o" them in !etai6
SAP# AAP 2acro
'" you &ant to reuse the same set o" statements more than once in a program( you can incu!ethem in a macro.
Dou can ony use a macro &ithin the program in &hich it is !e"ine!( an! it can ony be cae! in
ines o" the program "oo&ing its !e"inition.>acros can be use"u "or ong cacuations or compe R'T5 statements.
Synta
D'CIN' ,macro_name
Bacro tatement&
'NDEFCED'CINITIFN
Bacro& can u&e <arameter& &N w)ere N = 1GG:%
'"ample7E
DATA7 number1 TH<' I VA>' 1.
DEFINE increment.
ADD 1 to 1.
+@IT' 1. 'NDEFCED'CINITIFN.
Increment number1.
+@IT' number1.
Futput7
Include Programs
'ncu!e Programs are soey "or mo!uariing source co!e( an! ha%e no parameter inter"ace.
'ncu!e programs ao& you to use the same source co!e in !i""erent programs. They can be
use"u i" you ha%e engthy !ata !ecarations that you &ant to use in !i""erent programs.
Synta-
Inclu#e ,inclu#e pro-ram Name
Points to Note
• 'ncu!e programs cannot ca themse%es.
• 'ncu!e programs must contain compete statements.
E-ample6
IN(>D' JIK000.
+@IT'7 $ >&erLG HE>NAB'G$ DateLG HEDAT>B.
================================
<@F/@AB J@<B0001.
IN(>D' JIK000.
Subroutines
Subroutines are proce!ures that you can !e"ine in any ABAP program an! aso ca "rom any
program. Subroutines are normay cae! internay( that is( they contain sections o" co!e oragorithms that are use! "reuenty ocay. '" you &ant a "unction to be reusabe throughout the
system( use a "unction mo!ue.
ynta"E
CF@B ,ubroutine ,pa&&!.
,tatement bloc5.
'NDCF@B.
,ubroutine = Name of t)e &ubroutine
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 13/87
,pa&& = <arameter& bein- pa&&e#
Types o" Subroutines
Internal
Subroutine !e"ine! in same program being cae!.
an access a the !ata ob#ects !ecare! in the main ABAP+4 program.
E-ternalSubroutine !e"ine! outsi!e the program being cae!.
/ee! to use the EpassF option or !ecare !ata ob#ects in common parts o" memory.
aing a Subroutine
Internal Subroutines
<'@CF@B ,&ubroutine ,pa&&!
,&ubroutine = Name of t)e &ubroutine
,pa&& = <arameter& bein- pa&&e#
Data #eclare# in main pro-ram i& automatically available.
5terna Subroutines
<'@CF@B ,&ubroutine8,<ro-ram9 ,pa&&!.
<'@CF@B ,&ubroutine 8,<ro-ram9 ,pa&&! IC CF>ND!. <'@CF@B 8,&ubroutine9 IN <@F/@AB 8,<ro-ram9 ,pa&&! IC CF>ND!.
<'@CF@B ,in#e" FC ,&ubroutine1 ,&ubroutine ,&ubroutine: ,pa&&!.
Points to /ote
• /este! cas are ao&e! in subroutines i.e. P5R8-R> &ithin a 8-R> 9
5/78-R> 3.
• Recursi%e cas are aso possibe.
• To !e"ine oca !ata( use the 7ATA statement a"ter 8-R> . 5ach time you enter the
subroutine( the !ata is recreate! &ith an initia %aue3 an! reease! at the en! "romthe stack3.
• To !e"ine goba !ata use! &ithin a subroutine( use the :-A: statement a"ter
8-R> . The %aues are sa%e! &hen you enter the subroutine an! then reease! at theen! "rom the stack3
4unction 2odules
8unction >o!ues are genera purpose ABAP+4 routines that anyone can use. 'n"act ( there
are a arge number o" stan!ar! "unction >o!ues a%aiabe.8unction >o!ues are organie! into 8unction Groups6 oections o" ogicay reate!
"unctions. A 8unction mo!ue a&ays beongs to a 8unction Group.
ynta"E
C>N(TIFN ,function mo#ule
,tatement&
'NDC>N(TIFN.
'mportant in"ormation Associate! &ith 8unction >o!ue• A!ministration
• 'mport+hanging+5port parameters.
• Tabe Parameters+5ceptions.
• 7ocumentation
• Source co!e * L<fgrp>U! . E"grpF is the 8unction Group
• Goba 7ata * L<fgrp>"#$ .Goba !ata "or the "unction group$ Accessibe across "unction mo!ues in the "unction
group.
• >ain Program * %$L<fgrp> . ontains the ist o" a the incu!e "ies "or that "unction group
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 14/87
a a 8unction >o!ue
To ca a "unction mo!ue( use the A:: 8C/T'-/ statement6
(A C>N(TIFN ,mo#ule
'K<F@TIN/ f1 = a 1.... f n = a n!
IB<F@TIN/ f1 = a 1.... f n = a n!
(MAN/IN/ f1 = a 1.... f n = a n! TA;' f1 = a 1.... f n = a n!
'K('<TIFN e1 = r 1.... e n = r n '@@F@_B'A/' = r '!
FTM'@ = ro!!.
4unction 6roups
8unction groups are containers "or "unction mo!ues. 'n"act( there are a arge number o"
stan!ar! 8unction Groups.
A o" the "unction mo!ues in a "unction group can access the goba !ata o" the group.:ike eecutabe programs type 13 an! mo!ue poos type >3( "unction groups can contain
screens( seection screens( an! ists.
Points to /ote
•
8unction Groups cannot be eecute!.• The name o" a "unction group can be up to 2 characters ong.
• hen you create a "unction group or "unction mo!ue( the main program an! incu!e programs are generate! automaticay.
• 8unction groups encapsuate !ata.
Ho& to create a 8unction Group1. Goto Transaction S5I0.
2. Seect Program in the 7rop7o&n.
,. rite the name o" the 8unction Group That you &ant to create. Generay Cser ma!e8unction groups start &ith <J=. e.g. * EJ8C/T'-/GR-CP/A>5F . Hit
5nter Key.
4. /ote that The T-P 'ncu!e is create by !e"aut i" the user checks the option o"creating a T-P incu!e.
Ho& to create a 8unction >o!ue
1. reate a "unction Group say < '(L<3.
2. reate a "unction mo!ue( set the attributes ike 8unction group( Appication( ShortTet an! Process Type3 an! Sa%e.
,. 'ncu!e "ie < L'(LU!= &i ha%e source co!e o" "irst "unction mo!ue.
4. 'ncu!e "ie < L'(L"#$ = &i ha%e goba !ata.. >ain program <%$L'(L= contains
. Goba !ata 'ncu!e "ie < L'(L"#$ <
L. 8unction mo!ues incu!e "ie < L'(LU)) <
I. Cser !e"ine! 'ncu!e "ies < L'(LF ..=( < L'(L#..= an! < L'(LI ..=M. 7e"ine inter"ace parameters an! 5ceptions
10. rite the source co!e
11. Acti%ate 8unction >o!ue12. Testing the 8unction >o!ue * Singe Test N 7ebugging
1,. 7ocumenting an! Reeasing a 8unction >o!ue
That)s a to >o!uarity in ABAP.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 15/87
;;;;
Chapter ) # Nati7e and %pen S8L
The goa o" this hapter is not to teach you SO: or !atabase concepts but to intro!uce you
to the SO: !i%ersity in ABAP.'n ABAP+4 programming anguage( there are t&o types o" SO:
being use!.• /AT'@5 SO:
• -P5/ SO:.
-pen SO: ao&s you to access the !atabase tabes !ecare! in the ABAP !ictionaryregar!ess o" the !atabase pat"orm that the R+, system is using.
/ati%e SO: ao&s you to use !atabase$speci"ic SO: statements in an ABAP+4 program.
This means that you can use !atabase tabes that are not a!ministere! by ABAP !ictionary( an!there"ore integrate !ata that is not part o" the R+, system.
-pen SO: consists o" a set o" ABAP statements that per"orm operations on the centra
!atabase in the R+, system. The resuts o" the operations an! any error messages are in!epen!ento" the !atabase system in use. -pen SO: thus pro%i!es a uni"orm synta an! semantics "or a o"
the !atabase systems supporte! by SAP. ABAP programs that ony use -pen SO: statements&i &ork in any R+, system( regar!ess o" the !atabase system in use. -pen SO: statements can
ony &ork &ith !atabase tabes that ha%e been been create! in the ABAP !ictionary.
asic %pen S8L Commands
• S5:5T
• '/S5RT
• CP7AT5
• >-7'8D
• 75:5T5
• -P5/ CRS-R(85TH( :-S5 CRS-R
'"ample
TA;' ;FF.
DATA ( TH<' (>@F@G
+A I' ;FF.
F<'N (>@F@ ( CF@ ''(T * C@FB ;FF +M'@' (A@@ID = M
AND (FNNID = L000O
AND CDAT' = L1PP?0QO
F@D'@ ;H <@IBA@H 'H.
DF.
C'T(M N'KT (>@F@ ( INTF +A.
IC HE>;@( , 0.
(F' (>@F@ (. 'KIT.
'NDIC.
+@IT'7 $ +AE;FFIDG +AE(>TFBIDG +AE(>TTH<'G
+AEBF'@G +AE>//+'I/MTG +AE+>NITG
+AEINVFI('.
'NDDF.
-utput the passenger ist "or the :u"thansa "ight 0400 on 2I$02.1MM6
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 16/87
-pen SO: Return o!esA -pen SO: statements "i the "oo&ing t&o system "ie!s &ith return co!es.S9#S:;C
A"ter e%ery -pen SO: statement( the system "ie! SD$SCBR contains the %aue 0 i" theoperation &as success"u( a %aue other than 0 i" not.S9#!CN"
A"ter an -pen SO: statement( the system "ie! SD$7B/T contains the number o" !atabase
ines processe!.Nati7e S8L
As area!y mentione!( /ati%e SO: ao&s you to use !atabase$speci"ic SO: statements in
an ABAP program.To use /ati%e SO: statement( you must prece!e it &ith the 55 SO: statement( an!
"oo& it &ith the 5/755 statement.
ynta"
'K'( <'@CF@BIN/ ,form!.
,Native &tatement
'ND'K'(.
There is no perio! a"ter /ati%e SO: statements. 8urthermore( using in%erte! commas <3 or
an asterisk ;3 at the beginning o" a ine in a nati%e SO: statement !oes not intro!uce a commentas it &ou! in norma ABAP synta. Dou nee! to kno& &hether tabe an! "ie! names are case$
sensiti%e in your chosen !atabase.'n /ati%e SO: statements( the !ata is transporte! bet&een the !atabase tabe an! the ABAP
program using host %ariabes. These are !ecare! in the ABAP program( an! prece!e! in the
/ati%e SO: statement by a coon 63. Dou can use eementary structures as host %ariabes.5ceptionay( structures in an '/T- cause are treate! as though a o" their "ie!s &ere iste!
in!i%i!uay.
As in -pen SO:( a"ter the 5/755 statement( SD$7B/T contains the number o" ines
processe!. 'n neary a cases( SD$SCBR contains the %aue 0 a"ter the 5/755 statement.
%pen S8L – Per/ormance ;ules
To impro%e the per"ormance o" the SO: an! in turn o" the ABAP program( one shou! takecare o" the "oo&ing rues$ *eep the +esu,t %et %ma,,
Csing the &here cause
'" ony one recor! is reuire! "rom the !atabase( use S5:5T S'/G:5 &hene%er possibe. -inimie the mount of Data "ransferred
Restrict the number o" ines
'" ony certain "ie!s are reuire! "rom a tabe( use the S5:5T E"ie!1F E"ie!2F '/T- 9statement
Restrict no o" coumns
Cse aggregate "unctions
-inimie the Num/er of Data "ransfersA%oi! neste! seect oops
An aternati%e option is to use the S5:5T. 8-R A:: 5/TR'5S statement. This statement
can o"ten be a ot more e""icient than per"orming a arge number o" S5:5T or S5:5TS'/G:5 statements !uring a :--P o" an interna tabe.
Cse !ictionary %ie&s
Cse ?oins in the 8R-> causeCse sub ueries in the &here cause
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 17/87
-inimie the %earch #0erhead
Cse in!e "ie!s in the &here cause
hen accessing !atabases( a&ays ensure that the correct in!e is being use! . +educe the Data/ase Load
Bu""ering
:ogica !atabasesA%oi! repeate! !atabase access
Using Interna, "a/,es to 1uffer +ecords
To a%oi! eecuting the same S5:5T mutipe times an! there"ore ha%e !upicate seects3(an interna tabe o" type HASH57 can be use! to impro%e per"ormance.
<<<<
Chapter = # SAP Internal "ables'n this hapter &e &i co%er the "oo&ing topics
• 'nterna Tabes. 7i""erence bet&een 'nterna Tabes an! ork Areas
• Types o" 'nterna Tabes• reating 'nterna Tabes
• Popuating 'nterna Tabes
• Rea!ing 'nterna Tabes
• 7eeting "rom 'nterna tabe.
:et)s BeginQ
'hat is an Internal "able>
'nterna tabes are use! to obtain !ata "rom a "ie! structure "or !ynamic use in ABAP.
5ach ine in the interna tabe has the same "ie! structure. The main use "or interna tabes is "orstoring an! "ormatting !ata "rom a !atabase tabe &ithin a program.
'hat is a 'or Area>
ork areas are singe ro&s o" !ata. They shou! ha%e the same "ormat as any o" the internatabes. 't is use! to process the !ata in an interna tabe one ine at a time.
!i//erence etween Internal "able and a 'or Area>
A picture says a thousan! &or!s
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 18/87
"ypes o/ Internal "ables
There are t&o types o" interna tabes.
'nterna tabes &ith H5A75R ine'nterna tabes &ithout H5A75R ine.
'nterna Tabes &ith Hea!er :ine
Here the system automaticay creates the &ork area.The &ork area has the same !ata type as interna tabe.
This &ork area is cae! the H5A75R ine.
't is here that a the changes or any o" the action on the contents o" the tabe are !one. As aresut o" this( recor!s can be !irecty inserte! into the tabe or accesse! "rom the interna tabe
!irecty.
'nterna Tabes &ithout Hea!er :ine 3
Here there is no &ork area associate! &ith the tabe.ork area is to be epicity speci"ie! &hen &e nee! to access such tabes.
Hence these tabes cannot be accesse! !irecty.
Creating Internal "ables
There are many &ays to create an 'nterna Tabe. :et)s ook at them one by one$1. By Csing the Type Statement
:et us no& create a 'nterna tabe ita/ using the TDP5 statement.
T)e &ynta" i& E
Type& 7 be-in of lineG
column1 type IG
column type IG
en# of line.
'"ample7
TH<' 7 be-in of lineG
empno type IG
empname809 type c G
en# of line.
The TDP5S statement creates a structure ,ine as !e"ine!.To actuay create an 'nterna
Tabe ita/ use the "oo&ing comman!$
Data itab type line occur& 10.
An interna tabe ita/ is create! &ith the structure o" ine.Besi!es !ecaring the structure o" an
interna tabe( the -CRS cause aso !e"ines ho& many tabe entries are maintaine! in main
storagein this case 103. 5tra recor!s are &ritten out to paging area an! can a""ect per"ormance
2. By re"erring to another TabeDou can create an interna tabe by re"erring to an eisting tabe. The eisting tabe cou! be
a stan!ar! SAP tabe( a J tabe or another interna tabe.
ynta"E
Data ,f ,type wit) )ea#er line!.
5ampe$
DATA itab TH<' line F((>@ 10 wit) )ea#er line.
Here an interna tabe ita/ is create! o" the type ine &ith a hea!er ine. Pease note <&ith
hea!er ine= is optiona
,. By re"erring to eisting Structure
ynta"E
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 19/87
Data ,f I' ,&truct occur& n wit) )ea#er line!.
'"ampleE
DATA itab I' &line F((>@ 10.
Here a tabe ita/ is create! ha%ing a structure same as that o" sine
4. By creating a ne& Structure
:et us no& create an interna tabe &ith a structure o" our o&n. Here the tabe is create! &ithan Hea!er ine( by !e"aut.Synta $
Data 7 ;e-in of ,f occur& ,nG
,component #eclarationG
%%%%%%%%%%%G
'n# of ,f.
'"ample E
Data 7 ;e-in of itab occur& 10G
column1 type IG
column89 type (G
column: li5e maraEernamG
'n# of itab.'nterna tabe ita/ is create!
Populating Internal "ables
/o& that &e ha%e success"uy create! some interna tabes( et us see ho& !o &e popuate
them &ith some recor!s. There are %arious metho!s a%aiabe to popuate tabes
1. Appen! 7ata ine by ineThe "irst metho! a%aiabe is the use o" the APP5/7 statement.Csing the APP5/7
statement &e can either a!! one ine "rom another &ork area to the interna tabe or &e can a!!
one initia ine to the interna tabe. Synta $
A<<'ND ,wa TF $ INITIA IN' TF! ,itable.
Here &ork area <2a> or the 'nitia :ine is appen!e! to the interna tabe <ita/,e>.The system
%ariabe %34"1I) contains the in!e o" the appen!e! ine.
'"ample7
Data7 ;e-in of itab occur& 10G
col1 type (G
col type IG
en# of itab.
Appen# initial line to itab.
@e&ult& 7 L0O
An initia ine a!!s a ine initiaie! &ith the correct %aue "or its type to the tabe. Here (co1 is an integer an! co2 is a character. Then APP5/7 initia ine ( a!!s a ine initiaie! &ith
respect to the !ata type o" the coumns( i.e. 0 "or o1 an! space "or o2.
2. Csing -::5T statement-::5T is another "orm o" statement use! "or popuating the interna tabes. Generay
-::5T is use! &hie inserting ines into an interna tabe &ith uniue stan!ar! key.Synta$
(F'(T ,wa INTF! ,itable.
'n case o" tabes &ith Hea!er ine( '/T- option is omitte!. Suppose there is area!y an entry
ha%ing a key same as the one you are trying to appen!( then a ne& ine is not a!!e! to the tabe(
but the numeric "ie!s o" both the entries are a!!e! an! ony one entry correspon!ing to the key
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 20/87
is present. @aue o" SD$TAB' is change! to the ro& o" the origina entry. 5se -::5T acts
simiar to APP5/7 an! SD$TAB' contains the in!e o" the processe! ine.
,& Csing '/S5RT statement'/S5RT statement a!!s a ine+&ork area to the interna tabe. Dou can speci"y the position
at &hich the ne& ine is to be a!!e! by using the INDE) cause &ith the '/S5RT statement.Synta
IN'@T ,wa INTF $ INITIA IN' INTF! ,itable in#e" ,i#"!.Here( the &ork area <2a> or '/'T'A: :'/5 is inserte! into interna tabe Eita/,e> at
in!e <id5>.
Copying Internal "ables
The contents o" one interna tabe can be copie! to another by using the APP5/7 :'/5S or
'/S5RT :'/5S statement. A more simper &ay is to use any o" the "oo&ing synta)s.
BFV' ,itab1 To ,itab.
F@
,itab1 = ,itab.
These copy the contents o" 'TAB1 to 'TAB2. 'n case o" interna tabes &ith hea!er ine &e
ha%e to use in or!er to !istinguish "rom &ork area. So( to copy contents o" interna tabes &ith
hea!er ine the synta becomes( itab1 itab2.;eading Internal "ables
e are no& "amiiar &ith the creation o" interna tabes an! popuating them &ith !ata. e&i no& see ho& !o &e actuay use the !ata or retrie%e the !ata "rom the interna tabes.
1& Csing :oop $5n!oop
-ne o" the &ays o" accessing or rea!ing the interna tabe is by using :--P$5/7:--P.Synta$
FF< AT ,itable INTF ,wa!
%%%%%%%%%%%..
'NDFF<.
Here &hen you say :--P AT 'TAB:5( then the interna tabe 'TAB:5 is rea! ine by ine.
Dou can access the %aues o" the coumns "or that ine !uring any part o" the :--P$5/7:--P
structure. The %aue o" the %34%U1+( is set to ?( e%en i" ony one recor! is rea!.2& Csing R5A7
The other metho! o" rea!ing the interna tabe is by using the R5A7 statement. Synta$
@'AD TA;' ,itable INTF ,wa! IND'K ,i#".
This statement rea!s the current ine or ine as speci"ie! by in!e Ei!F. The %aue o" SD$
TAB'is the in!e o" the ine rea!. '" an entry &ith the speci"ie! in!e is "oun!( then SD$
SCBR is set to 0. '" the speci"ie! in!e is ess than 0( then run$time error occurs. '" the
speci"ie! in!e ecee!s tabe sie then SD$SCBR is set to 4.
!eleting Internal "ables
There are many &ays "or !eeting ines "rom an interna tabe.
1. 7eeting ines in a oop.This is the simpest &ay "or !eeting ines. Synta
D''T' ,ITA;'.
This statement &orks ony &ithin a oop. 't !eetes the current ine. Dou can !eete the ines in aoop con!itionay by a!!ing the H5R5 cause.
2. 7eeting ines using the in!e.
This is use! to !eete a ine "rom interna tabe at any kno& in!e.Synta
D''T' ,ITA;' IND'K ,IDK.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 21/87
The ine &ith the in!e E'7F is !eete!. The in!e o" the "oo&ing ine is !ecremente! by 1.
;;;;
Chapter @ # AAP "able ControlsTabe contros an! step oops are ob#ects "or screen tabe !ispay that you a!! to a screen in
the Screen Painter.8rom a programming stan!point( tabe contros an! step oops are amosteacty the same. Tabe contros are simpy impro%e! step oops that !ispay !ata &ith the ook
an! "ee associate! &ith tabes in !esktop appications.ith tabe contros( the user can6
• Scro through the tabe %erticay an! horiontay
• Re$sie the &i!th o" a coumn
• Scro &ithin a "ie! &hen "ie! contents are &i!er than the "ie!3
• Seect tabe ro&s or coumns
• Re$or!er the seuence o" coumns
• Sa%e the current !ispay settings "or "uture use
Tabe contros aso o""er specia "ormatting "eatures some automatic( some optiona3 thatmake tabes easier to ook at an! use. Tabe ontro pro%i!es $
• automatic tabe resiing %ertica an! horionta3 &hen the user resies the &in!o&
• separator ines bet&een ro&s an! bet&een coumns %ertica an! horionta3
• coumn hea!er "ie!s "or a coumns
-ne "eature o" step oops is that their tabe ro&s can span more than one ine on the screen.
A ro& o" a tabe contro( on the other han!( must a&ays be containe! in a singe ine athoughscroing is possibe3.
'n genera( many o" the "eatures pro%i!e! by the tabe contro are han!e! ocay by your
system)s SAP gui "ronten!( so you !o not nee! to program them yourse". The ony notabeeception to this is %ertica scroing. 5ampe Transaction TJ03
To han!e tabe contros in ABAP programs( you must !ecare a contro in the !ecaration
part o" the program "or each tabe contro using the "oo&ing statement6(FNT@F ,ctrl TH<' TA;'VI'+ >IN/ (@''N ,&cr
&here <ctr,> is the name o" the tabe contro on a screen in the ABAP program. The contro
ao&s the ABAP program to rea! the attributes o" the tabe contro an! to in"uence the
contro .Here( <scr> is the screen number &here the initia %aues o" the tabe are oa!e!.ursorPosition "or a tabe contro can be set in "oo&ing &ays6At PB- you can set the cursor on a
speci"ic "ie! o" a speci"ic ro& o" a tabe contro.
'T (>@F@ CI'D ,f IN' ,lin FCC'T ,off!
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 22/87
Csing the optiona a!!ition #FF%E" ( you can enter the o""set o" the cursor in the "ie! as
!escribe! un!er setting the ursor Position.At PA' you can rea! the current cursor position.
/'T (>@F@ CI'D ,f IN' ,lin %
'n a!!ition to the in"ormation gi%en un!er 8in!ing -ut the ursor Position(
"ie! <,in> contains in"ormation on &hich ro& o" the tabe contro the cursor is currenty on.
Dou can aso use/'T (>@F@ IN' ,lin.
To !etermine the ro& o" the tabe contro. %34%U1+( ao&s you to check i" the cursor is
pace! in a ro& o" a tabe contro.8or getting the correspon!ing ine o" the interna tabe6
/'T (>@F@ line ,lin.
in# = ,table_controlEtop_line R ,lin 4 1.
@ea# table ,itab in#e" in#.
The system %ariabe step, $ contains the current tabe ine in!e in a oop 9en!oop. Loopc * contains number o" ines %isibe in the tabe
"o create a table control
1. A!! a tabe contro eement to your screen
2. Gi%e a name to the tabe contro. 'n the ABAP program !ecare a structure &ith thesame -/TR-:S EtcF type TAB:5@'5 CS'/G SR55/ Escrn F3
,. To create "ie!s go to the 7ict.+Program "ie!s "unction.5nter the name o" the structure &hose "ie!s you &ant. '" you &ant it to pick it "rom
!ictionary o" your program cick the ree%ant puhbutton3.'n the "ie! ist choose the "ie!s you
&ant an! choose ok.ick in the tabe contro area.'" you &ant a seection coumn( check theappropriate check bo in the attributes an! gi%e it a name. reate the "ie! in the ABAP program.
'n the PB- you shou! ha%e the statement
FF< at ,itab >IN/ (FNT@F ,cntrl_name.
'NDFF<.
In t)e <AI you &)oul# )ave.
FF< at ,itab.
'NDFF<.
't is &ithin the oops that !ata trans"er happens bet&een the screen an! the interna
tabe.hen you popuate the interna tabe use 75SR'B5 TAB:5 EitabF :'/5S
EcntrnameF$ines( to store the tota number o" ines in the contro. The 8'5:7 statement can beuse! to contro &hen the !ata trans"er happens.To change the attributes o" in!i%i!ua ces
temporariy change the SR55/ tabe in the PB-. Dou can change the attributes o" the structure
create! by the -/TR-:S statement
,cntrlEfi"e#_col& etc are t)e attribute& of t)e control
,cntrlEcol&Ein#e" etc are t)e attribute& of t)e column&.
,cntrlEcol&E&creenEinvi&ible etc are t)e &creen attribute& of eac) column.
;;;;
Chapter # AAP ;eport ProgrammingSAP$ABAP supports t&o types o" Programs $ Report Programs N 7iaog Programs. Report
Programs are use! &hen arge amounts o" !ata nee!s to be !ispaye!
Purpose+Cse o" Report Programs
• They are use! &hen !ata "rom a number o" tabes ha%e to be seecte! an! processe! be"ore presenting
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 23/87
• Cse! &hen reports !eman! a specia "ormat
• Cse! &hen the report has to be !o&noa!e! "rom SAP to an 5ce sheet to be
!istribute! across.
• Cse! &hen the report has to be maie! to a particuar person.
'mportant Points to /ote about Report Program
• Report Programs are a&ays 5ecutabe Programs. Program Type is a&ays 1.• 5%ery Report program correspon!s to a particuar Appication Type i.e. either &ith
Saes N 7istribution( 8' * - etc. 't can aso be ross Appication i.e. type U;).
• Report Programming is an 5%ent$!ri%en programming.
• The "irst ine o" a report program is a&ays Report ,reportEname.
• 'n or!er to suppress the ist hea!ing or the name o" the program the a!!ition No
tan#ar# <a-e Mea#in- is use!.
• The ine sie "or a particuar report can be set by using the a!!ition lineE&iSe ,&iSe.
• The ine count "or a particuar page can be set by using the a!!ition lineEcount
n8n19. / is the number o" ines "or the page an! /1 is the number o" ines reser%e!"or the page "ooter.
• To !ispay any in"ormation or error message &e a!! a message cass to the program
using the a!!ition6 Be&&a-eEi# ,me&&a-e cla&& name. >essage casses aremaintaine! in S5M1.
There"ore an i!ea report program shou! start &ith6
+eport <report name> no standard page heading ,ine4sie <sie>
,ine4count <n6n!7>
message4id <message c,ass>.
Selection Screen
<Seection screen= is the screen &here one speci"ies the input %aues "or &hich the program
shou! run.The seection screen is normay generate! "rom the
• Parameters
• Seect$-ptions
ynta"
%e,ection4screen /egin of screen <screen 8> se,ection4screen /egin of /,oc9 <8> 2ith frame tit,e <te5t>
:::
::: se,ection4screen end of /,oc9 <8>
se,ection4screen end of screen <screen 8>
Parameters
Parameters heps one to !o !ynamic seection. They can accommo!ate ony one %aue "orone cyce o" eecution o" the program.Synta
7e"ining parameters as a !ata type
$arameters p;id67 type c.7e"ining parameters ike a tabe "ie!.
$arameter p;id ,i9e <ta/,e name>4<fie,d name>.
Parameters can be heckboes as &e as Ra!iobuttons.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 24/87
$arameters p;id as chec9/o5.
$arameters p;id! radio/utton group <group name>.
$arameters p;id= radio/utton group <group name>. Parameters can be istbo.
<arameter p_i# li5e ,table nameE,fiel# name a& li&tbo"
Seect -ptionsA Seect$-ption is use! to input a range o" %aues or a set o" %aues to a program.Synta
se,ect4options s;0/e,n for 0/a940/e,n.
Dou can aso !e"ine a seect option ike a %ariabe
se,ect4options s;0/e,n for 0/a940/e,n no inter0a,s no4e5tension
E7ents in an AAP ;eport Program
ABAP report programs are e%ent !ri%en programs. The !i""erent e%ents in a report Programare6
:oa!$o"$program
Triggers the associate! e%ent in an interna session a"ter oa!ing a program o" type 1( >( 8(
or S.Aso runs the associate! processing bock once an! once ony "or each program an! interna
session.The processing bock :-A7$-8$PR-GRA> has roughy the same "unction "or an ABAP
program o" type 1( >( 8 or S as a constructor has "or casses in ABAP -b#ects
'nitiaiation
This e%ent is eecute! be"ore the seection screen is !ispaye!.'nitiaiation o" a the %aues.
Dou can assign !i""erent %aues other than the %aues !e"aute! on the seection screen.
Dou can "i your seection screen &ith some %aues at runtime.At Seection$Screen
The e%ent is processe! &hen the seection screen has been processe! at the en! o" PA' 3.@ai!ation N hecks o" inputte! %aues happen here
Start$o"$Seection
Here the program starts seecting %aues "rom tabes.
5n!$o"$seectionA"ter a the !ata has been seecte! this e%ent &rites the !ata to the screen.
'nteracti%e 5%ents
Cse! "or interacti%e reporting. 't is use! to create a !etaie! ist "rom a basic ist.
4ormatting the report
ABAP ao&s the reports to be "ormatte! as the user &ants it to be. 8or eampe( <Aternate
:ines= must appear in !i""erent coors an! the <Totas= ine shou! appear in Deo&.
SyntaCormat (olor n
Cormat (olor n Inten&ifie# Fn
n may correspon! to %arious numbersPease note that there are other a!!itions aong &ith "ormat as &e
CF@BAT (FF@ FCC INT'NICI'D FCC INV'@' FCC MFT<FT FCC IN<>T
FCC
Interacti7e Programming
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 25/87
Csing 'nteracti%e Programming users can acti%ey contro the !ata retrie%a an! !ispay o"
!ata
Cse! to create a !etaie! ist "rom a %ery basic istThe !etaie! !ata is &ritten on a secon!ary ist.
The secon!ary ist may either competey o%eray the "irst screen or one can !ispay it in a
ne& screenThe secon!ary ists can be themse%es interacti%e.
The "irst ist may aso ca a transaction.
There are !i""erent e%ents associate! &ith interacti%e programming.Some comman!s use! "or interacti%e programming
Hotspot
'" one !rags the mouse o%er the !ata !ispaye! in the repor the cursor changes to a Han!
&ith an -utstretche! 'n!e "inger. An hotspot can be achie%e! using the 8-R>AT statement.Synta6 Cormat Mot&pot Fn 8Fff9.
Hi!e
This comman! heps you to store the "ie! names base! on &hich one &i be !oing "urther
processing to get a !etaie! ist. 't is &ritten !irecty a"ter the R'T5 statement "or a "ie!. hena ro& is seecte! the %aues get automaticay "ie! in the %ariabes "or "urther use.
Synta6 Mi#e ,fiel#Ename.
Logical !atabases
'nstea! o" using <Seect= ueries you can use ogica !atabase to retrie%e !ata "or a program.
:ogica !atabases are create! by transaction SE*@
The name o" a ogica !atabase can be up to 20 characters ong. 't may begin &ith a
namespace pre"i.
The !ata is seecte! by another program an! one can access the !ata using /'T ,tableE
name comman! &hich paces the !ata in the &ork area Etabe$nameF.A!%antages o" a ogica !atabase o%er norma Seect ueries.
't o""ers check con!itions to see &hether the input is correct( compete an! pausibe
't contains centra authoriation checks "or !atabase access5nhancements such as impro%ement in per"ormance imme!iatey appy to a reports &hich
use ogica !atabase.
/ote6 7ue to the compeities in%o%e!( ogica !atabases are not use! in most o" the cases;;;;
Chapter + # AAP !ialog ProgrammingSAP$ABAP supports t&o types o" programs * Report Program an! 7iaog Program.'" your ABAP program !eman!s user input( 7iaog programming is use!.
A user !iaog is any "orm o" interaction bet&een the user an! the program an! cou! be any
o" the "oo&ing
•
5ntering !ata• hoosing a menu item
• icking a button
• icking or !oube cicking an entry7iaog program is aso use! &hen &e nee! to na%igate back an! "orth bet&een screens
7iaog programs are create! &ith type as U>) * >o!ue Poo. They cannot be eecute!
in!epen!enty an! must be attache! to at east one transaction co!e in &hich you speci"y aninitia screen.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 26/87
!i//erence between ;eport and !ialog Programs
Report Program6
A report is a program that typicay rea!s an! anayes !ata in !atabase tabes &ithout
changing the !atabase.7iaog Program6
A !iaog program ao&s you to &ork interacti%ey &ith the system an! to change the
contents o" the !atabase tabes. 5ach !iaog program has a certain seuence o" screens that are processe! by the system one a"ter the other.
A Sample transaction processing in !ialog Programming
Components o/ !ialog Program
Cnike report &hich generay entais the creation o" one autonomous program &hich can be
eecute! in!epen!enty o" other ob#ects( !iaog program !e%eopment entais !e%eopment o"mutipe ob#ects none o" &hich can be eecute! on its o&n. 'nstea! a ob#ects are inke!
hierarchicay to the main program an! are eecute! in a seuence !ictate! by the 7iaog >ain
Program.
The components o" a !iaog program are6Transaction co!e
The transaction co!e starts a screen seuence.
Dou create transaction co!es in the Repository Bro&ser in the ABAP orkbench or usingTransaction S5M,.
A transaction co!e is inke! to an ABAP program an! an initia screen.
Dou can start a screen seuence "rom any ABAP program using the A:: SR55/statement.
Screens
5ach !iaog in an SAP system is controe! by one or more screens.Dou create screens using the Screen Painter in the ABAP orkbench through transaction
S51
5ach screen beongs to an ABAP program.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 27/87
These screens consist o" a <screen mask= or <ayout= an! its "o& ogic. The screen has a
ayout that !etermines the positions o" input+output "ie!s an! other graphica eements such as
checkboes an! ra!io buttons. A "o& ogic !etermines the ogica processing &ithin screen.GC' status
5ach screen has a GC' statuses3 &hich are in!epen!ent components o" a program.
This contros the menu bars( stan!ar! toobar( appication toobar ( &ith &hich the user canchoose "unctions in the appication.
Dou create them in the ABAP orkbench using the >enu Painter.
ABAP Program5ach screen an! GC' status in the R+, System beongs to one ABAP program.
The ABAP program contains the !iaog mo!ues that are cae! by the screen "o& ogic(
an! aso process the user input "rom the GC' status.
ABAP programs that use screens are aso kno&n as !iaog programs.'n a mo!ue poo type > program3V the "irst processing bock to be cae! is a&ays a !iaog
mo!ue. Ho&e%er( you can aso use screens in other ABAP programs( such as eecutabe
programs or "unction mo!ues. The "irst processing bock is then cae! !i""erentyV "or eampe(
by the runtime en%ironment or a proce!ure ca. The screen seuence is then starte! using theA:: SR55/ statement.
Screen 8o& :ogicScreen 8o& ogic is primariy !i%i!e! into "our components.
1. Process Be"ore -utput PB-3 e%ent6 &hich is processe! be"ore the screen is
!ispaye!2. Process A"ter 'nput PA'3 e%ent6 &hich is processe! a"ter a user action on the screen
,. Process on hep reuest P-H36 &hich is processe! &hen 81 is presse!
4. Process on %aue reuest P-@36&hich is processe! &hen 84 is presse!
7ynproA screen together &ith its 8o& ogic is cae! a 7ynpro <7ynamic Program= since the
screen "o& ogic in"uences the program "o&3
5ach !ynpro contros eacty one step o" your 7iaog Program.The screens beonging to a program are numbered. The screen "o& seuence can be either
inear or cycic. 8rom &ithin a screen chain( you can e%en ca another screen chain an!( a"ter
processing it( return to the origina chain. Dou can aso o%erri!e the staticay$!e"ine! net screen"rom &ithin the !iaog mo!ues o" the ABAP program.
ABAP >o!ue Poo
-n a PB- or PA' e%ent a 7ynpro cas an ABAP !iaog program. oection o" such
programs is cae! the ABAP mo!ue poo.8or eampe mo!ues cae! at the PA' e%ent are use! to check the user input an! to trigger
appropriate !iaog steps( such as the up!ate task.
A !ynpros to be cae! "rom &ithin one transaction re"er to a common mo!ue poo.Structure o" a 7iaog Program
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 28/87
Process 8o& "or a 7iaog Program
;;;;
Chapter B # SubscreensBe"ore you rea! this hapter make sure you &hat a 7iaog Program is 9
Subscreens
A subscreen is an in!epen!ent screen that is !ispaye! in an area o" another <main=3 screen.Subscreens ao& you to embe! one screen &ithin another at runtime. Dou can incu!e
mutipe sub$screens on main screen.
The term subscreen appies both to the screen that you embe!( an! the area on the main
screen in &hich you pace it. This hapter is about subscreen areas. The actua screens create!through S51 transaction( are cae! subscreen screens i" !e"ine! in screen attributes.
hen you use a subscreen( the "o& ogic o" the embe!!e! screen is aso embe!!e! in the
"o& ogic o" the main screen.Hence( Csing subscreens on screens is ike using incu!es inABAP programs.
To use a subscreen( you must "oo& three simpe steps
1. 7e"ine the subscreen areas3 on a screen
2. 7e"ine suitabe subscreen screens,. 'ncu!e the subscreen screen in the subscreen area.
Aso( you nee! to a!#ust the "rame o" sub$screen an! main screen. Dou nee! to name it in
the "ie! name "ie!.8urther( you aso nee! to a!#ust the "ie!s &ithin the subscreen to make them appear in main
screen. 'n case the sub$screen is !e"ine! to be arger than the a%aiabe area in the main screen(
ony the part o" subscreen &i be %isibe that "its in the area a%aiabe. The area is a&ays
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 29/87
measure! "rom the top e"t corner o" screen. Hence you shou! take a!euate care &hie !e"ining
sub$screen areas an! creating sub$screens.
5A>P:58or instance here &e ha%e !e"ine! t&o sub$screen areas on main screen an! ha%e attache!
t&o !i""erent Sub$screen to correspon!ing areas. hene%er main screen is cae!( the PB- o"
main screen is cae!. But be"ore !ispay( the PB-)s o" each screen attache! &ith sub$screenareas on main screen are aso cae!.
Dou can incu!e a subscreen screen using the A:: SCBSR55/ statement in the "o&
ogic o" the main screen.To incu!e a subscreen screen in the subscreen area o" the main screen an! ca its PB- "o&
ogic( use the "oo&ing statement in the PB- e%ent o" the main screen6
<@F(' ;'CF@' F>T<>T
(A >;(@''N ,area IN(>DIN/ ,pro-! ,#ynp.
This statement assigns the subscreen screen &ith number E!ynpF to the subscreen area
cae! EareaF. Dou can aso speci"y the program in &hich the subscreen screen is !e"ine!optiona3. '" you !o not speci"y the program epicity( the system ooks "or the subscreen screen
in the same ABAP program as the main program. '" it !oes not "in! a correspon!ing subscreen
screen( a runtime error occurs. The PB- "o& ogic o" the subscreen screen is aso incu!e! at thesame point. This can ca PB- mo!ues o" the ABAP program in &hich the subscreen screen is
!e"ine!. At the en! o" the subscreen PB-( the goba "ie!s "rom the program are passe! to anyi!enticay$name! screen "ie!s in the subscreen screen. The PB- "o& ogic o" the subscreenscreen can itse" incu!e "urther subscreens.
The name EareaF o" the subscreen area must be entere! !irecty &ithout in%erte! commas.
Dou can speci"y the names EprogF an! E!ynpF either as iteras or %ariabes. '" you use%ariabes( you must !ecare an! "i i!enticay$name! %ariabes in the ABAP program. The
screen number E!ynpF must be 4 characters ong. '" you !o not assign a subscreen screen to an
area( it remains empty.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 30/87
To ca the PA' "o& ogic o" the subscreen screen( use the "oo&ing statement in the PA'
"o& ogic o" the main screen6
<@F(' ACT'@ IN<>T
(A >;(@''N ,area.
This statement incu!es the PA' "o& ogic o" the subscreen screen incu!e! in the subscreen
area EareaF in the PB- e%ent. This can ca PA' mo!ues o" the ABAP program in &hich thesubscreen screen is !e"ine!. 7ata is transporte! bet&een i!enticay$name! "ie!s in the
subscreen screen an! the ABAP program either &hen the PA' e%ent is triggere!( or at the
correspon!ing 8'5:7 statements in the PA' "o& ogic o" the subscreen screen.Points to Remember
• /ames o" eements o" sub$screens &ithin a screen shou! be uniue
• Dou shou! not ha%e -K-75 or 8-75 attache! &ith sub$screen. The-K-75 o" main screen itse" is -K-75 o" sub$screen
• Sub$screens cannot ha%e any !iaog mo!ues containing S5T T'T:5BAR( S5T P8$
STATCS( S5T SR55/( :5A@5 SR55/ or :5A@5 T- SR55/. This &icause runtime error.
• Dou nee! to ca it in the "o& ogic both PB- an! PA'3 o" the main screen.• A:: SCBSR55/ is not ao&e! in HA'/..5/7HA'/ an! :--P 5/7:--P
statements
• annot ha%e an AT 5'T$->>A/7 mo!ue
• The "ie!s that you use are the goba "ie!s. They must be !ecare! in the top incu!e
• '" using subscreens "rom another !iaog program the !ata trans"er &i not happenuness you a!! speci"ic co!e.
;;;;
Chapter 1? # Process on $alue 5 Process on 0elp8irst( to begin &ith i" you kno& nothing about Screen 8o& ogic an! their uses in SAP (&e
recommen! you check our hapter on 7iaog Program
/o&( et)s ook into P-H an! P-@ in !etai
Process on 0elp#;euest DP%03 41 0elp
hene%er 81 is presse! the P-H e%ent "or the speci"ie! !ata eement is eecute!.
'" the PR-5SS -/ H5:P$R5OC5ST e%ent !oes not eist in the process ogic o" a screen(
the !ocumentation o" the "ie! in the ABAP 7ictionary is taken as a basis an! !ispaye!. 5%en i"that !oes not eit no hep is !ispaye!.
To !ispay "ie! hep !ocumentation( you must co!e the "oo&ing screen "o& ogic in the
P-H e%ent6 <@F(' FN M'<E@'>'T
CI'D ,f BFD>' ,mo#! +ITM ,num
'" there is screen$speci"ic !ata eement !ocumentation "or the "ie! ,fG you can !ispay it by
speci"ying its number ,num.The number ,num can be a itera or a %ariabe. The %ariabe must be !ecare! an! "ie! in
the correspon!ing ABAP program. /ote( the 8'5:7 statement !oes not trans"er the contents o" the screen "ie! ,f to the
ABAP program in the PR-5SS -/ H5:P$R5OC5ST e%ent. 't #ust sho&s hep
!ocumentation. That)s it.
The mo!ue ,mo# is !e"ine! in the ABAP program ike a norma PA' mo!ue. The processing ogic o" the mo!ue must ensure that a!euate hep is !ispaye! "or the "ie! in
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 31/87
uestion. 'nstea! o" caing an etra screen &ith tet "ie!s( you shou! use one o" the "oo&ing
"unction mo!ues to !ispay a suitabe SAP script !ocument
EL$;#1E(";%#W;F#+;FIELDThis "unction mo!ue !ispays the !ata eement !ocumentation "or components o" any
structure or !atabase tabe "rom the ABAP 7ictionary.
Dou pass the name o" the component an! structure or tabe to the import parameters 8'5:7an! TAB:5.
H5:P-B?5TSH-
Cse this "unction mo!ue to !ispay any SAP script !ocument.Dou must pass the !ocument cass "or eampe( T "or genera tets( 75 "or !ata eement
!ocumentation3 an! the name o" the !ocument to the import parameters 7-K:ASS an!
7-K/A>5.
8or technica reasons( you must aso pass an empty interna tabe &ith the ine type T:'/5to the tabes parameter o" the "unction mo!ue.
Process on $alue DP%$3 4)
hen the user chooses the "unction possibe entries 843( the system !ispays the possibe
input %aues "or a "ie! %aues( check tabe( matchco!e3( pro%i!e! they &ere store! by the!e%eoper.
The e%ent <@F(' FN VA>'E@'>'T is a&ays processe! i" the user has cae!<Possibe entries=.
To !e"ine Possibe %aues "or a "ie! on screen( you nee! to !e"ine! "oo&ing in P-@ e%ent
o" screen "o& ogic6
<@F(' FN VA>'E@'>'T
CI'D fiel# name BFD>' mo#ule name
8or Possibe %aues( &ithin mo!ue !e"ine! abo%e( you shou! use the genera "unction
mo!ue M'<_VA>'_/'T_+ITM_TA;' to get possibe %aues "rom ABAP 7ictionary.There are some other "unctions that can aso be use! "or input hep6
F@IF;FIELD;ALUE;+EBUE%"
as the input hep o" the ABAP 7ictionary !ynamicay.Dou can pass the component names o" a structure or !atabase tabe o" the ABAP 7ictionary
to the "unction mo!ue in the import parameters TAB/A>5 an! 8'5:7/A>5.
The "unction mo!ue starts the ABAP 7ictionary input hep "or this component. A o" theree%ant screen "ie!s are rea!.
'" you speci"y the import parameters 7D/PPR-G( 7D/P/R( an! 7D/PR-8'5:7( the
user)s seection is returne! to the correspon!ing "ie! on the screen.
'" you speci"y the tabe parameter R5TCR/TAB( the seection is returne! into the tabeinstea!.
BFD>' VA>'_(A@@I'@ IN<>T.
(A C>N(TIFN CIC_CI'D_VA>'_@'>'TL
'K<F@TIN/
TA;NAB' = D'BFCM'<L
CI'DNAB' = (A@@I'@1O
DHN<<@F/ = <@F/NAB'
DHN<N@ = DHNN>B
DHN<@FCI'D= (A@@I'@L.
'NDBFD>'.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 32/87
F@IF;IN";"1LE;ALUE;+EBUE%"
This "unction mo!ue !ispays a %aue ist that you create! in an ABAP program.
The %aue ist is passe! to the "unction mo!ue as the tabe parameter @A:C5TAB.'" you speci"y the import parameters 7D/PPR-G( 7D/P/R( an! 7D/PR-8'5:7( the
user)s seection is returne! to the correspon!ing "ie! on the screen.
'" you speci"y the tabe parameter R5TCR/TAB( the seection is returne! into the tabeinstea!.
(A C>N(TIFN CIC_INT_TA;'_VA>'_@'>'TL
'K<F@TIN/
@'TCI'D = (FNNIDL
DHN<<@F/ = <@F/NAB'
DHN<N@ = DHNN>B
DHN<@FCI'D = (FNN'(TIFNL
VA>'_F@/ = L
TA;'
VA>'_TA; = VA>'_TA;.
That)s a to P-H an! P-@. :ea%e your comments in case o" any !oubts.;;;;
Chapter 11 # AL$#AAP List $iewer ProgrammingThe common !esire! "eatures o" any report are <coumn aignment=( sorting( "itering(
subtotas( totas etc. To impement these "rom scratch( a ot o" co!ing e""ort is to be put. To a%oi!
that &e can use a concept cae! ABAP :ist @ie&er A:@3.Csing A:@( &e can ha%e three types o" reports6
1. Simpe Report
2. Bock Report
,. Hierarchica Seuentia Report5ach o" these reports pro%i!es "unction mo!ues &hich hep in pro!ucing !esire! output
&ithout much e""ort. :et)s ook at them in !etai $Simple ;eport
'mportant "unction mo!ues in this report are $
• @eu&e_alv_fiel#catalo-_mer-e
• @eu&e_alv_li&t_#i&play
• @eu&e_alv_event&_-et
• @eu&e_alv_-ri#_#i&play
• @eu&e_alv_commentary_write
+EU%E;LA;FIELD("L#C;-E+CE
This "unction mo!ue is use! to popuate a "ie! cataog &hich is essentia to !ispay the !ata
in A:@.'" the output !ata is "rom a singe !ictionary tabe an! a the coumns are seecte!( then &e
nee! not ecusi%ey create the "ie! cataog. 't)s enough to mention the tabe name as a parameter 'structurename3 in the @'>'_AV_IT_DI<AH . But in other cases &e nee!
to create it.
/ote 6 8ie!cataog can be "ie! manuay aso by "iing up a the reuire! !etais into theinterna tabe
'mportant parameters in are6
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 33/87
5port6
• I_pro-ram_name 6 report i!
• I_internal_tabname 6 the interna output tabe
• I_inclname 6 incu!e or the report name &here a the !ynamic "orms are han!e!.
hanging
• ct_fiel#cat 6 an interna tabe &ith the type I_T_CI'D(AT_AV &hich is!ecare! in the type poo S:'S.
+EU%E;LA;LI%";DI%$L3 This is the "unction mo!ue &hich prints the !ata.
The important parameters are6
5port6
• I_callbac5_pro-ram 6 report i!
• I_bypa&&in-_buffer 6 U)
• 'bu""eracti%e 6 U U
• I_callbac5_pf_&tatu&_&et 6 routine &here a user can set his o&n p" status or change
the "unctionaity o" the eisting p" status.
• I_callbac5_u&er_comman# 6 routine &here the "unction co!es are han!e!.
• I_&tructure name 6 name o" the !ictionary tabe
• I&_ayout 6 structure to set the ayout o" the report
• It_fiel#cat 6 interna tabe &ith the ist o" a "ie!s an! their attributes &hich are to be printe! this tabe can be popuate! automaticay by the "unction3
• It_event&6 interna tabe &ith a ist o" a possibe e%ents o" A:@ an! their
correspon!ing "orm names.Tabes6
• t_outtab6 interna tabe &ith the !ata to be output
+EU%E;LA;EAEN"%;CE"Returns tabe o" possibe e%ents "or a ist type
'mport6
• 't_'vent& 3The e%ent tabe is returne! &ith a possibe A::BAK e%ents "or thespeci"ie! ist type coumn U/A>5)3. 8or e%ents to be processe! by the aback(
their U8-R>) "ie! must be "ie!. '" the "ie! is initiaie!( the e%ent is ignore!. The
entry can be rea! "rom the e%ent tabe( the "ie! U8-R>) "ie! an! the entrymo!i"ie! using constants "rom the type poo S:'S.
5port6
I_li&t_type7
•0 simpe ist @'>'_AV_IT_DI<AH
• 1 hierarchica$seuentia ist @'>'_AV_MI'@'_IT_DI<AH
• 2 simpe bock ist @'>'_AV_;F(_IT_A<<'ND
• , hierarchica$seuentia bock ist
@'>'_AV_;F(_IT_M_A<<'ND
+EU%E;LA;C+ID;DI%$L3 A ne& "unction "rom ABAP4. %ersion( to !ispay the resuts in gri! rather than a pre%ie&.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 34/87
Parameters6 same as reu&e_alv_li&t_#i&play
/ote6
• Gri! cannot han!e high %oumes. A "unction ike sort( scroing !o&n consumes a
ot o" resources + time i" the %oume o" !ata to be !ispaye! is high. There is no cear
cut !e"inition such that i" the amount o" !ata is go "or ist or gri! but the !e%eoper
has to take a ca base! on his eperience. '" not sure( then ist is the better option
+EU%E;LA;(#--EN"+3;W+I"E
This is use! in the Top$o"$page e%ent to print the hea!ings an! other comments "or the ist.'mportant Parameters
It_li&t_commentary 6 'nterna tabe &ith the hea!ings o" the type &li&_t_li&t)ea#er .
This interna tabe has three "ie!s6Typ 6
• UH) * hea!er(
• US) * seection(
• UA) * action
Key6 ony &hen typ is US).'n"o 6 the tet to be printe!
loc ;eport
This ooks ike a simpe report but this report has the "eatures o" sorting an! "itering ony.
This report is use! i" you ha%e to !ispay more than one report on the output. Technicay
speaking i" you ha%e mutipe interna tabes &ith !ata to be !ispaye! as separate bocks then &ego "or bock report o" A:@.
The important "unctions use! "or creating this report are6
• @'>'_AV_;F(_IT_INIT
• @'>'_AV_;F(_IT_A<<'ND
• @'>'_AV_;F(_IT_DI<AH
+EU%E;LA;1L#(*;LI%";INI"
This "unction mo!ue is use! to set the !e"aut gui status etc. The parameters are simiar to
the one use! in reu&e_alv_li&t_#i&play or reu&e_alv_-ri#_#i&play
+EU%E;LA;1L#(*;LI%";$$END
This "unction mo!ue a!!s the !ata to the bock.
'mportant Parameters
5port6
• i&_layout 6 ayout settings "or bock
• it_fiel#cat 6 "ie! cataog
• I_tabname6 interna tabe name &ith a possibe e%ents
Tabes6
• t_outtab6 interna tabe &ith output !ata.
+EU%E;LA;1L#(*;LI%";DI%$L3
This "unction mo!ue !ispays the ist &ith !ata appen!e! by the abo%e "unction.
Parameters6 A the parameters are optiona.
0ierarchical ;eports
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 35/87
Hierarchica !ispay is use! "or !ispaying !ata that are reate!. :ike saes or!er an! item
!etais. Here saes or!er !etais can be the hea!er !ata &hereas them items in the saes or!er can
be the item !ataThe "unction mo!ue use! "or this is
+EU%E;LA;IE+%EB;LI%";DI%$L3
5port6• I_(A;A(_<@F/@AB
• I_(A;A(_<C_TAT>_'T
• I_(A;A(_>'@_(FBBAND
• I_AHF>T
• It_fiel#cat
• It_event&
• I_tabname_)ea#er 6 /ame o" the interna tabe in the program containing the output
!ata o" the highest hierarchy e%e.
• I_tabname_item6 /ame o" the interna tabe in the program containing the output!ata o" the o&est hierarchy e%e.
• I&_5eyinfo6 This structure contains the hea!er an! item tabe "ie! names &hich ink
the t&o tabes share! key3.Tabes
• t_outtab_)ea#er 6 Hea!er tabe &ith !ata to be output
• t_outtab_item 6 /ame o" the interna tabe in the program containing the output !atao" the o&est hierarchy e%e.
A the !e"initions o" interna tabes( structures an! constants are !ecare! in a type$poo
cae! SLIS& This interna tabe can be popuate! automaticay by using
@'>'_AV_CI'D(ATAF/_B'@/'L .
!isplay $ariants
7ispay %ariants are use! to set the !e"aut properties o" an a% output ike sort criteria(
"itering criteria( totaing an! subtotaing etc7ispay %ariants can be user speci"ic an! stan!ar! stan!ar! %ariants can be use! by any user
3
Kin! o" !ispay %ariants that can be sa%e! is controe! by the parameter isa%e that is passe! in "unction mo!ues reusea%ist!ispay + reusea%gri!!ispay
Dou can pro%i!e an option on the seection screen to seect &hat !ispay %ariant to be use!
The common "unction mo!ues reate! to seecting + %ai!ating !ispay %ariants are
• @eu&e_alv_variant_#efault_-et
• @eu&e_alv_variant_f
• @eu&e_alv_variant_e"i&tence
That)s a to ABAP$ A:@ programmingQ ;;;;
Chapter 1 # All about SAP scriptsSAP script is the SAP System)s o&n tet$processing system. 't ooks an! "ees a ot ike
other ea!ing tet$processing systems.
't is use! to print pre"ormatte! tet in pre$"ormatte! "orms.
Components o/ SAP Script
SAP Scripts comprises o" "i%e main components6
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 36/87
An e!itor "or entering an! e!iting the ines o" a tet
Styes an! ayout sets "or print ayout. These are create! in!epen!ent o" the in!i%i!ua tets
using the correspon!ing maintenance transactions an! are aocate! to the tets ater The composer is a centra output mo!ue. The SAP script composer is in%isibe to the
outsi!eA programming inter"ace that ao&s you to incu!e SAP script components into your o&n
appication programs an! to contro the output o" ayout sets "rom &ithin the programs
Se%era !atabase tabes "or storing tets( styes an! ayout sets
Layout Set
To output !ocuments using the programming inter"ace( R+, appication programs nee! so$cae! ayout sets a kin! o" "orm3.'n SAP script a ayout set !escribes the ayout o" the
in!i%i!ua print pages an! uses tet eements to suppy !e"inabe output bocks( &hich a print
program can ca. A ayout set can be !e"ine! as a page !esign "or a !ocument:ayout set on its o&n !oesn)t contain any !ata. The seection o" !ata "or the !ocument is
!one through the print program. The print program seects the !ata "rom !atabase tabe an!
"ee!s it to the ayout set. hen the print program is eecute! the !ocument is printe! on thescreen( printer.
Csuay a SAP Script :ayout consists o" "oo&ing components
1& 0eader !ata3
Hea!er !ata is use! "or in"ormation an! contro o" SAP printing. The hea!er !atacomprises o" 2 parts$
7e%ice 'n!epen!ent 6Stores in"ormation ike Start page( 7e"aut
paragraph( :anguage Attributes etc.
7e%ice 7epen!ent6 stores in"ormation ike Page "ormat (-rientation :ines
per inch etc
& Paragraph and Character 4ormats3
Paragraphs are "ormatte! using %arious attributes. 8or instance Stan!ar! paragraphattributes speci"y :e"t or Right margin( Aignment( :ine spacing etc. 8ont attributes
speci"y 8ont "amiy( 8ont sie etc. haracter "ormats ao& to "ormat entire bocks o"tet &ithin a paragraph
*& 'indows and "e-t Elements3
in!o&s are in!i%i!ua tet areas hea!er a!!ress( !ate( "ooter3 in a page. 't heps
combine the in"ormation containe! in a !ocument into certain groups an! make eachgroup appear on the printe! page in an in!i%i!ua area. Dou can !e"ine tet eements
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 37/87
&in!o& tets3 "or each &in!o&. The print program accesses tet eements by name(
"ormats them an! prints them in the respecti%e &in!o&. The paragraph an! the
character "ormats use! must be !e"ine! in the "orm.
)& Pages3
They are in!i%i!ua pages o" a !ocument an! must ha%e a uniue name. Dou &i
o"ten "in! !i""erent ayouts "or in!i%i!ua pages6 The "irst page o" an in%oice !i""ers"rom the subseuent pages( on &hich you nee! not repeat genera in"ormation( such
as a!!ress or customer !ata.
=& Page 'indows3
hie !e"ining &in!o&s an! pages( you !o not yet !etermine the position an!
spacing o" the tets to be output. A page &in!o& !e"ines the rectanguar output area
in the output me!ium by speci"ying the e"t upper e!ge o" the output area an! its
&i!th an! height
Control Commands
The purpose o" <contro comman!s= is to ao& contro o" the output "ormatting. These
comman!s are not interprete! by the SAP script e!itor( but are passe! through to the SAP script
omposer "or processing. This incu!es( "or eampe( ine an! page "ormatting( the "ormatting o"tet accor!ing to the paragraph an! character "ormats speci"ie!.
Synta
'nter $7 in the paragraph "ormat
5ampes
N'+E<A/' * 5picit page break
<@FT'(T %%%'ND<@FT'(T * To print compete paragraph in one page.
IN(>D' * To incu!e the content o" another tet into current tet
<'@CF@B * To ca a subroutine o" any ABAP program
Print Program
The eecution o" script is !one through an ABAP program( &hich is re"erre! as Print
Program. 5ach print program shou! ha%e an 5/TRD "orm ( &hich &i be cae! "rom
customiation.8or a stan!ar! con"iguration &e can see the "orm name script name3( print program name
an! output type in the tabe TNA<@.The print program uses the 8orm contro "unctions to ca
the script.The print program ca either a or some o" the "orm contro "unctions to eecute the script
• F<'N_CF@B >an!atory36 -pens the ayout set output
• (F'_CF@B >an!atory36 5n!s the ayout set output
• TA@T_CF@B -ptiona3 6Starts a ne& ayout set
• +@IT'_CF@B >an!atory36 as a ayout set eement
• 'ND_CF@B -ptiona36 5n!s the current ayout set
%utput "ypesThe output type can speci"y( a printe! "orm that you nee! "or interna use or a "orm that you
&ant to sen! to a customer or %en!or. The output type can aso be an interna eectronic maimessage that you &ant to sen! to sta"" in another !epartment.
8or eampe <Print out= can be cassi"ie! as one output type o" a biing !ocument( i.e. &hen
this output type is eecute! the biing !ocument is printe!. Simiary <8a= can be an output
type( i.e. &hen this output type is eecute! a "a o" the biing !ocument is sent
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 38/87
A the output types "or any !ocument e.g. biing !ocument3 &i be store! in the tabe
/AST.-utput types are eecute! through the program RS/AST00.
5ampe6 -utput type in a biing !ocument$
• Go to @80,
• 5nter biing !ocument number an! press enter again
• hose -utput un!er the menu Go to $F Hea!er • Here J101 is an output type o" a print output
Standard "e-ts and 6raphics
Stan!ar! Tets "or your report can be create! using transaction S%1?
Graphics an! printer macros are upoa!e! &ith report RST:7> into in!i%i!ua stan!ar!tet !ocuments or through transaction SE+& Graphics are upoa!e! in <Baseine T'88 .0W "ormat
.ti" "ies on P3
SAP Script N Stan!ar! tet eements can eporte! or importe! bet&een t&o systems using
RSTSRP program
Copying Scripts Across clients6
SAP Script is a cient !epen!ent ob#ect. Cnike programs( changes !one to SAP script in one
cient &i not be re"ecte! in other cients. 8or copying script "rom one cient to another( goto S5L1an! use <opy "rom ient= option a%aiabe un!er Ctiities menu or import the transport
reuest( in &hich the script is sa%e!( "rom the origina cient using the transaction SCC1&
'mportant Points to /ote
• SAP script !oes not maintain any %ersions. So &hen mo!i"ying the SAP script(ensure that the changes are &e !ocumente! in script. This appies to the stan!ar!
tets too.
• The output o" the "orm &i !i""er &hen %ie&e! on the screen an! on the printer. So
a&ays test the output o" the script on the printer.
;;;;
Chapter 1* # Smart 4ormsSAP Smart 8orms is use! to create an! maintain "orms "or mass printing in SAP Systems.
As output me!ium SAP Smart 8orms support a printer( a "a( e$mai( or the 'nternet by using the
generate! >: output3.SAP intro!uce! Smart 8orms in 1MMI to o%ercome the imitations in SAP Scripts. Smart
8orms are easier to !e%eop( maintain an! transport than SAP Script.Smart 4orms and Sap Scripts Comparison
• >utipe page "ormats are possibe in Smart 8orms &hich is not the case in SAP
Scripts
• 't is possibe to ha%e a Smart 8orm &ithout a main &in!o&.
• Routines can be &ritten in Smart 8orms too.
• Smart 8orms generates a "unction mo!ue &hen acti%ate!.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 39/87
• :abes cannot be create! in Smart 8orms.
Ad7antages o/ Smart 4orms
• They hep a!apting "orms &ithout any programming kno&e!ge !ue to entireygraphica user inter"ace
• hen acti%ating the smart "orm the system automaticay generates the "unction
mo!ue an! at the runtime.• To make any changes &e ha%e to use the 7rag N 7rop( ut N Paste. These actions
!o not incu!e &riting o" co!ing ines or using a script anguage.
• e can insert static an! !ynamic tabes. These incu!e the ine "ee!s in the
in!i%i!ua tabe ces( triggering e%ents "or tabe hea!ings an! subtotas an! sorting
!ata be"ore output.
• The smart "orms ao& the user to incu!e graphics( &hich can be !ispaye! as a parto" the "orm or as backgroun! graphics. 7uring printout the user can suppress the
backgroun! graphic as an! &hen necessary.
• eb Pubishing is possibe using the generate! >: output
Architecture o/ SAP Smart 4orm
Smart/orms 6uide
:et)s go through it in SAP system$
• 5nter transaction S2A;"4%;2S in the transaction co!e bo.
• 'n the net screen ( enter a "rom name an! cick create
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 40/87
• The net screen is !i%i!e! into three sections$
1. Na7igation window $consist o" no!es an! sub no!es. They contain a the eements
tet( &in!o& etc3 that beong to sap "orms
2. 2aintenance window$ sho&s attributes o" the eements,. 4orm printer $&in!o& sho&s the ayout o" the page
hene%er &e create smart "orms( SAP creates+generates a "unction mo!ue. Cnike SAP
scripts ( SAP 8-R>S ao& you to change anguage.'n the na%igation &in!o& you &i "in!
• 6lobal !ata !eclarations3 The 7ata !e"ine! here can be use! throughout the smart"orm "or co!ing purposes.
• 4orm Inter/ace6 Here a the !ata &hich &i be passe! to the smart "orm "rom the
Print program is !e"ine!.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 41/87
Right$icking on the Pages &i ao& creation o" /e& Page( in!o&( Graphic or A!!ress.
Printing &i take pace on the basis o" Unet page) "ie!.But processing &i happen as per the
seuence in na%igation &in!o&Q
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 42/87
8or backgroun! picture an! graphics you can pick up either back an! &hite or coor bitmap
images an! are store! in the "orm o" stan!ar! tets. Dou may take a !etour "rom the smart "orm
screen an! open 8orm Graphics screen. Transaction co!e6 SeLI
Setting in the 6raphics in Smart 4orm 'indow#
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 43/87
in!o&s in Smart 8orms
There are t&o types o" in!o&s1. >ain
2. Secon!ary
'mportant Points to /ote
• Dou cannot ha%e more than 1 main &in!o& in a page. Dou can ha%e mutipe
secon!ary &in!o&s
• hate%er you print in secon!ary &in!o&9it has to be static. '" u ha%e 20 ines in a
P- an! there is page constraint the ines get carrie! "or&ar! to net page in the main&in!o&. i.e. 'n a pre!ecessor an! successor type o" content( they &i be printe! in
seuence in main &in!o&. This is not ao&e! in Secon!ary &in!o&s.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 44/87
'nsi!e the main &in!o& &e can a!! tet as intro!uction to customie the "orm output.
The -utput options on each &in!o& !etermine the :ine sie( i!th( oors an! backgroun!
to be put.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 45/87
A smart "orm gi%es the option o" gi%ing the a!!ress number &hich is maintaine! in the
centra a!!ress management. The a!!ress &i be !irecty taken "rom A7R tabe an! &i be popuate! in the "orm.
The t&o !i""erent e!itors are a%aiabe in Smart"orms
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 46/87
1. /orma 5!itor
2. Graphics 5!itor.
This setting can be change! using the on"igure e!itor in Ctiities.'n Tabe painter(you can !ra& the "ormat as per cient reuirement e.g. Hea!ing( Sub Hea!ing( 'tem(
Sub Tota( Gran! Tota etc.3
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 47/87
Dou can use the tabe ayout to !etermine6
• The number o" ines an! ces
• The height o" each ine
• The &i!th o" each ce
• The aignment o" the tabe in the &in!o&
• The Tabe sho&s the !i""erent ine types &hich &i be use! in the tabe. The :inetypes !e"ine the sie o" each ce an! the number o" ces in each ine.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 48/87
Smart 4orms Programming 4low
• hen an SAP Smart 8orm tempate is create!( a user creates the "orm ayout( !e"ines
the reuire! "ie!s( con!itions( an! specia programming instructions in the Smart
8orm tempate using the Smart 8orm Bui!er.
• A"ter the "orm !esign is compete( the "orm nee!s to be acti%ate! be"ore it can beteste! or accesse! by the print programs. Acti%ating the "orm initiates the generation
o" a "unction mo!ue that han!es a o" the "orm)s processing.
• This "unction mo!ue interacts &ith the appication program+print program to createthe output in the user$!e"ine! output me!ia "or the speci"ie! !e%ice.
• 'n case o" smart "orms( &e use 2 "unction mo!ues "or the processing o" the smart
"orm. To the "irst "unction mo!ue( &e pass the name o" the smart "orm as the import parameter. This then returns the name o" the !ynamicay generate! "unction mo!ue
&hich &i actuay ca the smart "orm.
• The smart "orm name can be passe! on to the "unction >o!ue *
C_C>N(TIFN_BFD>'_NAB'L
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 49/87
• This &i return the 8unction mo!ue name o" the smart "orm &hich is re"erence!.
• The Print program &i be caing the 8> F C_C>N(TIFN_BFD>'_NAB'L to
get the 8unction mo!ue name at Runtime. Therea"ter it &i ca the 8unctionmo!ue thus obtaine! to eecute the smart "orm.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 50/87
"emplates
• Tempate can be use! &hen you kno& the eact sie o" the output or the output is in
a "ie! "ormat.
• 5.g. Ta "orm+ cheues +airine "orm+rai&ay ticket6 a these use tempates.
• The big bet&een tabe an! tempate is that in a Tabe the height changes
!ynamicay. e ca a ro& a Uine) in tempate.
S2A;" Styles
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 51/87
A Smart Stye contains6
• Hea!er !ata containing the !e"aut %aues o" a Smart Stye
• Paragraph "ormats incu!ing in!ents an! spacing( "ont attributes( tabs( an! outinean! numbering
• haracter "ormats incu!ing e""ects superscript( subscript3( barco!e an! "ont
attributes• oors an! un!erines "or a paragraph or character "ormat
• Dou can use the transaction Usmart"orms) + Usmartstyes) to create a smart stye.
That)s a to this hapter
;;;;
Chapter 1) # Customer and :ser E-itshat is ustomer 5itsX
ustomer eits are GhoosH pro%i!e! by SAP &ithin many stan!ar! programs( screens an!
menus on &hich customers may GhangH custom "unctionaity to meet business reuirements.>ore on this in a moment9
"ypes o/ Customer E-its
There are three main types o" customer eits6
1& 8unction >o!ue 5its
& Screen 5its*& >enu eits
4unction 2odule E-it6 't ao&s customer to a!! co!e %ia a "unction mo!ue at a speci"ic
ocation in an SAP appication program
Synta6 (A (>TFB'@EC>N(TIFN L00O
2enu E-it3 't ao&s customer to a!! items to a pu !o&n menu in a stan!ar! SAP
program. These items may be use! to ca a!!$on programs or custom screens.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 52/87
4ormat6 YCS a!!itiona item in GC' status3
Screen E-it3 't ao&s customer to a!! "ie!s to a screen in an SAP program %ia a
subscreen. The subscreen is cae! &ithin the stan!ar! screen)s "o& ogic.
4ormat3 (A (>TFB'@E>;(@''N (>T(@
E-amples o/ Customer E-its
E-ample o/ a Screen E-it6'n transaction AT2 * Time Sheet 5ntry( HR &ishes to incu!e an interacti%e
ackno&e!gment that kno&ingy submitting incorrect !ata is groun!s "or !ismissa.
E-ample o/ a 2enu E-it3'n transaction S5,I * ABAP 5!itor( the !e%eopment team &ishes to incu!e a menu
ink to transaction S5I0 * -b#ect /a%igator "or ease o" use.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 53/87
E4%;E
A4"E;
E-ample o/ a 4unction 2odule E-it3
The company &ants the bank !etais o" the @en!ors in the @en!or creation to be
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 54/87
man!atory e%ent .So it must "ash an error message that UPease 5nter the bank
!etais)
E4%;E
A4"E;
Locating Customer E-its
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 55/87
• 'n transaction S>-7 an! ook into the !etais$
• -r in transaction S5I1 you can use the appropriate appication area
reate a ustomer 5it• To create a customer eit you "irst nee! to create a pro#ect in transaction C2%!
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 56/87
• :ater you assign the ustomer 5it to your pro#ect.
'hat is a :SE; EI">
Cser 5it ser%es the same purpose as ustomer 5its but they are a%aiabe ony "or the S7
mo!ue. The eit is impemente! as a ca to a 8unction >o!ue. The co!e is &ritten by the
!e%eoper .
• e kno& Cser 5it in S7 is 2$)=A4JJ
• >'@'KIT_CI'D_BFDICI(ATIFN 6 To mo!i"y screen attributes
• >'@'KIT_AV'_DF(>B'NT 6To per"orm operations &hen user hits Sa%e
• >'@'KIT_AV'_DF(>B'NT_<@'<A@'
• >'@'KIT_BFV'_CI'D_TF_V;A 6hen user hea!er changes are mo%e! to
hea!er &ork area.
• >'@'KIT_BFV'_CI'D_TF_V;A< 6hen user item changes are mo%e! to
SAP item &ork area
****
Chapter 1= # A!IBA7' stan!s "or Business A!! 'ns
?ust ike ustomer 5its( BA7' hep hook custom enhancements to SAP "unctionaity.E-ample o/ a A!I3
'n transaction AT2 * Time Sheet 5ntry( HR &ishes to incu!e an interacti%e ackno&e!gment
that kno&ingy submitting incorrect !ata is groun!s "or !ismissa. This can be achie%e! using
BA7'
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 57/87
4eatures3
1& BA7')s are -b#ect -riente!
& They can be impemente! mutipe times
*& 't !oes not reuire SAP So"t&are hange Registration
)& /o e""ect on reease upgra!e! on the "unctioning o" BA7')s
!e/ine and Implement a API
These in%o%e! three steps
Step 1
• reating BA7' 7e"inition6 Transaction S51I.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 58/87
Step
• 7e"ine BA7' inter"ace6 Transaction S51M
Step *
• 7e"ine a cass impements the inter"ace6 7uring impementation creation( a cass "or
impementing the enhancement)s inter"ace is aso create!
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 59/87
;;;;
Chapter 1@ # All About AAP 8ueryThe ABAP Ouery appication is use! to create reports not area!y present in SAP system. 't
has been !esigne! "or users &ith itte or no kno&e!ge o" the ABAP programming.
ABAP Ouery o""ers users a broa! range o" &ays to !e"ine reports an! create !i""erent types o"
reports such as basic ists( statistics( an! ranke! ists.The ABAP Ouery comprises "our components6
1& 8ueries
& In/oSets
*& :ser 6roups
)& "ranslation o/ 8uery
:et)s ook into them in !etai6$
8ueries
The Oueries component is use! by en! users to maintain ueries. -ne can create ueries(
change ueries an! eecute ueries. Transaction SO01
In/oSets
• 'n"oSets are specia %ie&s o" !ata sources. An 'n"oSet !escribes &hich "ie!s o" a!ata source can be reporte! on in ueries. An 'n"oSet can be assigne! to se%era roes
or user groups.
Ad7antages#
• By creating 'n"oSets an! assigning them to roes or user groups( the system
a!ministrator !etermines the range o" reports that the in!i%i!ua appication
!epartments or en!$users are abe to generate using the SAP Ouery.
• 5n!$users are abe to &ork ony &ith those 'n"oSets that are ree%ant to their particuar area( as !esignate! by the roe or user group that they are assigne! to.
:SE; 6roups
• The Cser Groups component is use! to maintain user groups "rom a security stan!point3.
• Csers &orking in the same appication are assigne! to the same user group. 't !oes not
matter &ho actuay !e"ine! a uery in a user group. 5%ery user assigne! to the user
group is abe to eecute the uery.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 60/87
• Csers in a user group nee! to ha%e the necessary authoriKations be"ore they are abe to change
or re!e"ine a uery.5%ery user in a system can be assigne! to se%era user groups.
"ranslation(8:E;9 Component
• A ot o" tets are generate! &hen !e"ining ueries( 'n"oSets( an! user groups. These
tets are !ispaye! in the anguage that &e chose &hen &e og on to the SAP system.e can compare the tet+anguages using this component.
!ata processing in 8ueries
7ata can be processe! an! presente! in , &ays6$
1& ASIC LIS" 6Presents !ata in the or!er !e"ine! by the "unctiona area supports
sorting an! summation3.
& S"A"IS"IC 6 Sho&s the statistica "igures cacuate! "rom the basic !ata.
*& ;ANE! LIS" 6 A ranke! ist is a speciaiation o" a statistic. 5. Top ten
customers o" a tra%e agency.
A uery can ha%e one basic ist( up to nine statistics an! up to nine ranke! ists.
C;EA"IN6 A 8:E;9
Step 1 Go to SO01. Gi%e a name to the uery an! cick on the reate button.
Step
Gi%e the !escription o" the uery in the net screen. Speci"y the output ength an!
seect the processing option "rom the 8urther Processing -ptions bo. The !ata can be!ispaye! in %arious "ormats such as tabe( !o&noa! to a "ie( an! !ispay in or! etc.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 61/87
Step *
ick on the net screen( seect the "ie! group to be use!.
Step )
ick on the net screen( seect the "ie!s you &ant !ispaye!
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 62/87
Step =
-n the net screen( seect the seection "ie!s an! then chose one o" the output types
basic( statistics( ranke!3.
'n each o" the ists( you can seect %arious options. eg. Sort or!er o" "ie!s( change
output ength( coumn coor( totas( page hea!er( page "ooter etc.3 .
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 63/87
Step @
A"ter pro%i!ing a the abo%e options you can sa%e the uery an! eecute it.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 64/87
/ote6
• Transaction to reate+>aintain 'n"oset $SO02
• Transaction to reate+>aintain CserGroup $SO0,
;;;;
hapter 1L $ SAP B7 * Batch 7ata ommunication
This hapter &i co%er the "oo&ing topics$
1& 'ntro!uction to B7.& >etho! o" Batch 'nput.
*& Batch 7ata Proce!ures.
)& riting B7 programs.
=& reating Batch input Session.
@& Batch 'nput Recor!ing.
:et)s BeginQ
Introduction to atch input
• Batch input is typicay use! to trans"er !ata "rom non$R+, systems to R+, systems or to
trans"er !ata bet&een R+, systems.
• 't is a !ata trans"er techniue that ao&s you to trans"er !atasets automaticay to screens
beonging to transactions( an! thus to an SAP system. Batch input is controe! by a batch
input session.
atch input session
• Groups a series o" transaction cas together &ith input !ata an! user actions . A batch
input session can be use! to eecute a !iaog transaction in batch input( &here some ora the screens are processe! by the session. Batch input sessions are store! in the
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 65/87
!atabase as !atabase tabes an! can be use! &ithin a program as interna tabes &hen
accessing transactions.
Points to note
• B7' &orks by carrying out norma SAP transactions #ust as a user &ou! but it eecute
the transaction automaticay. All the screen 7alidations and business logic 7alidation will be done while
using atch !ata Input&
• 't is suitabe "or entering arge amount o" !ata.
• /o manua interaction is reuire!
2ethods o/ atch Input
SAP pro%i!es t&o basic metho!s "or trans"erring egacy !ata in to the R+, System.
1& assica Batch 'nput metho!.
& a Transaction >etho!.
assica Batch 'nput metho!
• 'n this metho! an ABAP+4 program rea!s the eterna !ata to the SAP System an! stores
in a batch input session.• A"ter creating the session( you can run the session to eecute the SAP transaction in it.
• This metho! uses the "unction mo!ues ;D(_ F<'NG ;D(_IN'@T an! ;D(_(F'
• Batch 'nput Session can be process in , &ays
• 'n the "oregroun!
• 'n the backgroun!
• 7uring processing( &ith error !ispay
• Dou shou! process batch input sessions in the "oregroun! or using the error !ispay i"
you &ant to test the !ata trans"er.
• '" you &ant to eecute the !ata trans"er or test its per"ormance( you shou! process the
sessions in the backgroun!.
• Points to note about assica Batch 'nput metho!
• Asynchronous processing
• Trans"er !ata "or mutipe transactions.
• Synchronous !atabase up!ate.
• A batch input process og is generate! "or each session.
• Session cannot be generate! in parae.
Call "ransaction 2ethod&
• 'n this metho! ABAP+4 program uses A:: TRA/SAT'-/ CS'/G statement to run
an SAP transaction.
• 5ntire batch input process takes pace onine in the program
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 66/87
Points to Note3
• 8aster processing o" !ata
• Synchronous processing
• Trans"er !ata "or a singe transaction.
• /o batch input processing og is generate!.
atch Input Procedures
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 67/87
• Dou &i typicay obser%e the "oo&ing seuence o" steps to !e%eop Batch 'nput "or
your organiation
• Anaysis o" the egacy !ata. 7etermine ho& the !ata to be trans"erre! is to be mappe! into the SAP Structure. Aso take note o" necessary !ata type or !ata ength con%ersions.
• Generate SAP !ata structures "or using in eport programs.
• 5port the !ata in to a seuentia "ie. /ote that character "ormat is reuire! by pre!e"ine! SAP batch input programs.
• '" the SAP suppie! B7 programs are not use!( co!e your o&n batch input program.
hoose an appropriate batch input metho! accor!ing to the situation.
• Process the !ata an! a!! it to the SAP System.
• Anaye the process og. 8or the A:: TRA/SAT'-/ metho!( &here no proper og is
create!( use the messages coecte! by your program.
• 8rom the resuts o" the process anaysis( correct an! reprocess the erroneous !ata.
'riting !C program• Dou may obser%e the "oo&ing process to &rite your B7 program
• Anaye the transactions3 to process batch input !ata.
• 7eci!e on the batch input metho! to use.
• Rea! !ata "rom a seuentia "ie
• Per"orm !ata con%ersion or error checking.
• Storing the !ata in the batch input structure( B77ATA.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 68/87
• Generate a batch input session "or cassica batch input( or process the !ata !irecty
&ith A:: TRA/SAT'-/ CS'/G statement.
Batch 'nput 7ata Structure7ecaration o" batch input !ata structure
7ATA6 B5G'/ -8 Eb!c tabeF
-CRS Eoccurs parametersF.'/:C75 STRCTCR5 B77ATA.
7ATA6 5/7 -8 Eb!c tabeF.
4ield name "ype Length !escription
PR-GRA> HAR I >o!ue poo
7D/PR- /C> 4 7ynpro number
7D/B5G'/ HAR 1 Starting a !ynpro8/A> HAR , 8ie! name
8@A: HAR I0 8ie! %aue
The or!er o" "ie!s &ithin the !ata "or a particuar screen is not o" any signi"icance
Points to /ote
• hie popuating the B7 7ata make sure that you take into consi!eration the usersettings. This is especiay ree%ant "or "iing "ie!s &hich in%o%es numbers :ike
uantity( amount 3. 't is the user setting &hich !eci!es on &hat is the groupingcharacter "or numbers 5.g.6 A number "i"ty thousan! can be &ritten as 0(000.00 or
0.000(00 base! on the user setting.
• on!ense the 8@A: "ie! "or amount an! uantity "ie!s so that they are e"t aigne!.
• /ote that a the "ie!s that you are popuating through B7 shou! be treate! as
character type "ie!s &hie popuating the B7 7ata tabe.
• 'n some screens &hen you are popuating %aues in a tabe contro using B7 youha%e to note ho& many number o" ro&s are present on a !e"aut sie o" the screen
an! co!e "or as many ro&s. '" you ha%e to popuate more ro&s then you ha%e to co!e
"or <Page !o&n= "unctionaity as you &ou! !o &hen you are popuating the tabecontro manuay.
• /umber o" ines that &ou! appear in the abo%e scenario &i !i""er base! on the
screen sie that the user uses. So a&ays co!e "or stan!ar! screen sie an! make yourB7 &ork a&ays in stan!ar! screen sie irrespecti%e o" &hat the user keeps his
screen sie as.
Creating atch Input Session
• -pen the batch input session using "unction mo!ue B7-P5/GR-CP.
• 8or each transaction in the session6
• 8i the B77ATA &ith %aues "or a screens an! "ie!s processe! in the
transaction.
• Trans"er the transaction to the session &ith B7'/S5RT.
• ose the batch input session &ith B7:-S5GR-CP
atch Input ;ecorder
• Batch input recor!er System F Ser%ices F Batch input F Recor!er3 recor!s
transactions &hich are manuay entere! an! creates a batch input session &hich can
be eecute! ater using S>,.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 69/87
• Begin the batch input recor!er by seecting the Recor!ing pushbutton "rom the batch
input initia screen.
• The recor!ing name is a user !e"ine! name an! can match the batch input session
name &hich can be create! "rom the recor!ing.
• 5nter a SAP transaction an! begin posting the transaction.
• A"ter you ha%e compete! posting a SAP transaction you either choose Get
Transaction an! Sa%e to en! the recor!ing or /et Transaction an! post another
transaction.
•
-nce you ha%e sa%e! the recor!ing you can create a batch input session "rom therecor!ing an!+or generate a batch input program "rom the recor!ing.
• The batch input session you create! can no& be anaye! #ust ike any other batchinput session.
• The program &hich is generate! by the "unction o" the batch input recor!er is a
po&er"u too "or the !ata inter"ace programmer. 't pro%i!es a soi! base &hich canthen be atere! accor!ing to customer reuirements.
;;;;
Chapter 1+ # 'hat is E!I, ALE and i!%C>57'( stan!s "or 5ectronic 7ata 'nterchange( is the eectronic echange o" structure!
business !ata bet&een !i""erent appications.
57' Architecture
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 70/87
57' Architecture consists o" $
• E!I#enabled applications6 They support the automatic processing o" business
transactions.
• "he I!oc inter/ace6 This &as !esigne! as an open inter"ace. The '7oc inter"ace
consists o" '7oc types an! "unction mo!ues that "orm the inter"ace to theappication.
• "he E!I subsystem6 This con%erts the '7oc types into 57' message types an! %ice
%ersa. This component o" the 57' architecture is not suppie! by SAP.
A!%antages o" 57' process
• Re!uce! !ata 5ntry 5rrors
• Re!uce! Processing cyce time
• A%aiabiity o" !ata eectronic "orm
• Re!uce! Paper ork
• Re!uce! ost
• Re!uce! 'n%entories an! Better Panning
• Stan!ar! >eans o" ommunicating
• Better Business Processes• ompetiti%e A!%antage
'hat is ALE>
A:5 supports the !istribution o" the business "unctions an! process across oosey coupe!
SAP R+, systems !i""erent %ersions o" SAP R+,3. A connection "rom R+2 an! non$SAP systems
is aso supporte!.
A:5 supports$
• 7istribution o" appications bet&een !i""erent reeases o" R+, Systems
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 71/87
• ontinue! !ata echange a"ter a reease upgra!e &ithout reuiring specia
maintenance
• ustomer$speci"ic etensions.
• ommunication inter"aces that ao& connections to non$SAP systems.
• ouping o" R+, an! R+2 Systems.
!i//erence between ALE and E!I>• A:5 is use! to support !istribute! yet integrate! processes across se%era SAP
systems &hereas 57' is use! "or the echange o" business !ocuments bet&een thesystems o" business partners cou! be non$SAP systems3
• A:5 is SAP)s technoogy "or supporting a !istribute! en%ironment &hereas 57' is a
process use! "or echange o" business !ocuments &hich no& ha%e been gi%en a
stan!ar! "ormat
• Both A:5 an! 57' reuire !ata echange. An '!oc is a !ata container &hich is use!
"or !ata echange by both 57' an! A:5 processes.
'hat is I!%C>
• '7- is simpy a !ata container use! to echange in"ormation bet&een any t&o
processes that can un!erstan! the synta an! semantics o" the !ata.
• 'n simpe &or!s( an i!oc is ike a !ata "ie &ith a speci"ie! "ormat &hich isechange! bet&een 2 systems &hich kno& ho& to interpret that !ata.
• '7- stan!s "or= 'nterme!iate 7ocumentH
• hen &e eecute an outboun! A:5 or 57' Process( an '7- is create!. 'nan inbound A:5 or 57' process( an '7- ser%es as input to create an appication
!ocument. 'n the SAP System( '7-s are store! in !atabase. 5%ery '7- has
an uniue number &ithin a cient3.
• '7-s are base! on 57' stan!ar!s( A/S' AS 12 an! E!I4AC". 'n case o" anycon"ict in !ata sie( it a!opts one &ith greater ength. '7-s are in!epen!ent o" the
!irection o" !ata echange e.g. -R75RS016 Purchasing mo!ue6 'nboun! an!
-utboun!. '7-s can be %ie&e! in a tet e!itor. 7ata is store! in character "ormatinstea! o" binary "ormat. '7-s are in!epen!ent o" the sen!ing an! recei%ing
systems.SAP$to$SAP as &e as /on$SAP3
;;;;
Chapter 1B # I!%C3 !e/inition, Architecture, Implementation'hat is an I!%C>
• '7- is simpy a !ata container use! to echange in"ormation bet&een any t&o
processes that can un!erstan! the synta an! semantics o" the !ata.
•'n other &or!s( an '7- is ike a !ata "ie &ith a speci"ie! "ormat &hich isechange! bet&een 2 systems &hich kno& ho& to interpret that !ata.
• '7- stan!s "or= 'nterme!iate 7ocumentH
• hen &e eecute an outboun! A:5 or 57' Process( an '7- is create!.
• 'n the SAP System( '7-s are store! in !atabase. 5%ery '7- has an uniue
number &ithin a cient3.Key 8eatures
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 72/87
• '7-s are in!epen!ent o" the sen!ing an! recei%ing systems&SAP$to$SAP as &e as
/on$SAP3
• '7-s are base! on 57' stan!ar!s( A/S' AS 12 an! 57'8AT. 'n case o" anycon"ict in !ata sie( it a!opts one &ith greater ength.
• '7-s are in!epen!ent o" the !irection o" !ata echange e.g. -R75RS01 6
Purchasing mo!ue 6 'nboun! an! -utboun!• '7-s can be %ie&e! in a tet e!itor. 7ata is store! in character "ormat instea! o"
binary "ormat.
Structure o/ an I!%C
The '!oc structure consists o" , parts $
1& "he administration part DControl ;ecord$ &hich has the type o" i!oc( message
type( the current status( the sen!er( recei%er etc. This is re"erre! to as the ontro
recor!.& "he application data D!ata ;ecord – hich contains the !ata. These are cae!
the !ata recor!s+segments.
*& "he Status in/ormation DStatus ;ecord# These gi%e you in"ormation about the
%arious stages the i!oc has passe! through.
Dou can %ie& an '7- using transaction 502 or 50
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 73/87
As seen in screenshot abo%e '7- recor! has three parts ontro( 7ata an! Status. :et)s
ook into them in !etai $
ontro Recor!
• A contro recor! !ata is store! in 57'7 tabe. The key to this tabe is the '7-
/umber
• 't contains in"ormation ike '7- number( the !irection inboun!+outboun!3( sen!er(
recipient in"ormation( channe it is using( &hich port it is using etc.
• 7irection )1Z in!icates outboun!( )2Z in!icates inboun!.
7ata Recor!
• 7ata recor! contains appication !ata ike empoyee hea!er in"o( &eeky !etais( cient
!etais etc
• A !ata recor! !ata is store! in 57'72 to 57'74 tabes an! 57'77 is a structure &here
you can see its components.
• 't contains !ata ike the i!oc number( name an! number o" the segment in the i!oc( thehierarchy an! the !ata
• The actua !ata is store! as a string in a "ie! cae! S7ATA( &hich is a 1000 char ong
"ie!.
Status Recor!
Status recor!s are attache! to an '7- at e%ery miestone or &hen it encounterserrors.
A status recor! !ata is store! in 57'7S tabe.
Statuses 1$42 are "or outboun! &hie 0$L "or inboun!
I!%C "ypes
An '7- Type Basic3 !e"ines the structure an! "ormat o" the business !ocument that is to
be echange!. An '7- is an instance o" an '7- Type( #ust ike the concept o" %ariabes an!
%ariabes types in programming anguages. Dou can !e"ine '7- types using 'E*?
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 74/87
'hat is a Segment>
• Segment !e"ines the "ormat an! structure o" a !ata recor! in '7-. Segments arereusabe components.
• 8or each segment SAP creates
1& Segment Type %ersion in!epen!ent3
& Segment 7e"inition %ersion !epen!ent3*& Segment 7ocumentation
• The ast , characters is the %ersion o" the segment
• 7e"initions keep changing as per the %ersion but the segment type remains the same.Transaction6 'E*1
'hat is E-tension I!%C type>
An '7- is o" 2 types6$
1& Basic
& 5tension
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 75/87
SAP pro%i!es many a pre$!e"ine! Basic '7- Types &hich cannot be modi/ied. 'n case you&ant to a!! more !ata to these restricte! basic type you may use an etension type. >ost o" the
times you &i N%" use etension.
!ocumentation
5ach '7- are thoroughy !ocumente! in transaction 50
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 76/87
2essage "ype
• A message represents a speci"ic type o" !ocument that is transmitte! bet&een t&o
partners 5. -r!ers( or!ers responses( in%oices etc.
• An i!oc type can be associate! &ith many message types
• Aso a message type can be associate! &ith !i""erent i!oc types. Transaction 'E+1
I!%C $iews
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 77/87
• An '7- type can be use! "or more than one message type( &hich resuts in '7-s
containing more "ie!s than reuire! "or a particuar message type.
• '7- %ie&s are use! to impro%e per"ormance in generating '7-s to ensure ony theree%ant segments are "ie! &ith !ata.
• '7- @ie&s are important ony "or -utboun! Processing.
Partner Pro/iles
• A partner is !e"ine! as a business partner &ith &hom you con!uct business an!
echange !ocuments
• 'n the partner pro"ie o" a partner that &e echange '!ocs &ith( &e maintain the
parameters that are necessary "or echanging the !ata. The transaction use! is 520.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 78/87
Port
• The port !e"ines the technica characteristics o" the connection bet&een your SAP
system an! the other system you &ant to trans"er !ata &ith subsystem3. The port
!e"ines the me!ium in &hich !ata is echange! bet&een the 2 systems.
• There are !i""erent types o" ports. The 2 most commony use! are the ";4C ports use!in A:5 an! 8ie ports &hich 57' uses.
• 8or TR8 ports &e ha%e to gi%e the name o" the ogica !estination create!
using S>M.
• hen using "ie port you can speci"y the !irectory &here the '7- "ie shou! be
pace!. The other system or the mi!!e&are &i pick up the "ie "rom here. The
8unction mo!ue can be use! to generate a "ie name "or the i!oc. hie testing youcan use <-utboun! "ie= to speci"y a constant "ie name. The tab <outboun! trigger=
can be use! to suppy in"ormation i" &e &ant to trigger some processing on the
subsystem &hen an i!oc is create! at this ocation. e ha%e to speci"y the comman!
"ie name an! the !irectory &hich has to be run.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 79/87
This is &o -/8CS'/GQ
:et)s un!erstan! the process o" creating an '7- &ith an eampe $
• hene%er a Purchase -r!er P-3 is create! &e &ant to sen! the '7- to a %en!or.
• The P- is sent in the "orm o" an '7- to the %en!or partner3. That partner has to be
57' enabe! in that system. SAP shou! reaie that it cou! sen! !oc to this %en!oreectronicay.
• The P- sent as an outboun! i!oc by the customer &i be inboun! i!oc "or the
%en!or. The SAP system on the %en!ors si!e can process this to create an appication!ocument a saes or!er3 on their system.
• Ouotation( R8O( P-( S-( 'n%oice( !ei%ery note etc are some o" the commony
echange! !ocuments through '7-
• The process o" !ata trans"er out o" your SAP system is cae! the %utbound process(
&hie that o" !ata mo%ing into you SAP system is cae! Inbound process. As a
!e%eoper or a consutant &ho &i be in%o%e! in setting up theses process "or yourorganiation. Here are the steps ho& to set them up$
"he %utbound Process
Steps 'n%o%e! $
• reate segments5,13
•reate an i!oc type5,03
• reate a message type 5I13
• Associate a message type to i!oc type5I23
• reate a port5213
• '" you are going to use the message contro metho! to trigger i!ocs then create the"unction mo!ue "or creating the i!oc an! associate the "unction mo!ue to an
outboun! process co!e
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 80/87
• -ther&ise create the "unction mo!ue or stan!aone program &hich &i create the
i!oc
• reate a partner pro"ie 5203 &ith the necessary in"ormation in the outboun! parameters "or the partner you &ant to echange the i!oc &ith. Trigger the i!oc.
"he Inbound Process
Steps 'n%o%e!$• reation o" basic '!oc type Transaction 5,03
• reating message type Transaction 5I13
• Associating the >essage type to basic '!oc type Transaction 5I23
• reate the "unction mo!ue "or processing the i!oc
• 7e"ine the "unction mo!ue characteristics B713
• Aocate the inboun! "unction mo!ue to the message type5L3
• 7e"ining process co!e Transaction 5423
• reation o" partner pro"ie Transaction 5203
;;;;
Chapter ? # All About API• BAP's are stan!ar!ie! programming inter"aces metho!s3 enabing eterna
appications to access business processes an! !ata in the R+, System. They pro%i!e
stabe an! stan!ar!ie! metho!s to achie%e seamess integration bet&een the R+,System an! eterna appications( egacy systems an! a!!$ons.
• BAP's are !e"ine! in the B-R Business ob#ect repository3 as metho!s o" SAP
business ob#ect types that carry out speci"ic business "unctions. They are
impemente! as ;4C#enabled /unction mo!ues an! are create! in the 8unction Bui!ero" the ABAP orkbench.
•Some BAP's an! metho!s pro%i!e basic "unctions an! can be use! "or most SAPBusiness -b#ects. These are cae! STA/7AR7'J57 BAP')s.
List o/ StandardiKed APIs6
1& BAP's "or Rea!ing 7ata * Get:ist3 ( Get7etai3 ( GetStatus3 ( 5istenceheck3
& BAP's "or reating or hanging 7ata$ reate3 (hange3(7eete3 an! Cn!eete3 (
*& BAP's "or >ass Processing $hange>utipe3( reate>utipe3( 7eete>utipe3.
0ow to create a API
Step 1.
• Go to transaction s&01 Toos$FBusiness 8rame&ork $F BAP' 7e%eopment
$FBusiness -b#ect bui!er3 .
• Seect the business ob#ect( accor!ing to the "unctiona reuirement "or &hich the
BAP' is being create!.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 81/87
Step&
• -pen the business ob#ect in change mo!e. Then Seect Ctiities $FAP' >etho!s
$FA!! metho!.
• Then enter the name o" the "unction mo!ue an! seect ontinue.
Step *
'n the net !iaog bo( "oo&ing in"ormation nee!s to be speci"ie!6
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 82/87
1& 2ethod 3 Suggest an appropriate name "or the metho!(
& "e-ts 6 5nter !escription "or the BAP'
*& ;adio buttons3 7iaog( Synchronous( an! 'nstance$in!epen!ent.BAP'Us are usuay impemente! synchronousy.
Step )
• To create the metho! seect Des in the net !iaog bo.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 83/87
Step=
• A"ter the program has been generate! an! eecute!( check the program in themetho! #ust create!. Thus( a BAP' is create!.
"esting the API
• Dou can test the BAP' by testing the in!i%i!ua metho! o" the Business -b#ect in theBusiness -b#ect Bui!er.
or one can use the transaction USC7) to test the metho!3.
;eleasing and /reeKing the API
• To reease the BAP'( "irst reease the "unction mo!ue using transaction se,L3 .
• Set the status o" the metho! to Ureease!) in the Business -b#ect Bui!er using
transaction So1 * 5!it$F change status$F reease!.3
• Dou can aso use the BAP' 5porer Transaction co!e BAP'3 "or ,0Z %ie& on
BAP'
;;;;
Chapter 1 # ;4C'hat is ;4C>
• A Remote 8unction aR83 is a ca to a "unction mo!ue running in a system
!i""erent "rom the caer)s. The remote "unction can aso be cae! "rom &ithin the
same system as a remote ca3.The R8 inter"ace pro%i!es the abiity to ca remote
"unctions.
• R8 consists o" t&o inter"aces6
1. A caing inter"ace "or ABAP Programs
2. A caing inter"ace "or /on$SAP programs.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 84/87
Any ABAP program can ca a remote "unction using the CALL 4:NC"I%NM!ES"INA"I%N
statement. The !ES"INA"I%N parameter tes the SAP System that the cae! "unction runs in a
system other than the caer)s.Synta$
(A C>N(TIFN remotefunctionL
D'TINATIFN #e&t 'K<F@TIN/ f1 =
IB<F@TIN/ f =
TA;' t1 =
'K('<TIFN
:ogica 7estinations are !e"ine! %ia transaction S>M an! store! in Tabe R875S
8unctions o" the R8 inter"ace
• on%erting a parameter !ata to the representation nee!e! in the remote system
• aing the communication routines nee!e! to tak to the remote system.
• Han!ing communications errors( an! noti"ying the caer( i" !esire! using55PT'-/S paramater o" the A:: 8C/T'-/3.
Types o" R81. Synchronous ;4C * The caing program continues the eecution ony a"ter the
cae! "unction is compete.
2. Asynchronous ;4C * The caing program continues the eecution &ithout &aiting
"or return "rom the cae! "unction.
,. "ransactional ;4C $ The cae! "unction mo!ue is eecute! eacty once in theR8 target system. 5ach "unction ca is seen as a transaction in the target system.
Transactiona R8s use the su""i '/ BAKGR-C/7 TASK. 5g. 6 A::
8C/T'-/ Uremote"unction) '/ BAKGR-C/7 TASK
0ow to Code an ;4C>
1. 'n the "unction mo!ue attributes tab transaction co!e S5,L3( set the processing type
as Remote$enabe! mo!ue to create a remote "unction mo!ue.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 85/87
2. rite the co!e "or the "unction mo!ue.
,. 7e"ine the !estination o" the R8 ser%er in the R8 cient system that cas the
remote "unction %ia S>M transaction3.
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 86/87
4. !eclaring Parameters6 A parameter "ie!s "or a remote "unction mo!ue must be
!e"ine! as re"erence "ie!s( that is( ike ABAP 7ictionary "ie!s.. E-ceptions3 The system raises ->>C/'AT'-/8A':CR5 an!
SDST5>8A':CR5 internay. Dou can raise eceptions in a remote "unction #ust
as you &ou! in a ocay cae! "unction.
!ebugging ;emote 4unction Calls
• 't is not possibe to !ebug a remote "unction ca to another system.
• Ho&e%er( &hen testing ABAP$to$ABAP R8 cas( you can use the ABAP !ebugger
to monitor the eecution o" the R8 "unction in the remote system.
• ith remote cas( the ABAP !ebugger incu!ing the !ebugging inter"ace3 runs on
the oca system. 7ata %aues an! other run in"ormation "or the remote "unction are passe! in "rom the remote system.
;;;;
8/13/2019 Abap in 4 Hours
http://slidepdf.com/reader/full/abap-in-4-hours 87/87
About the Author
Krishna is a omputer 5ngineer an! a SAP onsutant. He has o%er I years o" eperience&orking "or many >/)s. Recenty ( he uit is cushy #ob an! is on a mission to make e!ucation
"un an! "ree. This book is a step in that !irection
onnect &ith CST&itter 6 http6++t&itter.com+SAPTHub
8acebook6 http6++&&&."acebook.com+pages+Sap$Training$Hub+1,M,2210M2I4
Bog6 http6++&&&.saptraininghub.com+