Sie sind auf Seite 1von 12

Sap script:

SAP SCRIPT
SAP Script is a tool which is used to printable business documents in SAP like invoice
form, Sales Order form, eliver! form, other form related to "R etc#
Scripts are older version of SAP print forms, advanced version to scripts are smartforms$
we will learn in ne%t chapters &#
SAP Scripts are client dependent, that is if we develop a script in client '((, it will not be
visible in other clients like )((, *((#
Advanced version of scripts, smartforms are client independent, the! will be visible in all
clients#
+h! SAP Scripts are client dependent ,
If we -enerate a SAP Script, it will be internall! stored as te%ts#
Te%ts are nothin- but a data, as per SAP all data is client dependent, so SAP Scripts are
client dependent#
S./* is the T0code for SAP scripts#
Components of SAP Scripts
*# "eader $ Administrative data and basic settin-s &#
'# Pa-es#
)# +indows#
1# Pa-e windows#
2# Para-raph format#
3# Character 4ormat#
/# 5a!out#
"eader
It contains header information of SAP Script i:e administrative data and basic settin-s of
SAP script#
Administrative Data: It contains administrative data like packa-e, client, user and
lan-ua-e#
Basic Settings: It contains settin-s like pa-e format, 6rst pa-e, default para-raph etc#
Pa-es
SAP Script is a -roup of pa-es, each pa-e contains la!out#
The la!out is used to desi-n pa-e#
Pa-e is a -roup of windows#
In SAP Scripts we can create 77 pa-es onl!#
+indows
A window is a container which contains some information to displa!, the entire pa-e is
desi-ned usin- windows#
There are four t!pes of windows#
Main window:
A +indow which automaticall! e%pands dependin- upon the data is called main window#
.ach pa-e contains onl! one main +indow#
As there are 77 pa-es onl! in scripts, we can have ma%imum 77 main windows onl! The
main +indow data is divided into blocks called as te%t elements#
Text Element:
It is used to displa! the speci6c block of information#
Te%t elements are represented b! 8.
The entire main +indow data is divided into blocks called as te%t elements#
9ow,ispla! a particular te%t element, so that onl! that speci6c info related to te%t
element is displa!ed#
Constant Window:
A +indow which is constant for all the pa-es is called constant +indow#
Variable Window:
A +indow which does not e%pand i#e#, width and hei-ht is 6%ed #
Grapical Window:
A window which is used to displa! -raphics or ima-es#
Pa-e windows:
The windows assi-ned to particular pa-e are called pa-e windows#
Para-raph format :
It is used to specif! a particular format $font si:e8famil!8;old8italic8underlined& for all the
characters in a para-raph #
+e can also specif! TA;S#
Tabs : Tabs are used to specif! a position in sap script so that the te%t will be displa!ed
at that particular position#
Tabs are represented b! ,, $' commas&#
Character format :
A format which is used b! a -roup of characters inside a para-raph is called a character
format #
5a!out:
It is a place where we desi-n the pa-e with windows#
4unction <odules used in SAP Scripts
+e use some function modules to develop SAP Scripts, e%plained below#
OP.9=4OR<
This is used to open a form for e%ecution b! loadin- it into memor!#
+RIT.=4OR<
It is used to write Some information on the SAP Script form usin- Te%t .lement#
C5OS.=4OR<
It is used to close the form which is opened b! open form#
START=4OR<
It is used to call another SAP Script into current SAP Script$9ested Scripts&#
.9=4OR<
It is used to end the form which started b! START=4OR<#
river Pro-ram
A pro-ram which contains business lo-ic statements i#e#, all select statements
,loops,appends etc, is called river pr-#
In simple words, a pro-ram which is used to drive or print the script#
All the variables ,work areas ,internal tables which are declared in the driver pro-ram
will be automaticall! transferred to SAP Scripts#
If we want to displa! the variables or workarea values we need to follow below s!nta%#
S!nta% : >variable>
>workarea0fname>
? 0
Re@uirement: evelop a purchase order with 5o-o, Address and pa-e no#
A !eal Time Scenario on "#rcase $rder SA" Script %orm
Business Req : Create a PO form with the below layout.
Please follow the below steps
Step * : Create a Pa-e b! name PAA.*
Step ' : Create Re@uired no of +indow as per the la!out -iven
Step ): Create Pa-e +indows and specif! hei-ht8width
Step 1 : Create Para-raph 4ormats
Step 2 : Create a TA;S for Para-raph 4ormats
Step 3 : Create a Character 4ormat
Step / : +rite the code for Printin- "eadin-s, 5ine item information, Arand total in
<ainwindow
Step B : +rite the code for Printin- Cendor address in Address window
Step 7 : +rite the code for Printin- 4ooter information in 4ooter window
Step *( : +rite the code for Printin- 5o-o in 5o-o window
Step ** : Similarl!, +rite the code for Printin- PO etails8Pa-e9o8Title
Step *' : Print the standard te%t usin- SO*( Tcode
Step*) : Arran-e all the windows as per the -iven 5a!out#
Step*1 : Create a river Pro-ram
Step*2 : .D.CET. T". driver pro-ram
Step*3 : Create a Second Pa-e 5a!out
Step*/ : Increase the hei-ht of <AI9 window
Step*B : Printin- Terms>Conditions usin- START4OR< A9 .9 4OR<
Step*7 : Chan-e the river Pro-ram for usin- START4OR< A9 .9 4OR<
Detailed Steps:
*# Se/*0FAive formname 0FGC=PO 0Fcreate#
'# -ive <eanin-0Fclick on ;ASIC settin-s#
)# Select pa-e format 8landscape
Step & : Create a "age b' name "AGE&
1# Click on PAA.S0F.IT0FCRAT. .5.<.9T0F-ive pa-e as pa-e* and meanin- as
pa-e*0FFAive 9e%t Pa-e as Pa-e*
2# click on +I9O+S$b! default, main window will be added&
Step ( : Create !e)#ired no o* Window as per te la'o#t given
3# click on .IT0Fcreate element0F-ive window name as TIT5. and meanin- as title#
Repeat the same step and add the below windows#

Step +: Create "age Windows and speci*' eigt,widt
/# Click on Pa-e windows0F .IT0FCRAT. .5.<.9T0Fouble click on each window so
that the window would be added to the pa-e# Aive the appropriate hei-ht, width,
left8ri-ht mar-in as below for each window
Step - : Create "aragrap %ormats
Create the 1 para-raph 4ormats as below#
Step . : Create a TABS *or "aragrap %ormats
Aive Tabs for ".A.R para-raph format as below #
And the 1
th
tab as 22 chars ri-ht Husti6ed #
Aive font famil! as COERI.R A9 si:e as *' for all para-raph formats, e%cept for TIT5.
para-raph# Aive *3 for this TIT5. para-raph#
Step / : Create a Caracter %ormat
Create character format as below #
Step 0 : Write te code *or 1eadings2 3ine item in*ormation2 Grand total in
Mainwindow
Aoto0FPa-ewindows0Fouble click on main window and click on te%teditor0
C5ICI O9 AOTO C"A9A. .ITOR000Fwrite the below code#
"ereJKL
8:TOPJKL.9TOP is used to print header information in the main window so that the it
Mows on to ever! pa-e #
8.NO ;OP0000this is used to print bod!# All the line item values #
8.0Total0000used to print total at the end of main window ##
This element is called after the loop##endloop##so that Arand total is printed immediatel!
After the main window #
Step 4 : Write te code *or "rinting Vendor address in Address window
Aoto0FPa-ewindows0Fouble click on ADD!ESS window and click on te%teditor0
Fwrite the below code#
Step 5 : Write te code *or "rinting %ooter in*ormation in %ooter window
Aoto0FPa-ewindows0Fouble click on %$$TE! window and click on te%teditor0Fwrite
the below code#
4T00>E5I9.$3(&>
4T00A55 RIA"TS R.S.RC. TO QC*FI;<Q8F I9IA PCT#5T
"ere 4T is para-raph format And
C* is char format with bold#
Step &6 : Write te code *or "rinting 3ogo in 3ogo window
Aoto0FPa-ewindows0Fouble click on 3$G$ window and click on te%teditor0Fwrite
the below code or Click on I9S.RT0FARAP"ICS0FSelect Stored on ocument
Server0FAive 9ame RI;<R$Ima-e name Eploaded throu-h S./B&0F
Aive obHect : G!A"17CS
I : ;<AP
Select color ;itmap Ima-e0FPress Continue0Fthe ;elow s!nta% will come
automaticall!
;IT<AP RI;<R O;S.CT ARAP"ICS I ;<AP TPP. ;CO5
Step && : Similarl'2 Write te code *or "rinting "$ Details,"age8o,Title
Similarl!, for all windows write the below code in the te%t editor
Aoto0FPa-ewindows0Fouble click on "$98$ window and click on te%teditor0Fwrite
the below code
400 PO 9o : >wa=ekko0ebeln>
400 PO ate : >wa=ekko0aedat>
Aoto0FPa-ewindows0Fouble click on "AGE98$ window and click on te%teditor0
Fwrite the below code
400Pa-e#9o : >PAA.>8>SAPSCRIPT04OR<PAA.S$C&>
Aoto0FPa-ewindows0Fouble click on T7T3E window and click on te%teditor0Fwrite
the below code
T50000Purchase Order
Step &( : "rint te standard text #sing S$&6 Tcode
Aoto0FPa-ewindows0Fouble click on TE:T window and click on te%teditor0Fwrite the
below te%t#
+e can write the te%t directl! in the window# ;ut in the real time we use a concept
called standard Te%t#
So 5ets use the standard Te%t now#
Aoto SO*(0F-ive te%t name0Fclick on Create0F
C37C; $8 G$T$<=C1A8GE ED7T$!
Write te below text<=clic> on save<=go bac> and clic> on print preview?
Go bac> to script
Aoto0FPa-ewindows0Fouble click on TE:T window and click on te%teditor0Fwrite the
below te%t#
,: I9C5E. @V9"$9TE:T O;S.CT T.DT I ST
T"IS IS ST T.DT T"RE SO*( TD9#
Or
C5ick on Insert0FTe%t0FStandard0Fa pop will appear0F-ive te%t name as GC=PO=T.DT0
Fpress enter0F
The code will be displa!ed automaticall!#
Step&+ : Arrange all te windows as per te given 3a'o#t
4inall!, 5ets Re0arran-e all the window positions a-ain b! -oin- to Araphical 4orm
Painer#
Click on S.TTI9AS0F4OR< PAI9T.R0FSelect checkbo% Araphical 4orm Painter
And press enter
The form should look as below#
If not arran-e all the windows as below b! dra--in- and droppin-#
9ow -oback to PC .ITOR #
Save and activate script
Specif! default para-raph and 6rst pa-e
Save and activate script
Step&- : Create a Driver "rogram
And the driver pr- is :
R.PORT GC=PO=RIC.R#
TA;5.S : ARC,54A*,.IIO#
PARA<.T.RS : P=.;.59 TPP. .IIO0.;.59 #
TATA .C5ARATIO9S
ATA : +A=.IIO TPP. .IIO #
ATA : +A=.IPO TPP. .IPO #
ATA : IT=.IPO TPP. TA;5. O4 .IPO #
ATA : +A=54A* TPP. 54A* #
ATA : +A=ARC TPP. ARC #
ATA : C=TOT TPP. .IPO09.T+R #
TR.A PO ".A.R .TAI5S
S.5.CT SI9A5. T 4RO< .IIO
I9TO +A=.IIO
+".R. .;.59 U P=.;.59 #
TR.A PO IT.< .TAI5S
S.5.CT T 4RO< .IPO
I9TO TA;5. IT=.IPO
+".R. .;.59 U P=.;.59 #
R.A TA;5. IT=.IPO I9TO +A=.IPO I9.D *#
O *(( TI<.S #
APP.9 +A=.IPO TO IT=.IPO #
.9O#
TR.A C.9OR <AST.R ATA TO 4I9 T". AR.SS 9E<;.R
S.5.CT SI9A5. T 4RO< 54A* I9TO +A=54A* +".R. 5I49R U +A=.IIO05I49R #
S.5.CT SI9A5. T 4RO< ARC I9TO +A=ARC +".R. AR9E<;.R U +A=54A*0AR9R
#
TOP.9 T". 4OR<
CA55 4E9CTIO9 ROP.9=4OR<R
.DPORTI9A
4OR< U RGC=POR
5A9AEAA. U SP05A9AE#
TPRI9T .AC" IT.< I9 <AI9 +I9O+
5OOP AT IT=.IPO I9TO +A=.IPO #
TCA5C5EAT. ARA9 TOTA5
C=TOT U C=TOT ? +A=.IPO09.T+R #
+A=.IPO0<AT9R U RAPAC".0*3(R #
CA55 4E9CTIO9 R+RIT.=4OR<R
.DPORTI9A
.5.<.9T U R;OPR
+I9O+ U R<AI9R#
TPRII9T T".TOTA5 A4.TR A9I9 +I9O+ ;OP PAA.
AT 5AST #
CA55 4E9CTIO9 R+RIT.=4OR<R
.DPORTI9A
.5.<.9T U RTOTA5R
+I9O+ U R<AI9R#
.9AT#
.95OOP #
CA55 4E9CTIO9 RC5OS.=4OR<R#
Step&. : E:ECATE T1E driver program
.D.CET. T". driver pro-ram0FAive PO number as 1*2*2(B'')
and e%ecute0F;elow is the output #
Step&/ : Create a Second "age 3a'o#t
9ow Create a second Pa-e PAA.' and cop! the <ain +indow, Pa-e 9o +indow, 4ooter
+indow#
Click on PAA.S0F.IT0FCRAT. .5.<.9T0F-ive pa-e as pa-e' and meanin- as pa-e'0
FFAive 9e%t Pa-e as Pa-e'
ouble click on Pa-e*0F-ive ne%t pa-e as Pa-e'#
ouble click on Pa-e'0F-ive ne%t pa-e as Pa-e'#

/# Click on Pa-e windows0F Aive Pa-e as Pa-e'0FClick on .IT0FCRAT. .5.<.9T0
Fouble click on <ain +indow, Pa-e 9o +indow, 4ooter +indow so that the windows
would be added to the pa-e'#
Step&0 : 7ncrease te eigt o* MA78 window
9ow 5ets Re0arran-e the <AI9 window position i#e# Sust Increase the hei-ht of <AI9
window as below b! -oin- to Araphical 4orm Painer#
Click on S.TTI9AS0F4OR< PAI9T.R0FSelect checkbo% Araphical 4orm Painter

The form should look as below#
Save0Factivate the form and a-ain test it from river Pr-#
The Pa-e* Should look as below#
And the Pa-e' Should look as below#
AS78G STA!T%$!M A8D E8D %$!M
Step&4 : "rinting TermsBConditions #sing STA!T%$!M A8D E8D %$!M
Crate another Sap Script b! name GC=PO=T.R<S with below attributes#
Pa-e : Pa-e*
+indows : <ain +indow, Create a new window b! name T.R<S#
Pa-e +indows : Cop! <AI9 window and T.R<S windows onto pa-e* #
ouble click on the <ain +indow0F+rite the below te%t#
ouble click on the T.R<S +indow0F+rite the below te%t#
Create a title para-raph format and write the below te%t with font si:e '' points
Also create defuakt para-raph format with font si:e *3 points
Save , Activate the pro-ram#
e6ne irst pa-e and default para-raph
Step&5 : Cange te Driver "rogram *or #sing STA!T%$!M A8D E8D %$!M
+rite the below code in the above driver pro-ram i#e# Hust add the below code to the
above code CA55 4E9CTIO9 RC5OS.=4OR<R#
CA55 4E9CTIO9 R.9=4OR<R #
TThe start form is used to call a diVerent form for printin- TR.<S>CO9ITIO9S#
TThis for is reusable as it is onl! for printin-
T TR.<S>CO9ITIO9S
CA55 4E9CTIO9 RSTART=4OR<R
.DPORTI9A
T ARC"IC.=I9.D U ARC"IC.=I9.D
form U RGC=PO=T.R<SR
lan-ua-e U s!0lan-u
#
CA55 4E9CTIO9 R+RIT.=4OR<R
.DPORTI9A
element U RT.R<SR
window U R<AI9R#
CA55 4E9CTIO9 R.9=4OR<R #
CA55 4E9CTIO9 RC5OS.=4OR<R#
The Terms and conditions will be printed on the 5ast Pa-e #
T>000000000000000000000000000000000000000000000000000000000000000000000T
T> Report GC=PO=RIC.R
T>
T>000000000000000000000000000000000000000000000000000000000000000000000T
R.PORT GC=PO=RIC.R#
TA;5.S : ARC,54A*,.IIO#
PARA<.T.RS : P=.;.59 TPP. .IIO0.;.59 #
TATA .C5ARATIO9S
ATA : +A=.IIO TPP. .IIO #
ATA : +A=.IPO TPP. .IPO #
ATA : IT=.IPO TPP. TA;5. O4 .IPO #
ATA : +A=54A* TPP. 54A* #
ATA : +A=ARC TPP. ARC #
ATA : C=TOT TPP. .IPO09.T+R #
TR.A PO ".A.R .TAI5S
S.5.CT SI9A5. T 4RO< .IIO
I9TO +A=.IIO
+".R. .;.59 U P=.;.59 #
TR.A PO IT.< .TAI5S
S.5.CT T 4RO< .IPO
I9TO TA;5. IT=.IPO
+".R. .;.59 U P=.;.59 #
R.A TA;5. IT=.IPO I9TO +A=.IPO I9.D *#
O *(( TI<.S #
APP.9 +A=.IPO TO IT=.IPO #
.9O#
TR.A C.9OR <AST.R ATA TO 4I9 T". AR.SS 9E<;.R
S.5.CT SI9A5. T 4RO< 54A* I9TO +A=54A* +".R. 5I49R U +A=.IIO05I49R #
S.5.CT SI9A5. T 4RO< ARC I9TO +A=ARC +".R. AR9E<;.R U +A=54A*0AR9R
#
TOP.9 T". 4OR<
CA55 4E9CTIO9 ROP.9=4OR<R
.DPORTI9A
4OR< U RGC=POR
5A9AEAA. U SP05A9AE#
TPRI9T .AC" IT.< I9 <AI9 +I9O+
5OOP AT IT=.IPO I9TO +A=.IPO #
TCA5C5EAT. ARA9 TOTA5
C=TOT U C=TOT ? +A=.IPO09.T+R #
+A=.IPO0<AT9R U RAPAC".0*3(R #
CA55 4E9CTIO9 R+RIT.=4OR<R
.DPORTI9A
.5.<.9T U R;OPR
+I9O+ U R<AI9R#
TPRII9T T".TOTA5 A4.TR A9I9 +I9O+ ;OP PAA.
AT 5AST #
CA55 4E9CTIO9 R+RIT.=4OR<R
.DPORTI9A
.5.<.9T U RTOTA5R
+I9O+ U R<AI9R#
.9AT#
.95OOP #
CA55 4E9CTIO9 R.9=4OR<R #
TThe start form is used to call another SAP SCRIPT form for printin-
T.R<S>CO9ITIO9S#
TThis form can be reusable b! al forms as it is onl! for printin- TR.<S>CO9ITIO9S
CA55 4E9CTIO9 RSTART=4OR<R
.DPORTI9A
T ARC"IC.=I9.D U ARC"IC.=I9.D
4OR< U RGC=PO=T.R<SR
5A9AEAA. U SP05A9AE
#
CA55 4E9CTIO9 R+RIT.=4OR<R
.DPORTI9A
.5.<.9T U RT.R<SR
+I9O+ U R<AI9R#
CA55 4E9CTIO9 R.9=4OR<R #
CA55 4E9CTIO9 RC5OS.=4OR<R
#