Abap in 4 Hours
Abap in 4 Hours
Published by SapTrainingHub.com Copyright 2012 Krishna Rungta Smashwords Edition Smashwords Edition, License Notes This ebook is icense! "or your persona en#oyment on y. This ebook may not be re$so ! or gi%en a&ay to other peop e. '" you &ou ! ike to share this book &ith another person( p ease 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 on y( then p ease return to Smash&or!s.com an! purchase your o&n copy. Thank you "or respecting the har! &ork o" this author..
Chapter 1 Introduction to A AP
ABAP stan!s "or * A!%ance! Business App ication Programming. 't is a programming anguage "or !e%e oping app ications "or the SAP R+, system. The atest %ersion o" ABAP is ca e! ABAP -b#ects an! supports ob#ect$oriente! programming. SAP &i run app ications &ritten using ABAP+4( the ear ier ABAP %ersion( as &e as app ications using ABAP -b#ects. .ithout "urther a!o( et)s !i%e into ABAP./ote( this 0hapter &i not go into e1tensi%e !etai s on ABAP anguage constructs 2&hich become %ery boring to rea!3 but 4uick y intro!uce key concepts to get you starte! so you can "ocus your attention on more important topics. !ata "ypes Synta1 to !ec are a %ariab e in ABAP $ DATA Variable_Name Type Variable_Type. 51amp e6 DATA employee_number Type I. The "o o&ing is a ist o" 7ata Types supporte! by ABAP
# Assigning
$alues
a=16. move 16 to a. write a to b. # Arithmetic %perations compute a = a*100. Control Statements 8o o&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.. %.. %..
'n#w)ile. Do loop Do ,n. time&. %.. %.. 'n##o. Logical %perator A li&t of lo-ical operator& /' or .= /T or . 0' or ,= 0T or , '1 or = N' or ,. A AP() Editor 8ina y( here is &here you &i spent most o" your time as a !e%e oper creating + mo!i"ying programs. Transaction SE*+
;;;;
Support "or so"t&are !e%e opment Support "or !ocumentation 5nsuring that !ata !e"initions are " e1ib e an! up$to$!ate
-b#ects in the ABAP 7ictionary resi!e! on three e%e s that support their re$usabi ity. These e%e s are6 Tab es an! structures 7ata e ements 7omains :et)s ook into them in !etai $ !omains 7escribes the technica characteristics o" a tab e "ie ! Speci"ies a %a ue range &hich !escribes a o&e! !ata %a ues "or the "ie !s 8ie !s re"erring to the same !omain 2%ia the !ata e ements assigne! to them3 are change! &hen a change is ma!e to the !omain 5nsures consistency '". Purchasing !ocument number 25B5:/3
!ata Elements 7escribes the ro e p aye! by a "ie ! in a technica conte1t 8ie !s o" same semantic meaning can re"er to the same !ata e ement 0ontains the "ie ! in"ormation E-. Purchasing !ocument number 25B5:/3
"ables Represent the 7atabase Tab es &here !ata actua y resi!es. Tab es can be !e"ine! in!epen!ent y o" the !atabase in the ABAP 7ictionary. The "ie !s o" the tab e are !e"ine! &ith their 2!atabase$in!epen!ent3 SAP ABAP !ata types an! engths.
Structures Are recor! !ec arations that !o /-T correspon! to a 7atabase Tab e. ?ust ike user$!e"ine! !ata type. 7e"ine! ike a tab e an! can then be a!!resse! "rom ABAP programs. Structures contain !ata on y !uring the runtime o" a program.
Aggregated %b.ects o/ A AP !ictionary Aggregate! means consisting o" se%era components. 'n the ABAP 7ictionary( aggregate! ob#ects are ob#ects &hich come "rom se%era !i""erent transparent tab es. @ie&s Search He p :ock -b#ects :et)s ook into them in !etai $iews @ie&s in SAP A ABAP are use! to summariBe !ata &hich is !istribute! among se%era tab es The !ata o" a %ie& is not actua y physica y store!. The !ata o" a %ie& is instea! !eri%e! "rom one or more other tab es 't is tai ore! to the nee!s o" a speci"ic app ication
Search 0elp A Search he p is a too to he p 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
Loc1 %b.ects Simu taneous accessing o" the same !ata recor! by t&o users in the SAP system is synchroniBe! by a ock mechanism. :ocks are set an! re ease! by ca ing certain "unction mo!u es. These "unction mo!u es are generate! automatica y "rom the !e"inition o" so$ca e! 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
'mportant Transactions 6'11 7 Data Dictionary Initial 6creen 86'1* Di&play only9 6'1: 7 A;A< Dictionary 7 Tec)nical 6ettin-& 6'1= 7 Databa&e >tility 6'1? 7 @epo&itory Information 6y&tem 6'16 7 Data ;row&er 6'1A 7 /eneral table Di&play 6'?? 7 Table View Baintenance 6B:0 7 Table Baintenance ;;;;
:et)s ook into each o" them in !etai 6 SAP# A AP 2acro '" you &ant to reuse the same set o" statements more than once in a program( you can inc u!e them in a macro. Dou can on y use a macro &ithin the program in &hich it is !e"ine!( an! it can on y be ca e! in ines o" the program "o o&ing its !e"inition. >acros can be use"u "or ong ca cu ations or comp e1 .R'T5 statements. Synta1 D'CIN' ,macro_name. DBacro 6tatement& 'NDEFCED'CINITIFN Bacro& can u&e <arameter& &N w)ere N = 1G*G:% '"ample7E DATA7 number1 TH<' I VA0>' 1. DEFINE increment. ADD 1 to I1. +@IT' I1. 'NDEFCED'CINITIFN. Increment number1. +@IT' number1. Futput7 * Include Programs 'nc u!e Programs are so e y "or mo!u ariBing source co!e( an! ha%e no parameter inter"ace. 'nc u!e programs a o& you to use the same source co!e in !i""erent programs. They can be use"u i" you ha%e engthy !ata !ec arations that you &ant to use in !i""erent programs. SyntaInclu#e ,inclu#e pro-ram Name. Points to Note 'nc u!e programs cannot ca themse %es. 'nc u!e programs must contain comp ete statements. E-ample6 IN(0>D' JI0K000=. +@IT'7 $ D>&erLG 6HE>NAB'G$ DDateLG 6HEDAT>B. ================================ <@F/@AB J@<B0001. IN(0>D' JI0K000=. Subroutines Subroutines are proce!ures that you can !e"ine in any ABAP program an! a so ca "rom any program. Subroutines are norma y ca e! interna y( that is( they contain sections o" co!e or a gorithms that are use! "re4uent y oca y. '" you &ant a "unction to be reusab e throughout the system( use a "unction mo!u e. 6ynta"E CF@B ,6ubroutine. ,pa&&.!. ,6tatement bloc5.. 'NDCF@B. ,6ubroutine. = Name of t)e &ubroutine
,pa&&. = <arameter& bein- pa&&e# Types o" Subroutines Internal Subroutine !e"ine! in same program being ca e!. 0an access a the !ata ob#ects !ec are! in the main ABAP+4 program. E-ternal Subroutine !e"ine! outsi!e the program being ca e!. /ee! to use the EpassF option or !ec are !ata ob#ects in common parts o" memory. 0a ing 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. 51terna Subroutines <'@CF@B ,&ubroutine.8,<ro-ram.9 ,pa&&.!. <'@CF@B ,&ubroutine. 8,<ro-ram.9 ,pa&&.! IC CF>ND!. <'@CF@B 8,&ubroutine.9 IN <@F/@AB 8,<ro-ram.9 ,pa&&.! IC CF>ND!. <'@CF@B ,in#e". FC ,&ubroutine1. ,&ubroutine*. ,&ubroutine:. ,pa&&.!. Points to /ote /este! ca s are a o&e! in subroutines 2i.e. P5R8-R> &ithin a 8-R> 9 5/78-R> 3. Recursi%e ca s are a so possib e. To !e"ine oca !ata( use the 7ATA statement a"ter 8-R> . 5ach time you enter the subroutine( the !ata is recreate! 2&ith an initia %a ue3 an! re ease! at the en! 2"rom the stack3. To !e"ine g oba !ata use! &ithin a subroutine( use the :-0A: statement a"ter 8-R> . The %a ues are sa%e! &hen you enter the subroutine an! then re ease! at the en! 2"rom the stack3 4unction 2odules 8unction >o!u es are genera purpose ABAP+4 routines that anyone can use. 'n"act ( there are a arge number o" stan!ar! "unction >o!u es a%ai ab e. 8unction >o!u es are organiBe! into 8unction Groups6 0o ections o" ogica y re ate! "unctions. A 8unction mo!u e a &ays be ongs to a 8unction Group. 6ynta"E C>N(TIFN ,function mo#ule. ,6tatement&. 'NDC>N(TIFN. 'mportant in"ormation Associate! &ith 8unction >o!u e
A!ministration 'mport+0hanging+51port parameters. Tab e Parameters+51ceptions. 7ocumentation Source co!e * L<fgrp>U ! . E"grpF is the 8unction Group G oba 7ata * L<fgrp>"#$ .G oba !ata "or the "unction group$ Accessib e across "unction mo!u es in the "unction group. >ain Program * %&$L<fgrp> . 0ontains the ist o" a the inc u!e "i es "or that "unction group
0a a 8unction >o!u e To ca a "unction mo!u e( use the 0A:: 8C/0T'-/ statement6 (A00 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;0'6 f1 = a 1.... f n = a n! 'K('<TIFN6 e1 = r 1.... e n = r n '@@F@_B'66A/' = r '! FTM'@6 = ro!!. 4unction 6roups 8unction groups are containers "or "unction mo!u es. 'n"act( there are a arge number o" stan!ar! 8unction Groups. A o" the "unction mo!u es in a "unction group can access the g oba !ata o" the group. :ike e1ecutab e programs 2type 13 an! mo!u e poo s 2type >3( "unction groups can contain screens( se ection screens( an! ists. Points to /ote 8unction Groups cannot be e1ecute!. The name o" a "unction group can be up to 2H characters ong. .hen you create a "unction group or "unction mo!u e( the main program an! inc u!e programs are generate! automatica y. 8unction groups encapsu ate !ata. Ho& to create a 8unction Group 1. Goto Transaction S5I0. 2. Se ect Program in the 7rop7o&n. ,. .rite the name o" the 8unction Group That you &ant to create. Genera y Cser ma!e 8unction groups start &ith <J=. e.g. * EJA8C/0T'-/AGR-CPA/A>5F . Hit 5nter Key. 4. /ote that The T-P 'nc u!e is create by !e"au t i" the user checks the option o" creating a T-P inc u!e. Ho& to create a 8unction >o!u e 1. 0reate a "unction Group 2say <'(&L<3. 2. 0reate a "unction mo!u e( set the attributes ike 28unction group( App ication( Short Te1t an! Process Type3 an! Sa%e. ,. 'nc u!e "i e <L'(&LU != &i ha%e source co!e o" "irst "unction mo!u e. 4. 'nc u!e "i e <L'(&L"#$= &i ha%e g oba !ata. K. >ain program <%&$L'(&L= contains H. G oba !ata 'nc u!e "i e <L'(&L"#$< L. 8unction mo!u es inc u!e "i e <L'(&LU))< I. Cser !e"ine! 'nc u!e "i es <L'(&LF..=( <L'(&L#..= an! <L'(&LI..= M. 7e"ine inter"ace parameters an! 51ceptions 10. .rite the source co!e 11. Acti%ate 8unction >o!u e 12. Testing the 8unction >o!u e * Sing e Test N 7ebugging 1,. 7ocumenting an! Re easing a 8unction >o!u e That)s a to >o!u arity in ABAP.
;;;;
-inimi.e the %earch #0erhead Cse in!e1 "ie !s in the &here c ause .hen accessing !atabases( a &ays ensure that the correct in!e1 is being use! . +educe the Data/ase Load Bu""ering :ogica !atabases A%oi! repeate! !atabase access Using Interna, "a/,es to 1uffer +ecords To a%oi! e1ecuting the same S5:50T mu tip e times 2an! there"ore ha%e !up icate se ects3( an interna tab e o" type HASH57 can be use! to impro%e per"ormance. <<<<
"ypes o/ Internal "ables There are t&o types o" interna tab es. 'nterna tab es &ith H5A75R ine 'nterna tab es &ithout H5A75R ine. 'nterna Tab es &ith Hea!er :ine Here the system automatica y creates the &ork area. The &ork area has the same !ata type as interna tab e. This &ork area is ca e! the H5A75R ine. 't is here that a the changes or any o" the action on the contents o" the tab e are !one. As a resu t o" this( recor!s can be !irect y inserte! into the tab e or accesse! "rom the interna tab e !irect y. 'nterna Tab es &ithout Hea!er :ine 3 Here there is no &ork area associate! &ith the tab e. .ork area is to be e1p icit y speci"ie! &hen &e nee! to access such tab es. Hence these tab es cannot be accesse! !irect y. Creating Internal "ables There are many &ays to create an 'nterna Tab e. :et)s ook at them one by one$ 1. By Csing the Type Statement :et us no& create a 'nterna tab e 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<'6 7 be-in of lineG empno type IG empname8*09 type c G en# of line. The TDP5S statement creates a structure ,ine as !e"ine!.To actua y create an 'nterna Tab e ita/ use the "o o&ing comman!$ Data itab type line occur& 10. An interna tab e ita/ is create! &ith the structure o" ine.Besi!es !ec aring the structure o" an interna tab e( the -00CRS c ause a so !e"ines ho& many tab e entries are maintaine! in main storage2in this case 103. 51tra recor!s are &ritten out to paging area an! can a""ect per"ormance 2. By re"erring to another Tab e Dou can create an interna tab e by re"erring to an e1isting tab e. The e1isting tab e cou ! be a stan!ar! SAP tab e( a J tab e or another interna tab e. 6ynta"E Data ,f. ,type. wit) )ea#er line!. 51amp e$ DATA itab TH<' line F((>@6 10 wit) )ea#er line. Here an interna tab e ita/ is create! o" the type ine &ith a hea!er ine. P ease note <&ith hea!er ine= is optiona ,. By re"erring to e1isting Structure 6ynta"E
Data ,f. 0IN' ,&truct. occur& n wit) )ea#er line!. '"ampleE DATA itab 0IN' &line F((>@6 10. Here a tab e ita/ is create! ha%ing a structure same as that o" s ine 4. By creating a ne& Structure :et us no& create an interna tab e &ith a structure o" our o&n. Here the tab e is create! &ith an Hea!er ine( by !e"au t.Synta1 $ Data 7 ;e-in of ,f. occur& ,n.G ,component #eclaration.G %%%%%%%%%%%G 'n# of ,f.. '"ample E Data 7 ;e-in of itab occur& 10G column1 type IG column*8=9 type (G column: li5e maraEernamG 'n# of itab. 'nterna tab e ita/ is create! Populating Internal "ables /o& that &e ha%e success"u y create! some interna tab es( et us see ho& !o &e popu ate them &ith some recor!s. There are %arious metho!s a%ai ab e to popu ate tab es 1. Appen! 7ata ine by ine The "irst metho! a%ai ab e 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 tab e or &e can a!! one initia ine to the interna tab e. Synta1 $ A<<'ND ,wa. TF $ INITIA0 0IN' TF! ,itable.. Here &ork area <2a> or the 'nitia :ine is appen!e! to the interna tab e <ita/,e>.The system %ariab e %34"&1I) contains the in!e1 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 D D L0O An initia ine a!!s a ine initia iBe! &ith the correct %a ue "or its type to the tab e. Here ( co 1 is an integer an! co 2 is a character. Then APP5/7 initia ine ( a!!s a ine initia iBe! &ith respect to the !ata type o" the co umns( i.e. 0 "or 0o 1 an! space "or 0o 2. 2. Csing 0-::50T statement 0-::50T is another "orm o" statement use! "or popu ating the interna tab es. Genera y 0-::50T is use! &hi e inserting ines into an interna tab e &ith uni4ue stan!ar! key.Synta1$ (F00'(T ,wa. INTF! ,itable.. 'n case o" tab es &ith Hea!er ine( '/T- option is omitte!. Suppose there is a rea!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 tab e( but the numeric "ie !s o" both the entries are a!!e! an! on y one entry correspon!ing to the key
is present. @a ue o" SD$TAB'P is change! to the ro& o" the origina entry. 5 se 0-::50T acts simi ar to APP5/7 an! SD$TAB'P contains the in!e1 o" the processe! ine. ,& Csing '/S5RT statement '/S5RT statement a!!s a ine+&ork area to the interna tab e. Dou can speci"y the position at &hich the ne& ine is to be a!!e! by using the INDE) c ause &ith the '/S5RT statement.Synta1 IN6'@T ,wa. INTF $ INITIA0 0IN' INTF! ,itable. in#e" ,i#".!. Here( the &ork area <2a> or '/'T'A: :'/5 is inserte! into interna tab e Eita/,e> at in!e1 <id5>. Copying Internal "ables The contents o" one interna tab e can be copie! to another by using the APP5/7 :'/5S or '/S5RT :'/5S statement. A more simp er &ay is to use any o" the "o o&ing synta1)s. BFV' ,itab1. To ,itab*.. F@ ,itab1. = ,itab*.. These copy the contents o" 'TAB1 to 'TAB2. 'n case o" interna tab es &ith hea!er ine &e ha%e to use RS in or!er to !istinguish "rom &ork area. So( to copy contents o" interna tab es &ith hea!er ine the synta1 becomes( itab1RS T itab2RS. ;eading Internal "ables .e are no& "ami iar &ith the creation o" interna tab es an! popu ating them &ith !ata. .e &i no& see ho& !o &e actua y use the !ata or retrie%e the !ata "rom the interna tab es. 1& Csing :oop $5n! oop -ne o" the &ays o" accessing or rea!ing the interna tab e is by using :--P$5/7:--P. Synta1$ 0FF< AT ,itable. INTF ,wa.! %%%%%%%%%%%.. 'ND0FF<. Here &hen you say :--P AT 'TAB:5( then the interna tab e 'TAB:5 is rea! ine by ine. Dou can access the %a ues o" the co umns "or that ine !uring any part o" the :--P$5/7:--P structure. The %a ue o" the %34%U1+( is set to ?( e%en i" on y one recor! is rea!. 2& Csing R5A7 The other metho! o" rea!ing the interna tab e is by using the R5A7 statement. Synta1$ @'AD TA;0' ,itable. INTF ,wa.! IND'K ,i#".. This statement rea!s the current ine or ine as speci"ie! by in!e1 Ei!1F. The %a ue o" SD$ TAB'Pis the in!e1 o" the ine rea!. '" an entry &ith the speci"ie! in!e1 is "oun!( then SD$ SCBR0 is set to 0. '" the speci"ie! in!e1 is ess than 0( then run$time error occurs. '" the speci"ie! in!e1 e1cee!s tab e siBe then SD$SCBR0 is set to 4. !eleting Internal "ables There are many &ays "or !e eting ines "rom an interna tab e. 1. 7e eting ines in a oop. This is the simp est &ay "or !e eting ines. Synta1 D'0'T' ,ITA;0'.. This statement &orks on y &ithin a oop. 't !e etes the current ine. Dou can !e ete the ines in a oop con!itiona y by a!!ing the .H5R5 c ause. 2. 7e eting ines using the in!e1. This is use! to !e ete a ine "rom interna tab e at any kno& in!e1.Synta1 D'0'T' ,ITA;0'. IND'K ,IDK..
The ine &ith the in!e1 E'7PF is !e ete!. The in!e1 o" the "o o&ing ine is !ecremente! by 1. ;;;;
To han! e tab e contro s in ABAP programs( you must !ec are a contro in the !ec aration part o" the program "or each tab e contro using the "o o&ing statement6 (FNT@F06 ,ctrl. TH<' TA;0'VI'+ >6IN/ 6(@''N ,&cr. &here <ctr,> is the name o" the tab e contro on a screen in the ABAP program. The contro a o&s the ABAP program to rea! the attributes o" the tab e contro an! to in" uence the contro .Here( <scr> is the screen number &here the initia %a ues o" the tab e are oa!e!.0ursor Position "or a tab e contro can be set in "o o&ing &ays6At PB- you can set the cursor on a speci"ic "ie ! o" a speci"ic ro& o" a tab e contro . 6'T (>@6F@ CI'0D ,f. 0IN' ,lin. FCC6'T ,off.!
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 0ursor Position.At PA' you can rea! the current cursor position. /'T (>@6F@ CI'0D ,f. 0IN' ,lin. % 'n a!!ition to the in"ormation gi%en un!er 8in!ing -ut the 0ursor Position( "ie ! <,in> contains in"ormation on &hich ro& o" the tab e contro the cursor is current y on. Dou can a so use /'T (>@6F@ 0IN' ,lin.. To !etermine the ro& o" the tab e contro . %34%U1+( a o&s you to check i" the cursor is p ace! in a ro& o" a tab e contro .8or getting the correspon!ing ine o" the interna tab e6 /'T (>@6F@ line ,lin.. in# = ,table_control.Etop_line R ,lin. 4 1. @ea# table ,itab. in#e" in#. The system %ariab e step, $ contains the current tab e ine in!e1 in a oop 9 en! oop. Loopc * contains number o" ines %isib e in the tab e "o create a table control 1. A!! a tab e contro e ement to your screen 2. Gi%e a name to the tab e contro . 'n the ABAP program !ec are a structure &ith the same 2 0-/TR-:S Etc F type TAB:5@'5. CS'/G S0R55/ 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. 2'" you &ant it to pick it "rom !ictionary o" your program c ick the re e%ant puhbutton3.'n the "ie ! ist choose the "ie !s you &ant an! choose ok.0 ick in the tab e contro area.'" you &ant a se ection co umn( check the appropriate check bo1 in the attributes an! gi%e it a name. 0reate the "ie ! in the ABAP program. 'n the PB- you shou ! ha%e the statement 0FF< at ,itab. >6IN/ (FNT@F0 ,cntrl_name.. 'ND0FF<. In t)e <AI you &)oul# )ave. 0FF< at ,itab.. 'ND0FF<. 't is &ithin the oops that !ata trans"er happens bet&een the screen an! the interna tab e..hen you popu ate the interna tab e use 75S0R'B5 TAB:5 EitabF :'/5S Ecntr AnameF$ ines( to store the tota number o" ines in the contro . The 8'5:7 statement can be use! to contro &hen the !ata trans"er happens.To change the attributes o" in!i%i!ua ce s temporari y change the S0R55/ tab e in the PB-. Dou can change the attributes o" the structure create! by the 0-/TR-:S statement ,cntrl.Efi"e#_col& etc are t)e attribute& of t)e control ,cntrl.Ecol&Ein#e" etc are t)e attribute& of t)e column&. ,cntrl.Ecol&E&creenEinvi&ible etc are t)e &creen attribute& of eac) column. ;;;;
Cse! &hen reports !eman! a specia "ormat Cse! &hen the report has to be !o&n oa!e! "rom SAP to an 51ce sheet to be !istribute! across. Cse! &hen the report has to be mai e! to a particu ar person. 'mportant Points to /ote about Report Program Report Programs are a &ays 51ecutab e Programs. Program Type is a &ays 1. 5%ery Report program correspon!s to a particu ar App ication Type i.e. either &ith Sa es N 7istribution( 8' * 0- etc. 't can a so be 0ross App ication 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 6tan#ar# <a-e Mea#in- is use!. The ine siBe "or a particu ar report can be set by using the a!!ition lineE&iSe ,&iSe.. The ine count "or a particu ar 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 !isp ay any in"ormation or error message &e a!! a message c ass to the program using the a!!ition6 Be&&a-eEi# ,me&&a-e cla&& name.. >essage c asses are maintaine! in S5M1. There"ore an i!ea report program shou ! start &ith6 +eport <report name> no standard page heading ,ine4si.e <si.e> ,ine4count <n6n!7> message4id <message c,ass>. Selection Screen <Se ection screen= is the screen &here one speci"ies the input %a ues "or &hich the program shou ! run.The se ection screen is norma y generate! "rom the Parameters Se ect$-ptions 6ynta" %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 he ps one to !o !ynamic se ection. They can accommo!ate on y one %a ue "or one cyc e o" e1ecution o" the program.Synta1 7e"ining parameters as a !ata type $arameters p;id6< 7 type c. 7e"ining parameters ike a tab e "ie !. $arameter p;id ,i9e <ta/,e name>4<fie,d name>. Parameters can be 0heckbo1es as &e as Ra!iobuttons.
$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 istbo1. <arameter p_i# li5e ,table name.E,fiel# name. a& li&tbo" Se ect -ptions A Se ect$-ption is use! to input a range o" %a ues or a set o" %a ues to a program.Synta1 se,ect4options s;0/e,n for 0/a940/e,n. Dou can a so !e"ine a se ect option ike a %ariab e se,ect4options s;0/e,n for 0/a940/e,n no inter0a,s no4e5tension E7ents in an A AP ;eport Program ABAP report programs are e%ent !ri%en programs. The !i""erent e%ents in a report Program are6 :oa!$o"$program Triggers the associate! e%ent in an interna session a"ter oa!ing a program o" type 1( >( 8( or S. A so runs the associate! processing b ock once an! once on y "or each program an! interna session. The processing b ock :-A7$-8$PR-GRA> has rough y the same "unction "or an ABAP program o" type 1( >( 8 or S as a constructor has "or c asses in ABAP -b#ects 'nitia iBation This e%ent is e1ecute! be"ore the se ection screen is !isp aye!. 'nitia iBation o" a the %a ues. Dou can assign !i""erent %a ues other than the %a ues !e"au te! on the se ection screen. Dou can "i your se ection screen &ith some %a ues at runtime. At Se ection$Screen The e%ent is processe! &hen the se ection screen has been processe! 2at the en! o" PA' 3. @a i!ation N 0hecks o" inputte! %a ues happen here Start$o"$Se ection Here the program starts se ecting %a ues "rom tab es. 5n!$o"$se ection A"ter a the !ata has been se ecte! this e%ent &rites the !ata to the screen. 'nteracti%e 5%ents Cse! "or interacti%e reporting. 't is use! to create a !etai e! ist "rom a basic ist. 4ormatting the report ABAP a o&s the reports to be "ormatte! as the user &ants it to be. 8or e1amp e( <A ternate :ines= must appear in !i""erent co ors an! the <Tota s= ine shou ! appear in De o&. Synta1 Cormat (olor n Cormat (olor n Inten&ifie# Fn n may correspon! to %arious numbers P ease note that there are other a!!itions a ong &ith "ormat as &e CF@BAT (F0F@ FCC INT'N6ICI'D FCC INV'@6' FCC MFT6<FT FCC IN<>T FCC Interacti7e Programming
Csing 'nteracti%e Programming users can acti%e y contro the !ata retrie%a an! !isp ay o" !ata Cse! to create a !etai e! ist "rom a %ery basic ist The !etai e! !ata is &ritten on a secon!ary ist. The secon!ary ist may either comp ete y o%er ay the "irst screen or one can !isp ay it in a ne& screen The secon!ary ists can be themse %es interacti%e. The "irst ist may a so 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 !isp aye! in the repor the cursor changes to a Han! &ith an -utstretche! 'n!e1 "inger. An hotspot can be achie%e! using the 8-R>AT statement. Synta16 Cormat Mot&pot Fn 8Fff9. Hi!e This comman! he ps you to store the "ie ! names base! on &hich one &i be !oing "urther processing to get a !etai e! ist. 't is &ritten !irect y a"ter the .R'T5 statement "or a "ie !. .hen a ro& is se ecte! the %a ues get automatica y "i e! in the %ariab es "or "urther use. Synta16 Mi#e ,fiel#Ename.. Logical !atabases 'nstea! o" using <Se ect= 4ueries 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"i1. The !ata is se ecte! by another program an! one can access the !ata using /'T ,tableE name. comman! &hich p aces the !ata in the &ork area Etab e$nameF. A!%antages o" a ogica !atabase o%er norma Se ect 4ueries. 't o""ers check con!itions to see &hether the input is correct( comp ete an! p ausib e 't contains centra authoriBation checks "or !atabase access 5nhancements such as impro%ement in per"ormance imme!iate y app y to a reports &hich use ogica !atabase. /ote6 7ue to the comp e1ities in%o %e!( ogica !atabases are not use! in most o" the cases ;;;;
Report Program6 A report is a program that typica y rea!s an! ana yBes !ata in !atabase tab es &ithout changing the !atabase. 7ia og Program6 A !ia og program a o&s you to &ork interacti%e y &ith the system an! to change the contents o" the !atabase tab es. 5ach !ia og program has a certain se4uence o" screens that are processe! by the system one a"ter the other. A Sample transaction processing in !ialog Programming
Components o/ !ialog Program Cn ike report &hich genera y entai s the creation o" one autonomous program &hich can be e1ecute! in!epen!ent y o" other ob#ects( !ia og program !e%e opment entai s !e%e opment o" mu tip e ob#ects none o" &hich can be e1ecute! on its o&n. 'nstea! a ob#ects are inke! hierarchica y to the main program an! are e1ecute! in a se4uence !ictate! by the 7ia og >ain Program. The components o" a !ia og program are6 Transaction co!e The transaction co!e starts a screen se4uence. Dou create transaction co!es in the Repository Bro&ser in the ABAP .orkbench or using Transaction S5M,. A transaction co!e is inke! to an ABAP program an! an initia screen. Dou can start a screen se4uence "rom any ABAP program using the 0A:: S0R55/ statement. Screens 5ach !ia og in an SAP system is contro e! by one or more screens. Dou create screens using the Screen Painter in the ABAP .orkbench through transaction S5K1 5ach screen be ongs to an ABAP program.
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 e ements such as checkbo1es an! ra!io buttons. A " o& ogic !etermines the ogica processing &ithin screen. GC' status 5ach screen has a GC' status2es3 &hich are in!epen!ent components o" a program. This contro s the menu bars( stan!ar! too bar( app ication too bar ( &ith &hich the user can choose "unctions in the app ication. Dou create them in the ABAP .orkbench using the >enu Painter. ABAP Program 5ach screen an! GC' status in the R+, System be ongs to one ABAP program. The ABAP program contains the !ia og mo!u es that are ca e! by the screen " o& ogic( an! a so process the user input "rom the GC' status. ABAP programs that use screens are a so kno&n as !ia og programs. 'n a mo!u e poo 2type > program3V the "irst processing b ock to be ca e! is a &ays a !ia og mo!u e. Ho&e%er( you can a so use screens in other ABAP programs( such as e1ecutab e programs or "unction mo!u es. The "irst processing b ock is then ca e! !i""erent yV "or e1amp e( by the runtime en%ironment or a proce!ure ca . The screen se4uence is then starte! using the 0A:: S0R55/ statement. Screen 8 o& :ogic Screen 8 o& ogic is primari y !i%i!e! into "our components. 1. Process Be"ore -utput 2PB-3 e%ent6 &hich is processe! be"ore the screen is !isp aye! 2. Process A"ter 'nput 2PA'3 e%ent6 &hich is processe! a"ter a user action on the screen ,. Process on he p re4uest 2P-H36 &hich is processe! &hen 81 is presse! 4. Process on %a ue re4uest 2P-@36&hich is processe! &hen 84 is presse! 7ynpro A screen together &ith its 8 o& ogic is ca e! a 7ynpro 2<7ynamic Program= since the screen " o& ogic in" uences the program " o&3 5ach !ynpro contro s e1act y one step o" your 7ia og Program. The screens be onging to a program are numbered. The screen " o& se4uence can be either inear or cyc ic. 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 a so o%erri!e the statica y$!e"ine! ne1t screen "rom &ithin the !ia og mo!u es o" the ABAP program. ABAP >o!u e Poo -n a PB- or PA' e%ent a 7ynpro ca s an ABAP !ia og program. 0o ection o" such programs is ca e! the ABAP mo!u e poo . 8or e1amp e mo!u es ca e! at the PA' e%ent are use! to check the user input an! to trigger appropriate !ia og steps( such as the up!ate task. A !ynpros to be ca e! "rom &ithin one transaction re"er to a common mo!u e poo . Structure o" a 7ia og Program
;;;;
Chapter B # Subscreens
Be"ore you rea! this 0hapter make sure you &hat a 7ia og Program is 9 Subscreens A subscreen is an in!epen!ent screen that is !isp aye! in an area o" another 2<main=3 screen. Subscreens a o& you to embe! one screen &ithin another at runtime. Dou can inc u!e mu tip e sub$screens on main screen. The term subscreen app ies both to the screen that you embe!( an! the area on the main screen in &hich you p ace it. This 0hapter is about subscreen areas. The actua screens create! through S5K1 transaction( are ca e! subscreen screens i" !e"ine! in screen attributes. .hen you use a subscreen( the " o& ogic o" the embe!!e! screen is a so embe!!e! in the " o& ogic o" the main screen.Hence( Csing subscreens on screens is ike using inc u!es in ABAP programs. To use a subscreen( you must "o o& three simp e steps 1. 7e"ine the subscreen area2s3 on a screen 2. 7e"ine suitab e subscreen screens ,. 'nc u!e the subscreen screen in the subscreen area. A so( 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 a so 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%ai ab e area in the main screen( on y the part o" subscreen &i be %isib e that "its in the area a%ai ab e. The area is a &ays
measure! "rom the top e"t corner o" screen. Hence you shou ! take a!e4uate care &hi e !e"ining sub$screen areas an! creating sub$screens. 5PA>P:5 8or 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 ca e!( the PB- o" main screen is ca e!. But be"ore !isp ay( the PB-)s o" each screen attache! &ith sub$screen areas on main screen are a so ca e!.
Dou can inc u!e a subscreen screen using the 0A:: SCBS0R55/ statement in the " o& ogic o" the main screen. To inc u!e a subscreen screen in the subscreen area o" the main screen an! ca its PB- " o& ogic( use the "o o&ing statement in the PB- e%ent o" the main screen6 <@F('66 ;'CF@' F>T<>T (A00 6>;6(@''N ,area. IN(0>DIN/ ,pro-.! ,#ynp.. This statement assigns the subscreen screen &ith number E!ynpF to the subscreen area ca e! EareaF. Dou can a so speci"y the program in &hich the subscreen screen is !e"ine! 2optiona 3. '" you !o not speci"y the program e1p icit y( 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 a so inc u!e! at the same point. This can ca PB- mo!u es o" the ABAP program in &hich the subscreen screen is !e"ine!. At the en! o" the subscreen PB-( the g oba "ie !s "rom the program are passe! to any i!entica y$name! screen "ie !s in the subscreen screen. The PB- " o& ogic o" the subscreen screen can itse " inc u!e "urther subscreens. The name EareaF o" the subscreen area must be entere! !irect y &ithout in%erte! commas. Dou can speci"y the names EprogF an! E!ynpF either as itera s or %ariab es. '" you use %ariab es( you must !ec are an! "i i!entica y$name! %ariab es 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.
To ca the PA' " o& ogic o" the subscreen screen( use the "o o&ing statement in the PA' " o& ogic o" the main screen6 <@F('66 ACT'@ IN<>T (A00 6>;6(@''N ,area.. This statement inc u!es the PA' " o& ogic o" the subscreen screen inc u!e! in the subscreen area EareaF in the PB- e%ent. This can ca PA' mo!u es o" the ABAP program in &hich the subscreen screen is !e"ine!. 7ata is transporte! bet&een i!entica y$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" e ements o" sub$screens &ithin a screen shou ! be uni4ue Dou shou ! not ha%e -KA0-75 or 80-75 attache! &ith sub$screen. The -KA0-75 o" main screen itse " is -KA0-75 o" sub$screen Sub$screens cannot ha%e any !ia og mo!u es containing S5T T'T:5BAR( S5T P8$ STATCS( S5T S0R55/( :5A@5 S0R55/ or :5A@5 T- S0R55/. This &i cause runtime error. Dou nee! to ca it in the " o& ogic 2both PB- an! PA'3 o" the main screen. 0A:: SCBS0R55/ is not a o&e! in 0HA'/..5/70HA'/ an! :--P 5/7:--P statements 0annot ha%e an AT 5P'T$0->>A/7 mo!u e The "ie !s that you use are the g oba "ie !s. They must be !ec are! in the top inc u!e '" using subscreens "rom another !ia og program the !ata trans"er &i not happen un ess you a!! speci"ic co!e. ;;;;
4uestion. 'nstea! o" ca ing an e1tra screen &ith te1t "ie !s( you shou ! use one o" the "o o&ing "unction mo!u es to !isp ay a suitab e SAP script !ocument >EL$;#1?E(";%>#W;F#+;FIELD This "unction mo!u e !isp ays the !ata e ement !ocumentation "or components o" any structure or !atabase tab e "rom the ABAP 7ictionary. Dou pass the name o" the component an! structure or tab e to the import parameters 8'5:7 an! TAB:5. H5:PA-B?50TASH-. Cse this "unction mo!u e to !isp ay any SAP script !ocument. Dou must pass the !ocument c ass 2"or e1amp e( TP "or genera te1ts( 75 "or !ata e ement !ocumentation3 an! the name o" the !ocument to the import parameters 7-K0:ASS an! 7-K/A>5. 8or technica reasons( you must a so pass an empty interna tab e &ith the ine type T:'/5 to the tab es parameter o" the "unction mo!u e. Process on $alue DP%$E3 4) .hen the user chooses the "unction possib e entries 2843( the system !isp ays the possib e input %a ues "or a "ie ! 2%a ues( check tab e( matchco!e3( pro%i!e! they &ere store! by the !e%e oper. The e%ent <@F('66 FN VA0>'E@'1>'6T is a &ays processe! i" the user has ca e! <Possib e entries=. To !e"ine Possib e %a ues "or a "ie ! on screen( you nee! to !e"ine! "o o&ing in P-@ e%ent o" screen " o& ogic6 <@F('66 FN VA0>'E@'1>'6T CI'0D fiel# name BFD>0' mo#ule name 8or Possib e %a ues( &ithin mo!u e !e"ine! abo%e( you shou ! use the genera "unction mo!u e M'0<_VA0>'6_/'T_+ITM_TA;0' to get possib e %a ues "rom ABAP 7ictionary. There are some other "unctions that can a so be use! "or input he p6 F@IF;FIELD;A&LUE;+EBUE%" 0a s the input he p o" the ABAP 7ictionary !ynamica y. Dou can pass the component names o" a structure or !atabase tab e o" the ABAP 7ictionary to the "unction mo!u e in the import parameters TAB/A>5 an! 8'5:7/A>5. The "unction mo!u e starts the ABAP 7ictionary input he p "or this component. A o" the re e%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 se ection is returne! to the correspon!ing "ie ! on the screen. '" you speci"y the tab e parameter R5TCR/ATAB( the se ection is returne! into the tab e instea!. BFD>0' VA0>'_(A@@I'@ IN<>T. (A00 C>N(TIFN DC=IC_CI'0D_VA0>'_@'1>'6TL 'K<F@TIN/ TA;NAB' = DD'BFC=M'0<L CI'0DNAB' = D(A@@I'@1O DHN<<@F/ = <@F/NAB' DHN<N@ = DHNN>B DHN<@FCI'0D= D(A@@I'@L. 'NDBFD>0'.
F@IF;IN";"&1LE;A&LUE;+EBUE%" This "unction mo!u e !isp ays a %a ue ist that you create! in an ABAP program. The %a ue ist is passe! to the "unction mo!u e as the tab e parameter @A:C5ATAB. '" you speci"y the import parameters 7D/PPR-G( 7D/P/R( an! 7D/PR-8'5:7( the user)s se ection is returne! to the correspon!ing "ie ! on the screen. '" you speci"y the tab e parameter R5TCR/ATAB( the se ection is returne! into the tab e instea!. (A00 C>N(TIFN DC=IC_INT_TA;0'_VA0>'_@'1>'6TL 'K<F@TIN/ @'TCI'0D = D(FNNIDL DHN<<@F/ = <@F/NAB' DHN<N@ = DHNN>B DHN<@FCI'0D = D(FNN'(TIFNL VA0>'_F@/ = D6L TA;0'6 VA0>'_TA; = VA0>'6_TA;. That)s a to P-H an! P-@. :ea%e your comments in case o" any !oubts. ;;;;
51port6 0hanging I_pro-ram_name 6 report i! I_internal_tabname 6 the interna output tab e I_inclname 6 inc u!e or the report name &here a the !ynamic "orms are han! e!. ct_fiel#cat 6 an interna tab e &ith the type 60I6_T_CI'0D(AT_A0V &hich is !ec are! in the type poo S:'S.
+EU%E;&LA;LI%";DI%$L&3 This is the "unction mo!u e &hich prints the !ata. The important parameters are6 51port6 I_callbac5_pro-ram 6 report i! I_bypa&&in-_buffer 6 UP) 'Abu""erAacti%e 6 U U I_callbac5_pf_&tatu&_&et 6 routine &here a user can set his o&n p" status or change the "unctiona ity o" the e1isting 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 tab e I&_0ayout 6 structure to set the ayout o" the report It_fiel#cat 6 interna tab e &ith the ist o" a "ie !s an! their attributes &hich are to be printe! 2this tab e can be popu ate! automatica y by the "unction3 It_event&6 interna tab e &ith a ist o" a possib e e%ents o" A:@ an! their correspon!ing "orm names. Tab es6 t_outtab6 interna tab e &ith the !ata to be output +EU%E;&LA;EAEN"%;CE"D Returns tab e o" possib e e%ents "or a ist type 'mport6 't_'vent& 3The e%ent tab e is returne! &ith a possib e 0A::BA0K e%ents "or the speci"ie! ist type 2co umn U/A>5)3. 8or e%ents to be processe! by the 0a back( their U8-R>) "ie ! must be "i e!. '" the "ie ! is initia iBe!( the e%ent is ignore!. The entry can be rea! "rom the e%ent tab e( the "ie ! U8-R>) "i e! an! the entry mo!i"ie! using constants "rom the type poo S:'S. 51port6 I_li&t_type7 0 T simp e ist @'>6'_A0V_0I6T_DI6<0AH 1 T hierarchica $se4uentia ist @'>6'_A0V_MI'@6'1_0I6T_DI6<0AH 2 T simp e b ock ist @'>6'_A0V_;0F(N_0I6T_A<<'ND , T hierarchica $se4uentia b ock ist @'>6'_A0V_;0F(N_0I6T_M6_A<<'ND +EU%E;&LA;C+ID;DI%$L&3 A ne& "unction "rom ABAP4.H %ersion( to !isp ay the resu ts in gri! rather than a pre%ie&.
Parameters6 same as reu&e_alv_li&t_#i&play /ote6 Gri! cannot han! e high %o umes. A "unction ike sort( scro ing !o&n consumes a ot o" resources + time i" the %o ume o" !ata to be !isp aye! is high. There is no c ear cut !e"inition such that i" the amount o" !ata is P go "or ist or gri! but the !e%e oper has to take a ca base! on his e1perience. '" 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 tab e &ith the hea!ings o" the type &li&_t_li&t)ea#er. This interna tab e has three "ie !s6 Typ 6 UH) * hea!er( US) * se ection( UA) * action Key6 on y &hen typ is US). 'n"o 6 the te1t to be printe! loc1 ;eport This ooks ike a simp e report but this report has the "eatures o" sorting an! "i tering on y. This report is use! i" you ha%e to !isp ay more than one report on the output. Technica y speaking i" you ha%e mu tip e interna tab es &ith !ata to be !isp aye! as separate b ocks then &e go "or b ock report o" A:@. The important "unctions use! "or creating this report are6 @'>6'_A0V_;0F(N_0I6T_INIT @'>6'_A0V_;0F(N_0I6T_A<<'ND @'>6'_A0V_;0F(N_0I6T_DI6<0AH +EU%E;&LA;1L#(*;LI%";INI" This "unction mo!u e is use! to set the !e"au t gui status etc. The parameters are simi ar 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!u e a!!s the !ata to the b ock. 'mportant Parameters 51port6 i&_layout6 ayout settings "or b ock it_fiel#cat6 "ie ! cata og I_tabname6 interna tab e name &ith a possib e e%ents Tab es6 t_outtab6 interna tab e &ith output !ata. +EU%E;&LA;1L#(*;LI%";DI%$L&3 This "unction mo!u e !isp ays the ist &ith !ata appen!e! by the abo%e "unction. Parameters6 A the parameters are optiona . 0ierarchical ;eports
Hierarchica !isp ay is use! "or !isp aying !ata that are re ate!. :ike sa es or!er an! item !etai s. Here sa es or!er !etai s can be the hea!er !ata &hereas them items in the sa es or!er can be the item !ata The "unction mo!u e use! "or this is +EU%E;&LA;>IE+%EB;LI%";DI%$L&3 51port6 I_(A00;A(N_<@F/@AB I_(A00;A(N_<C_6TAT>6_6'T I_(A00;A(N_>6'@_(FBBAND I6_0AHF>T It_fiel#cat It_event& I_tabname_)ea#er6 /ame o" the interna tab e in the program containing the output !ata o" the highest hierarchy e%e . I_tabname_item6 /ame o" the interna tab e in the program containing the output !ata o" the o&est hierarchy e%e . I&_5eyinfo6 This structure contains the hea!er an! item tab e "ie ! names &hich ink the t&o tab es 2share! key3. Tab es t_outtab_)ea#er 6 Hea!er tab e &ith !ata to be output t_outtab_item 6 /ame o" the interna tab e in the program containing the output !ata o" the o&est hierarchy e%e . A the !e"initions o" interna tab es( structures an! constants are !ec are! in a type$poo ca e! SLIS& This interna tab e can be popu ate! automatica y by using @'>6'_A0V_CI'0D(ATA0F/_B'@/'L. !isplay $ariants 7isp ay %ariants are use! to set the !e"au t properties o" an a % output ike sort criteria( "i tering criteria( tota ing an! subtota ing etc 7isp ay %ariants can be user speci"ic an! stan!ar! 2stan!ar! %ariants can be use! by any user 3 Kin! o" !isp ay %ariants that can be sa%e! is contro e! by the parameter iAsa%e that is passe! in "unction mo!u es reuseAa %A istA!isp ay + reuseAa %Agri!A!isp ay Dou can pro%i!e an option on the se ection screen to se ect &hat !isp ay %ariant to be use! The common "unction mo!u es re ate! to se ecting + %a i!ating !isp ay %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 ;;;;
An e!itor "or entering an! e!iting the ines o" a te1t Sty es an! ayout sets "or print ayout. These are create! in!epen!ent o" the in!i%i!ua te1ts using the correspon!ing maintenance transactions an! are a ocate! to the te1ts ater The composer is a centra output mo!u e. The SAP script composer is in%isib e to the outsi!e A programming inter"ace that a o&s you to inc u!e SAP script components into your o&n app ication programs an! to contro the output o" ayout sets "rom &ithin the programs Se%era !atabase tab es "or storing te1ts( sty es an! ayout sets Layout Set To output !ocuments using the programming inter"ace( R+, app ication programs nee! so$ ca e! ayout sets 2a kin! o" "orm3.'n SAP script a ayout set !escribes the ayout o" the in!i%i!ua print pages an! uses te1t e ements to supp y !e"inab e output b ocks( &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 se ection o" !ata "or the !ocument is !one through the print program. The print program se ects the !ata "rom !atabase tab e an! "ee!s it to the ayout set. .hen the print program is e1ecute! the !ocument is printe! on the screen( printer. Csua y a SAP Script :ayout consists o" "o o&ing components 1& 0eader !ata3 Hea!er !ata is use! "or in"ormation an! contro o" SAP printing. The hea!er !ata comprises o" 2 parts$ 7e%ice 'n!epen!ent 6Stores in"ormation ike Start page( 7e"au t 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! paragraph attributes speci"y :e"t or Right margin( A ignment( :ine spacing etc. 8ont attributes speci"y 8ont "ami y( 8ont siBe etc. 0haracter "ormats a o& to "ormat entire b ocks o" te1t &ithin a paragraph *& 'indows and "e-t Elements3 .in!o&s are in!i%i!ua te1t areas 2hea!er a!!ress( !ate( "ooter3 in a page. 't he ps combine the in"ormation containe! in a !ocument into certain groups an! make each group appear on the printe! page in an in!i%i!ua area. Dou can !e"ine te1t e ements
2&in!o& te1ts3 "or each &in!o&. The print program accesses te1t e ements 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 uni4ue 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 subse4uent pages( on &hich you nee! not repeat genera in"ormation( such as a!!ress or customer !ata. =& Page 'indows3 .hi e !e"ining &in!o&s an! pages( you !o not yet !etermine the position an! spacing o" the te1ts to be output. A page &in!o& !e"ines the rectangu ar 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 a o& 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 0omposer "or processing. This inc u!es( "or e1amp e( ine an! page "ormatting( the "ormatting o" te1t accor!ing to the paragraph an! character "ormats speci"ie!. Synta1 'nter $7 in the paragraph "ormat 51amp es N'+E<A/' * 51p icit page break <@FT'(T %%%'ND<@FT'(T * To print comp ete paragraph in one page. IN(0>D' * To inc u!e the content o" another te1t into current te1t <'@CF@B * To ca a subroutine o" any ABAP program Print Program The e1ecution 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 ca e! "rom customiBation. 8or a stan!ar! con"iguration &e can see the "orm name 2script name3( print program name an! output type in the tab e 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 e1ecute the script F<'N_CF@B 2>an!atory36 -pens the ayout set output (0F6'_CF@B 2>an!atory36 5n!s the ayout set output 6TA@T_CF@B 2-ptiona 3 6Starts a ne& ayout set +@IT'_CF@B 2>an!atory36 0a s a ayout set e ement 'ND_CF@B 2-ptiona 36 5n!s the current ayout set %utput "ypes The 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 a so be an interna e ectronic mai message that you &ant to sen! to sta"" in another !epartment. 8or e1amp e <Print out= can be c assi"ie! as one output type o" a bi ing !ocument( i.e. &hen this output type is e1ecute! the bi ing !ocument is printe!. Simi ar y <8a1= can be an output type( i.e. &hen this output type is e1ecute! a "a1 o" the bi ing !ocument is sent
A the output types "or any !ocument 2e.g. bi ing !ocument3 &i be store! in the tab e /AST.-utput types are e1ecute! through the program RS/AST00. 51amp e6 -utput type in a bi ing !ocument$ Go to @80, 5nter bi ing !ocument number an! press enter again 0hose -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! Te1ts "or your report can be create! using transaction S%1? Graphics an! printer macros are up oa!e! &ith report RSTP:7>0 into in!i%i!ua stan!ar! te1t !ocuments or through transaction SEA+& Graphics are up oa!e! in <Base ine T'88 H.0W "ormat 2.ti" "i es on P03 SAP Script N Stan!ar! te1t e ements can e1porte! or importe! bet&een t&o systems using RSTPS0RP program Copying Scripts Across clients6 SAP Script is a c ient !epen!ent ob#ect. Cn ike programs( changes !one to SAP script in one c ient &i not be re" ecte! in other c ients. 8or copying script "rom one c ient to another( go to S5L1an! use <0opy "rom 0 ient= option a%ai ab e un!er Cti ities menu or import the transport re4uest( in &hich the script is sa%e!( "rom the origina c ient 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 app ies to the stan!ar! te1ts 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. ;;;;
:abe s cannot be create! in Smart 8orms. Ad7antages o/ Smart 4orms They he p a!apting "orms &ithout any programming kno& e!ge !ue to entire y graphica user inter"ace .hen acti%ating the smart "orm the system automatica y generates the "unction mo!u e an! at the runtime. To make any changes &e ha%e to use the 7rag N 7rop( 0ut N Paste. These actions !o not inc u!e &riting o" co!ing ines or using a script anguage. .e can insert static an! !ynamic tab es. These inc u!e the ine "ee!s in the in!i%i!ua tab e ce s( triggering e%ents "or tab e hea!ings an! subtota s an! sorting !ata be"ore output. The smart "orms a o& the user to inc u!e graphics( &hich can be !isp aye! as a part o" the "orm or as backgroun! graphics. 7uring printout the user can suppress the backgroun! graphic as an! &hen necessary. .eb Pub ishing is possib e using the generate! P>: 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 bo1. 'n the ne1t screen ( enter a "rom name an! c ick create
1. Na7igation window $consist o" no!es an! sub no!es. They contain a the e ements 2te1t( &in!o& etc3 that be ong to sap "orms 2. 2aintenance window$ sho&s attributes o" the e ements ,. 4orm printer $&in!o& sho&s the ayout o" the page .hene%er &e create smart "orms( SAP creates+generates a "unction mo!u e. Cn ike SAP scripts ( SAP 8-R>S a o& 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!.
Right$0 icking on the Pages &i a o& creation o" /e& Page( .in!o&( Graphic or A!!ress.
Printing &i take p ace on the basis o" Une1t page) "ie !.But processing &i happen as per the se4uence in na%igation &in!o&Q
8or backgroun! picture an! graphics you can pick up either b ack an! &hite or co or bitmap images an! are store! in the "orm o" stan!ar! te1ts. Dou may take a !etour "rom the smart "orm screen an! open 8orm Graphics screen. Transaction co!e6 SeLI
There are t&o types o" .in!o&s 1. >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 mu tip e secon!ary &in!o&s .hate%er you print in secon!ary &in!o&9it has to be static. 2'" u ha%e 20 ines in a P- an! there is page constraint the ines get carrie! "or&ar! to ne1t page in the main &in!o&. i.e. 'n a pre!ecessor an! successor type o" content( they &i be printe! in se4uence in main &in!o&. This is not a o&e! in Secon!ary &in!o&s.
'nsi!e the main &in!o& &e can a!! te1t as intro!uction to customiBe the "orm output.
The -utput options on each &in!o& !etermine the :ine siBe( .i!th( 0o ors an! backgroun! to be put.
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 !irect y taken "rom A7R0 tab e an! &i be popu ate! in the "orm.
1. /orma 5!itor
2. Graphics 5!itor.
This setting can be change! using the 0on"igure e!itor in Cti ities.'n Tab e painter( you can !ra& the "ormat as per c ient re4uirement 2e.g. Hea!ing( Sub Hea!ing( 'tem( Sub Tota ( Gran! Tota etc.3
Dou can use the tab e ayout to !etermine6 The number o" ines an! ce s The height o" each ine The &i!th o" each ce The a ignment o" the tab e in the &in!o&
The Tab e sho&s the !i""erent ine types &hich &i be use! in the tab e. The :ine types !e"ine the siBe o" each ce an! the number o" ce s in each ine.
Smart 4orms Programming 4low .hen an SAP Smart 8orm temp ate is create!( a user creates the "orm ayout( !e"ines the re4uire! "ie !s( con!itions( an! specia programming instructions in the Smart 8orm temp ate using the Smart 8orm Bui !er. A"ter the "orm !esign is comp ete( the "orm nee!s to be acti%ate! be"ore it can be teste! or accesse! by the print programs. Acti%ating the "orm initiates the generation o" a "unction mo!u e that han! es a o" the "orm)s processing. This "unction mo!u e interacts &ith the app ication program+print program to create the 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!u es "or the processing o" the smart "orm. To the "irst "unction mo!u e( &e pass the name o" the smart "orm as the import parameter. This then returns the name o" the !ynamica y generate! "unction mo!u e &hich &i actua y ca the smart "orm. The smart "orm name can be passe! on to the "unction >o!u e * D66C_C>N(TIFN_BFD>0'_NAB'L
This &i return the 8unction mo!u e name o" the smart "orm &hich is re"erence!.
The Print program &i be ca ing the 8> F66C_C>N(TIFN_BFD>0'_NAB'L to get the 8unction mo!u e name at Runtime. Therea"ter it &i ca the 8unction mo!u e thus obtaine! to e1ecute the smart "orm.
"emplates Temp ate can be use! &hen you kno& the e1act siBe o" the output or the output is in a "i1e! "ormat. 5.g. Ta1 "orm+ che4ues +air ine "orm+rai &ay ticket6 a these use temp ates. The big bet&een tab e an! temp ate is that in a Tab e the height changes !ynamica y. .e ca a ro& a U ine) in temp ate.
S2A;" Styles
A Smart Sty e contains6 Hea!er !ata containing the !e"au t %a ues o" a Smart Sty e Paragraph "ormats inc u!ing in!ents an! spacing( "ont attributes( tabs( an! out ine an! numbering 0haracter "ormats inc u!ing e""ects 2superscript( subscript3( barco!e an! "ont attributes 0o ors an! un!er ines "or a paragraph or character "ormat Dou can use the transaction Usmart"orms) + Usmartsty es) to create a smart sty e.
4ormat6 Y0CS 2a!!itiona item in GC' status3 Screen E-it3 't a o&s customer to a!! "ie !s to a screen in an SAP program %ia a subscreen. The subscreen is ca e! &ithin the stan!ar! screen)s " o& ogic. 4ormat3 (A00 (>6TFB'@E6>;6(@''N (>6T6(@* E-amples o/ Customer E-its E-ample o/ a Screen E-it6 'n transaction 0AT2 * Time Sheet 5ntry( HR &ishes to inc u!e an interacti%e ackno& e!gment that kno&ing y submitting incorrect !ata is groun!s "or !ismissa .
E-ample o/ a 2enu E-it3 'n transaction S5,I * ABAP 5!itor( the !e%e opment team &ishes to inc u!e a menu ink to transaction S5I0 * -b#ect /a%igator "or ease o" use.
E4%;E
A4"E;
E-ample o/ a 4unction 2odule E-it3 The company &ants the bank !etai s o" the @en!ors in the @en!or creation to be
man!atory e%ent .So it must " ash an error message that UP ease 5nter the bank !etai s) E4%;E
A4"E;
-r in transaction S5I1 you can use the appropriate app ication area
:ater you assign the 0ustomer 51it to your pro#ect. 'hat is a :SE; EII"> Cser 51it ser%es the same purpose as 0ustomer 51its but they are a%ai ab e on y "or the S7 mo!u e. The e1it is imp emente! as a ca to a 8unction >o!u e. The co!e is &ritten by the !e%e oper. .e kno& Cser 51it in S7 is 2$)=A4JJ >6'@'KIT_CI'0D_BFDICI(ATIFN 6 To mo!i"y screen attributes >6'@'KIT_6AV'_DF(>B'NT 6To per"orm operations &hen user hits Sa%e >6'@'KIT_6AV'_DF(>B'NT_<@'<A@' >6'@'KIT_BFV'_CI'0D_TF_V;AN 6.hen user hea!er changes are mo%e! to hea!er &ork area. >6'@'KIT_BFV'_CI'0D_TF_V;A< 6.hen user item changes are mo%e! to SAP item &ork area ****
Chapter 1= # A!I
BA7' stan!s "or Business A!! 'ns ?ust ike 0ustomer 51its( BA7' he p hook custom enhancements to SAP "unctiona ity. E-ample o/ a A!I3 'n transaction 0AT2 * Time Sheet 5ntry( HR &ishes to inc u!e an interacti%e ackno& e!gment that kno&ing y submitting incorrect !ata is groun!s "or !ismissa . This can be achie%e! using BA7'
4eatures3 1& BA7')s are -b#ect -riente! ,& They can be imp emente! mu tip e times *& 't !oes not re4uire SAP So"t&are 0hange Registration )& /o e""ect on re ease upgra!e! on the "unctioning o" BA7')s !e/ine and Implement a API These in%o %e! three steps Step 1 0reating BA7' 7e"inition6 Transaction S51I.
Step * 7e"ine a c ass imp ements the inter"ace6 7uring imp ementation creation( a c ass "or imp ementing the enhancement)s inter"ace is a so create!
;;;;
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 4ueries. An 'n"oSet can be assigne! to se%era ro es or user groups. Ad7antages# By creating 'n"oSets an! assigning them to ro es or user groups( the system a!ministrator !etermines the range o" reports that the in!i%i!ua app ication !epartments or en!$users are ab e to generate using the SAP Ouery. 5n!$users are ab e to &ork on y &ith those 'n"oSets that are re e%ant to their particu ar area( as !esignate! by the ro e or user group that they are assigne! to. :SE; 6roups The Cser Groups component is use! to maintain user groups 2"rom a security stan!point3. Csers &orking in the same app ication are assigne! to the same user group. 't !oes not matter &ho actua y !e"ine! a 4uery in a user group. 5%ery user assigne! to the user group is ab e to e1ecute the 4uery.
Csers in a user group nee! to ha%e the necessary authoriKations be"ore they are ab e to change or re!e"ine a 4uery. 5%ery user in a system can be assigne! to se%era user groups. "ranslation(8:E;9 Component A ot o" te1ts are generate! &hen !e"ining 4ueries( 'n"oSets( an! user groups. These te1ts are !isp aye! in the anguage that &e chose &hen &e og on to the SAP system. .e can compare the te1t+ 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 2supports sorting an! summation3. ,& S"A"IS"IC 6 Sho&s the statistica "igures ca cu ate! "rom the basic !ata. *& ;ANLE! LIS" 6 A ranke! ist is a specia iBation o" a statistic. 51. Top ten customers o" a tra%e agency. A 4uery 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 4uery an! c ick on the 0reate button.
Step , Gi%e the !escription o" the 4uery in the ne1t screen. Speci"y the output ength an! se ect the processing option "rom the 8urther Processing -ptions bo1. The !ata can be !isp aye! in %arious "ormats such as tab e( !o&n oa! to a "i e( an! !isp ay in .or! etc.
Step * 0 ick on the ne1t screen( se ect the "ie ! group to be use!.
Step ) 0 ick on the ne1t screen( se ect the "ie !s you &ant !isp aye!
Step = -n the ne1t screen( se ect the se ection "ie !s an! then chose one o" the output types 2basic( statistics( ranke!3. 'n each o" the ists( you can se ect %arious options. 2eg. Sort or!er o" "ie !s( change output ength( co umn co or( tota s( page hea!er( page "ooter etc.3 .
Step @ A"ter pro%i!ing a the abo%e options you can sa%e the 4uery an! e1ecute it.
/ote6 Transaction to 0reate+>aintain 'n"oset $SO02 Transaction to 0reate+>aintain CserGroup $SO0, ;;;; 0hapter 1L $ SAP B70 * Batch 7ata 0ommunication This 0hapter &i co%er the "o o&ing topics$ 1& 'ntro!uction to B70. ,& >etho! o" Batch 'nput. *& Batch 7ata Proce!ures. )& .riting B70 programs. =& 0reating Batch input Session. @& Batch 'nput Recor!ing. :et)s BeginQ Introduction to atch input Batch input is typica y 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 techni4ue that a o&s you to trans"er !atasets automatica y to screens be onging to transactions( an! thus to an SAP system. Batch input is contro e! by a batch input session. atch input session Groups a series o" transaction ca s together &ith input !ata an! user actions . A batch input session can be use! to e1ecute a !ia og transaction in batch input( &here some or a the screens are processe! by the session. Batch input sessions are store! in the
!atabase as !atabase tab es an! can be use! &ithin a program as interna tab es &hen accessing transactions. Points to note B7' &orks by carrying out norma SAP transactions #ust as a user &ou ! but it e1ecute the transaction automatica y. All the screen 7alidations and business logic 7alidation will be done while
using atch !ata Input&
't is suitab e "or entering arge amount o" !ata. /o manua interaction is re4uire! 2ethods o/ atch Input SAP pro%i!es t&o basic metho!s "or trans"erring egacy !ata in to the R+, System. 1& 0 assica Batch 'nput metho!. ,& 0a Transaction >etho!. 0 assica Batch 'nput metho! 'n this metho! an ABAP+4 program rea!s the e1terna !ata to the SAP System an! stores in a batch input session. A"ter creating the session( you can run the session to e1ecute the SAP transaction in it. This metho! uses the "unction mo!u es ;D(_ F<'NG ;D(_IN6'@T an! ;D(_(0F6' Batch 'nput Session can be process in , &ays 'n the "oregroun! 'n the backgroun! 7uring processing( &ith error !isp ay Dou shou ! process batch input sessions in the "oregroun! or using the error !isp ay i" you &ant to test the !ata trans"er. '" you &ant to e1ecute the !ata trans"er or test its per"ormance( you shou ! process the sessions in the backgroun!. Points to note about 0 assica Batch 'nput metho! Asynchronous processing Trans"er !ata "or mu tip e transactions. Synchronous !atabase up!ate. A batch input process og is generate! "or each session. Session cannot be generate! in para e . Call "ransaction 2ethod& 'n this metho! ABAP+4 program uses 0A:: TRA/SA0T'-/ CS'/G statement to run an SAP transaction. 5ntire batch input process takes p ace on ine in the program
Points to Note3 8aster processing o" !ata Synchronous processing Trans"er !ata "or a sing e transaction. /o batch input processing og is generate!. atch Input Procedures
Dou &i typica y obser%e the "o o&ing se4uence o" steps to !e%e op Batch 'nput "or your organiBation Ana ysis o" the egacy !ata. 7etermine ho& the !ata to be trans"erre! is to be mappe! in to the SAP Structure. A so take note o" necessary !ata type or !ata ength con%ersions. Generate SAP !ata structures "or using in e1port programs. 51port the !ata in to a se4uentia "i e. /ote that character "ormat is re4uire! by pre!e"ine! SAP batch input programs. '" the SAP supp ie! B70 programs are not use!( co!e your o&n batch input program. 0hoose an appropriate batch input metho! accor!ing to the situation. Process the !ata an! a!! it to the SAP System. Ana yBe the process og. 8or the 0A:: TRA/SA0T'-/ metho!( &here no proper og is create!( use the messages co ecte! by your program. 8rom the resu ts o" the process ana ysis( correct an! reprocess the erroneous !ata. 'riting !C program Dou may obser%e the "o o&ing process to &rite your B70 program Ana yBe the transaction2s3 to process batch input !ata. 7eci!e on the batch input metho! to use. Rea! !ata "rom a se4uentia "i e Per"orm !ata con%ersion or error checking. Storing the !ata in the batch input structure( B707ATA.
Generate a batch input session "or c assica batch input( or process the !ata !irect y &ith 0A:: TRA/SA0T'-/ CS'/G statement. Batch 'nput 7ata Structure 7ec aration o" batch input !ata structure 7ATA6 B5G'/ -8 Eb!c tab eF -00CRS Eoccurs parametersF. '/0:C75 STRC0TCR5 B707ATA. 7ATA6 5/7 -8 Eb!c tab eF. 4ield name "ype Length !escription PR-GRA> 0HAR I >o!u e poo 7D/PR/C>0 4 7ynpro number 7D/B5G'/ 0HAR 1 Starting a !ynpro 8/A> 0HAR ,K 8ie ! name 8@A: 0HAR I0 8ie ! %a ue The or!er o" "ie !s &ithin the !ata "or a particu ar screen is not o" any signi"icance Points to /ote .hi e popu ating the B70 7ata make sure that you take into consi!eration the user settings. This is especia y re e%ant "or "i ing "ie !s &hich in%o %es numbers 2:ike 4uantity( amount 3. 't is the user setting &hich !eci!es on &hat is the grouping character "or numbers 5.g.6 A number "i"ty thousan! can be &ritten as K0(000.00 or K0.000(00 base! on the user setting. 0on!ense the 8@A: "ie ! "or amount an! 4uantity "ie !s so that they are e"t a igne!. /ote that a the "ie !s that you are popu ating through B70 shou ! be treate! as character type "ie !s &hi e popu ating the B70 7ata tab e. 'n some screens &hen you are popu ating %a ues in a tab e contro using B70 you ha%e to note ho& many number o" ro&s are present on a !e"au t siBe o" the screen an! co!e "or as many ro&s. '" you ha%e to popu ate more ro&s then you ha%e to co!e "or <Page !o&n= "unctiona ity as you &ou ! !o &hen you are popu ating the tab e contro manua y. /umber o" ines that &ou ! appear in the abo%e scenario &i !i""er base! on the screen siBe that the user uses. So a &ays co!e "or stan!ar! screen siBe an! make your B70 &ork a &ays in stan!ar! screen siBe irrespecti%e o" &hat the user keeps his screen siBe as. Creating atch Input Session -pen the batch input session using "unction mo!u e B70A-P5/AGR-CP. 8or each transaction in the session6 8i the B707ATA &ith %a ues "or a screens an! "ie !s processe! in the transaction. Trans"er the transaction to the session &ith B70A'/S5RT. 0 ose the batch input session &ith B70A0:-S5AGR-CP atch Input ;ecorder Batch input recor!er 2System F Ser%ices F Batch input F Recor!er3 recor!s transactions &hich are manua y entere! an! creates a batch input session &hich can be e1ecute! ater using S>,K.
Begin the batch input recor!er by se ecting 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 comp ete! posting a SAP transaction you either choose Get Transaction an! Sa%e to en! the recor!ing or /e1t Transaction an! post another transaction. -nce you ha%e sa%e! the recor!ing you can create a batch input session "rom the recor!ing an!+or generate a batch input program "rom the recor!ing. The batch input session you create! can no& be ana yBe! #ust ike any other batch input 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 so i! base &hich can then be a tere! accor!ing to customer re4uirements. ;;;;
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!u es that "orm the inter"ace to the app ication. "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 supp ie! by SAP. A!%antages o" 57' process Re!uce! !ata 5ntry 5rrors Re!uce! Processing cyc e time A%ai abi ity o" !ata e ectronic "orm Re!uce! Paper .ork Re!uce! 0ost Re!uce! 'n%entories an! Better P anning Stan!ar! >eans o" 0ommunicating Better Business Processes 0ompetiti%e A!%antage 'hat is ALE> A:5 supports the !istribution o" the business "unctions an! process across oose y coup e! SAP R+, systems 2!i""erent %ersions o" SAP R+,3. A connection "rom R+2 an! non$SAP systems is a so supporte!. A:5 supports$ 7istribution o" app ications bet&een !i""erent re eases o" R+, Systems
0ontinue! !ata e1change a"ter a re ease upgra!e &ithout re4uiring specia maintenance 0ustomer$speci"ic e1tensions. 0ommunication inter"aces that a o& connections to non$SAP systems. 0oup ing 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 e1change o" business !ocuments bet&een the systems o" business partners 2cou ! be non$SAP systems3 A:5 is SAP)s techno ogy "or supporting a !istribute! en%ironment &hereas 57' is a process use! "or e1change o" business !ocuments &hich no& ha%e been gi%en a stan!ar! "ormat Both A:5 an! 57' re4uire !ata e1change. An '!oc is a !ata container &hich is use! "or !ata e1change by both 57' an! A:5 processes. 'hat is I!%C> '7-0 is simp y a !ata container use! to e1change in"ormation bet&een any t&o processes that can un!erstan! the synta1 an! semantics o" the !ata. 'n simp e &or!s( an i!oc is ike a !ata "i e &ith a speci"ie! "ormat &hich is e1change! bet&een 2 systems &hich kno& ho& to interpret that !ata. '7-0 stan!s "or= 'nterme!iate 7ocumentH .hen &e e1ecute an outboun! A:5 or 57' Process( an '7-0 is create!. 'n an inbound A:5 or 57' process( an '7-0 ser%es as input to create an app ication !ocument. 'n the SAP System( '7-0s are store! in !atabase. 5%ery '7-0 has an uni4ue number 2&ithin a c ient3. '7-0s are base! on 57' stan!ar!s( A/S' AS0 P12 an! E!I4AC". 'n case o" any con" ict in !ata siBe( it a!opts one &ith greater ength. '7-0s are in!epen!ent o" the !irection o" !ata e1change e.g. -R75RS016 Purchasing mo!u e6 'nboun! an! -utboun!. '7-0s can be %ie&e! in a te1t e!itor. 7ata is store! in character "ormat instea! o" binary "ormat. '7-0s are in!epen!ent o" the sen!ing an! recei%ing systems.2SAP$to$SAP as &e as /on$SAP3 ;;;;
'7-0s are in!epen!ent o" the sen!ing an! recei%ing systems&2SAP$to$SAP as &e as /on$SAP3 '7-0s are base! on 57' stan!ar!s( A/S' AS0 P12 an! 57'8A0T. 'n case o" any con" ict in !ata siBe( it a!opts one &ith greater ength. '7-0s are in!epen!ent o" the !irection o" !ata e1change e.g. -R75RS01 6 Purchasing mo!u e 6 'nboun! an! -utboun! '7-0s can be %ie&e! in a te1t 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 ;ecordE$ &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 0ontro recor!. ,& "he application data D!ata ;ecordE .hich contains the !ata. These are ca e! the !ata recor!s+segments. *& "he Status in/ormation DStatus ;ecordE# These gi%e you in"ormation about the %arious stages the i!oc has passe! through. Dou can %ie& an '7-0 using transaction .502 or .50K
As seen in screenshot abo%e '7-0 recor! has three parts 0ontro ( 7ata an! Status. :et)s ook into them in !etai $ 0ontro Recor! A contro recor! !ata is store! in 57'70 tab e. The key to this tab e is the '7-0 /umber 't contains in"ormation ike '7-0 number( the !irection 2inboun!+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 app ication !ata ike emp oyee hea!er in"o( &eek y !etai s( c ient !etai s etc A !ata recor! !ata is store! in 57'72 to 57'74 tab es 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( the hierarchy an! the !ata The actua !ata is store! as a string in a "ie ! ca e! S7ATA( &hich is a 1000 char ong "ie !. Status Recor! Status recor!s are attache! to an '7-0 at e%ery mi estone or &hen it encounters errors. A status recor! !ata is store! in 57'7S tab e. Statuses 1$42 are "or outboun! &hi e K0$LK "or inboun! I!%C "ypes An '7-0 Type 2Basic3 !e"ines the structure an! "ormat o" the business !ocument that is to be e1change!. An '7-0 is an instance o" an '7-0 Type( #ust ike the concept o" %ariab es an! %ariab es types in programming anguages. Dou can !e"ine '7-0 types using 'E*?
'hat is a Segment> Segment !e"ines the "ormat an! structure o" a !ata recor! in '7-0. Segments are reusab e components. 8or each segment SAP creates 1& Segment Type 2%ersion in!epen!ent3 ,& Segment 7e"inition 2%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-0 is o" 2 types6$ 1& Basic ,& 51tension
SAP pro%i!es many a pre$!e"ine! Basic '7-0 Types &hich cannot be modi/ied. 'n case you &ant to a!! more !ata to these restricte! basic type you may use an e1tension type. >ost o" the times you &i N%" use e1tension.
2essage "ype A message represents a speci"ic type o" !ocument that is transmitte! bet&een t&o partners 51. -r!ers( or!ers responses( in%oices etc. An i!oc type can be associate! &ith many message types A so a message type can be associate! &ith !i""erent i!oc types. Transaction 'E+1
I!%C $iews
An '7-0 type can be use! "or more than one message type( &hich resu ts in '7-0s containing more "ie !s than re4uire! "or a particu ar message type. '7-0 %ie&s are use! to impro%e per"ormance in generating '7-0s to ensure on y the re e%ant segments are "i e! &ith !ata. '7-0 @ie&s are important on y "or -utboun! Processing.
Partner Pro/iles A partner is !e"ine! as a business partner &ith &hom you con!uct business an! e1change !ocuments 'n the partner pro"i e o" a partner that &e e1change '!ocs &ith( &e maintain the parameters that are necessary "or e1changing the !ata. The transaction use! is .520.
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 2subsystem3. The port !e"ines the me!ium in &hich !ata is e1change! bet&een the 2 systems. There are !i""erent types o" ports. The 2 most common y use! are the ";4C ports use! in A:5 an! 8i e ports &hich 57' uses. 8or TR80 ports &e ha%e to gi%e the name o" the ogica !estination create! using S>KM. .hen using "i e port you can speci"y the !irectory &here the '7-0 "i e shou ! be p ace!. The other system or the mi!! e&are &i pick up the "i e "rom here. The 8unction mo!u e can be use! to generate a "i e name "or the i!oc. .hi e testing you can use <-utboun! "i e= to speci"y a constant "i e name. The tab <outboun! trigger= can be use! to supp y 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! "i e name an! the !irectory &hich has to be run.
This is &o 0-/8CS'/GQ :et)s un!erstan! the process o" creating an '7-0 &ith an e1amp e $ .hene%er a Purchase -r!er 2P-3 is create! &e &ant to sen! the '7-0 to a %en!or. The P- is sent in the "orm o" an '7-0 to the %en!or 2partner3. That partner has to be 57' enab e! in that system. SAP shou ! rea iBe that it cou ! sen! !oc to this %en!or e ectronica y. 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 app ication !ocument 2a sa es or!er3 on their system. Ouotation( R8O( P-( S-( 'n%oice( !e i%ery note etc are some o" the common y e1change! !ocuments through '7-0 The process o" !ata trans"er out o" your SAP system is ca e! the %utbound process( &hi e that o" !ata mo%ing into you SAP system is ca e! Inbound process. As a !e%e oper or a consu tant &ho &i be in%o %e! in setting up theses process "or your organiBation. Here are the steps ho& to set them up$ "he %utbound Process Steps 'n%o %e! $ 0reate segments2.5,13 0reate an i!oc type2.5,03 0reate a message type 2.5I13 Associate a message type to i!oc type2.5I23 0reate a port2.5213 '" you are going to use the message contro metho! to trigger i!ocs then create the "unction mo!u e "or creating the i!oc an! associate the "unction mo!u e to an outboun! process co!e
-ther&ise create the "unction mo!u e or stan!a one program &hich &i create the i!oc 0reate a partner pro"i e 2.5203 &ith the necessary in"ormation in the outboun! parameters "or the partner you &ant to e1change the i!oc &ith. Trigger the i!oc. "he Inbound Process Steps 'n%o %e!$ 0reation o" basic '!oc type 2Transaction .5,03 0reating message type 2Transaction .5I13 Associating the >essage type to basic '!oc type 2Transaction .5I23 0reate the "unction mo!u e "or processing the i!oc 7e"ine the "unction mo!u e characteristics 2B7K13 A ocate the inboun! "unction mo!u e to the message type2.5KL3 7e"ining process co!e 2Transaction .5423 0reation o" partner pro"i e 2Transaction .5203 ;;;;
Step,& -pen the business ob#ect in change mo!e. Then Se ect Cti ities $FAP' >etho!s $FA!! metho!. Then enter the name o" the "unction mo!u e an! se ect 0ontinue.
Step * 'n the ne1t !ia og bo1( "o o&ing in"ormation nee!s to be speci"ie!6
1& 2ethod 3 Suggest an appropriate name "or the metho!( ,& "e-ts 6 5nter !escription "or the BAP' *& ;adio buttons3 7ia og( Synchronous( an! 'nstance$in!epen!ent. BAP'Us are usua y imp emente! synchronous y.
Step ) To create the metho! se ect Des in the ne1t !ia og bo1.
Step= A"ter the program has been generate! an! e1ecute!( check the program in the metho! #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 the Business -b#ect Bui !er. 2or one can use the transaction US.C7) to test the metho!3. ;eleasing and /reeKing the API To re ease the BAP'( "irst re ease the "unction mo!u e 2using transaction se,L3 . Set the status o" the metho! to Ure ease!) in the Business -b#ect Bui !er 2using transaction S.o1 * 5!it$F change status$F re ease!.3 Dou can a so use the BAP' 51p orer 2Transaction co!e BAP'3 "or ,H0Z %ie& on BAP' ;;;;
Chapter ,1 # ;4C
'hat is ;4C> A Remote 8unction 0a 2R803 is a ca to a "unction mo!u e running in a system !i""erent "rom the ca er)s. The remote "unction can a so be ca e! "rom &ithin the same system 2as a remote ca 3.The R80 inter"ace pro%i!es the abi ity to ca remote "unctions. R80 consists o" t&o inter"aces6 1. A ca ing inter"ace "or ABAP Programs 2. A ca ing inter"ace "or /on$SAP programs.
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 te s the SAP System that the ca e! "unction runs in a system other than the ca er)s. Synta1$ (A00 C>N(TIFN DremotefunctionL D'6TINATIFN #e&t 'K<F@TIN/ f1 = IB<F@TIN/ f* = TA;0'6 t1 = 'K('<TIFN6 :ogica 7estinations are !e"ine! %ia transaction S>KM an! store! in Tab e R8075S 8unctions o" the R80 inter"ace 0on%erting a parameter !ata to the representation nee!e! in the remote system 0a ing the communication routines nee!e! to ta k to the remote system. Han! ing communications errors( an! noti"ying the ca er( i" !esire! 2using 5P05PT'-/S paramater o" the 0A:: 8C/0T'-/3.
,. 7e"ine the !estination o" the R80 ser%er in the R80 c ient system that ca s the remote "unction 2%ia S>KM transaction3.
4. !eclaring Parameters6 A parameter "ie !s "or a remote "unction mo!u e must be !e"ine! as re"erence "ie !s( that is( ike ABAP 7ictionary "ie !s. K. E-ceptions3 The system raises 0->>C/'0AT'-/A8A':CR5 an! SDST5>A8A':CR5 interna y. Dou can raise e1ceptions in a remote "unction #ust as you &ou ! in a oca y ca e! "unction. !ebugging ;emote 4unction Calls 't is not possib e to !ebug a remote "unction ca to another system. Ho&e%er( &hen testing ABAP$to$ABAP R80 ca s( you can use the ABAP !ebugger to monitor the e1ecution o" the R80 "unction in the remote system. .ith remote ca s( the ABAP !ebugger 2inc u!ing the !ebugging inter"ace3 runs on the oca system. 7ata %a ues an! other run in"ormation "or the remote "unction are passe! in "rom the remote system. ;;;;
Krishna is a 0omputer 5ngineer an! a SAP 0onsu tant. He has o%er I years o" e1perience &orking "or many >/0)s. Recent y ( he 4uit is cushy #ob an! is on a mission to make e!ucation "un an! "ree. This book is a step in that !irection 0onnect &ith CS T&itter 6 http6++t&itter.com+SAPTHub 8acebook6 http6++&&&."acebook.com+pages+Sap$Training$Hub+1,MH,221H0M2IH4 B og6 http6++&&&.saptraininghub.com+