Sunteți pe pagina 1din 15

SAP R/3 Release 4.

7
Solutions: SAPScript SAP Development ABAP Training
Exercise
!utput Program name " YSPXXOUTPROG_1
SAPScript #orm $ame YSPXXFORM_1
Steps To %reate t&e SAPScript #orm:
Go to Transaction SE71.
Type the Form name an press the create !"tton.
The #eaer Section o$ the S%PScript Form &i'' appear.
Gi(e a )escription o$ the pro*ram an c'ic+ the sa(e !"tton to sa(e the pro*ram in the
appropriate pac+a*e an ,TS.
-o& c'ic+ on the Pa*es !"tton an *o to the Pa*es section o$ the $orm.
Use the men" path Eit ./ ,reate e'ement to create a ne& pa*e 0P%GE1 in this case1.
Speci$y the ne2t pa*e as P%GE1 itse'$ !eca"se &e &i'' "se on'y one pa*e. 3ea(e rest o$
the $ie's to their e$a"'t (a'"es.
March 4556
Pa*e 1
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
-o& c'ic+ on the Para*raph $ormats !"tton an create the necessary para*raph $ormats.
7n o"r case8 &e &i'' "se 9 para*raph $ormats P18 P48 P9 $or the #eaer8 Footer an Main
&ino&s respecti(e'y. The &ino&s &i'' !e create 'ater. Use the men" path Eit ./
,reate E'ement to create the para*raph $ormats.
March 4556
Pa*e 4
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
Gi(e appropriate (a'"es to the attri!"tes o$ the para*raph $ormats 'i+e Font $ami'y8 Font
si:e8 ;o'<7ta'ic<Uner'ine8 Ta! positions etc. The main &ino& is re="ire to o"tp"t the
'ine items o$ a ta!'e8 so yo" ha(e to speci$y Ta! positions $or the para*raph P9 &hich is
the e$a"'t para*raph $or the main &ino&. For the other t&o para*raph $ormats8 yo"
nee not speci$y the Ta! positions.
March 4556
Pa*e 9
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
-o& sa(e the S%PScript Form once a*ain an *o to the heaer section. ,'ic+ on the
icon &ith a pict"re o$ a #at or press F6 to *o to #eaer Section.
,'ic+ on the ;asic Settin*s !"tton an *i(e the (a'"e P%GE1 $or First Pa*e an *i(e P9
as )e$a"'t para*raph. >eep rest o$ the $ie's to their e$a"'t (a'"es.
March 4556
Pa*e ?
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
-o& ,'ic+ on the ,haracter $ormats !"tton to create the ,haracter $ormats neee $or
this pro*ram.
March 4556
Pa*e 6
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
@e are "sin* 9 ,haracter Formats in o"r pro*ram. The ,haracter $ormat % is ;o' an
3ar*e si:e &hich is "se to print the te2t A7n(oice PrintB8 ,haracter $ormat ; &i'' !e "se
$or !o' te2ts &ith sma'' $ont si:e an ,haracter $ormat , is "se $or the pa*e no. part o$
the $ooter &ino&. Gi(e appropriate $ont si:e an ;o'<7ta'ic<Uner'ine as neee.
-o& &e &i'' create the &ino&s necessary to the S%PScript Form. @e &i'' create 9
&ino&s #)R 0#eaer @ino&18 M%7- 0Main @ino&1 an FTR 0Footer @ino&1. To
create the &ino&s an *i(e them appropriate si:es8 &e &i'' "se the Graphica' Form
Painter.
Use the men" path Settin*s ./ Form Painter. On c'ic+in* the men"8 yo" &i'' *et one
pop"p screen in &hich yo" ha(e to chec+ the Graphica' Form Painter ,hec+!o2 an
"nchec+ the Graphica' P, Eitor chec+!o2 an press CEnterD. -o& yo" &i'' *et the
Graphica' Form Painter.
March 4556
Pa*e E
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
First &e ha(e to create one Graphics o!Fect $or the 7;M 'o*o. To create this8 "se
transaction SE7G.
%$ter creatin* the Graphics o!Fect8 ri*ht c'ic+ on the 3ayo"t Eitor an se'ect the men"
A,reate *raphicB. % screen &i'' appear8 &here yo" ha(e to choose the Graphics o!Fect
yo" nee.
March 4556
Pa*e 7
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
%$ter choosin* the Graphic o!Fect8 press AEnterB. On the 3ayo"t yo" can see one !'"e
rectan*'e representin* the *raphic o!Fect. -o& mo(e or resi:e that rectan*'e as per yo"r
re="irement on the 'ayo"t set.
-o& &e &i'' create 9 &ino&s on the 'ayo"t. Ri*ht c'ic+ on the 'ayo"t an se'ect A,reate
&ino&B men". % &hite rectan*'e &i'' appear on the top 'e$t han corner o$ the 'ayo"t.
-o& )ra* the &ino& to appropriate position an *i(e it appropriate shape. Yo" can
chan*e the name8 escription8 type8 si:e8 an position etc o$ the &ino& $rom the 'e$t
han sie o$ the screen. % screenshot is sho&n !e'o& &ith a'' the &ino&s create.
March 4556
Pa*e G
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
-o& come !ac+ to the Graphica' P, Eitor "sin* the men" path Settin*s ./ Form
painter. Yo" &i'' see that a'' the &ino&s $or the pa*e P%GE1 are sho&n in the Pa*e
@ino&s section.
-o& o"!'e c'ic+ on #)R &ino& an c'ic+ on the Te2t e'ements !"tton or press FH. Yo"
&i'' 'an "p on the !asic eitor &here &e ha(e to a the coe $or the &ino&. Use the
men" path Goto ./ ,han*e eitor to *et the secon $orm o$ eitor &hich is easy to "se.
March 4556
Pa*e H
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
The screen shot a!o(e sho&s the coe ae to the #)R &ino&. The har coe te2t
A)ateIB is enc'ose &ithin character $ormat ;. @e ha(e to sho& the ate8 thatDs &hy &e
ha(e "se the S%P system $ie' JSY.)%TUMJ. The te2t A7n(oice PrintB is em!ee
&ithin character $ormat %.
Fo''o& the same path $or the rest o$ the &ino&s to *o to their corresponin* eitors an
a coe there.
March 4556
Pa*e 15
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
7n the M%7- &ino&8 &e ha(e printe the in(oice n"m!er &hich is comin* $rom the
se'ection screen o$ the o"tp"t pro*ram. @e are "sin* JSY.U-%MEJ system $ie' $or
printin* the name o$ the person. @e ha(e "se C88D separate har coe te2ts $or the
co'"mn names o$ the ta!'es. C88D represents ta! separation. The corresponin* ta!
positions ha(e !een speci$ie in the para*raph $ormat P9. @e ha(e "se one Te2t
E'ement CTEXT_E3ED &hich is repeate'y ca''e $rom the o"tp"t pro*ram to print the
contents o$ the interna' ta!'e.
March 4556
Pa*e 11
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
7n the FTR &ino&8 &e ha(e ae some har coe te2ts. The pa*e n"m!er in CPa*e 2
o$ 2D $ormat is printe "sin* t&o S%PScript Form sym!o's JP%GEJ an JS%PS,R7PT.
FORMP%GESJ.
T&e !utput Program:
The o"tp"t pro*ram $irst *ets the (a'"e o$ in(oice n"m!er $rom the "ser thro"*h a
se'ection screen. -o& it "ses that (a'"e to retrie(e ata $rom the ata!ase an stores it
in an interna' ta!'e. The coe snippet is *i(en !e'o&.
TYPESI ;EG7- OF T%;8
POS-R 37>E K;RP.POS-R8
M%T-R 37>E K;RP.M%T-R8
F>7MG 37>E K;RP.F>7MG8
KR>ME 37>E K;RP.KR>ME8
-ET@R 37>E K;RP.-ET@R8
E-) OF T%;.
P%R%METERSI 7-KO7,E 37>E K;RP.K;E3-.
March 4556
Pa*e 14
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
)%T%I 7_T%; TYPE ST%-)%R) T%;3E OF T%; 7-7T7%3 S7LE 5 @7T# #E%)ER
37-E8
UP TYPE P )E,7M%3S 4 K%3UE 5.
SE3E,T POS-R M%T-R F>7MG KR>ME -ET@R FROM K;RP 7-TO T%;3E
7_T%; @#ERE
K;E3- M 7-KO7,E.
7F SY.SU;R, N/ 5.
MESS%GE 7555 0YTR%;%PMSG1 @7T# O7-KO7,E -O. )OES -OT EX7STO.
3E%KE 37ST.PRO,ESS7-G.
E-)7F.
-o& the $"nction mo"'e OPE-_FORM is ca''e. Form name is speci$ie in the
EXPORT7-G parameter FORM.
,%33 FU-,T7O- OOPE-_FORMO
EXPORT7-G
P %PP37,%T7O- M OTXO
P %R,#7KE_7-)EX M
P %R,#7KE_P%R%MS M
P )EK7,E M OPR7-TERO
P )7%3OG M OXO
FORM M OYSPXXFORM_1O
P 3%-GU%GE M SY.3%-GU
P OPT7O-S M
P M%73_SE-)ER M
P M%73_RE,7P7E-T M
P M%73_%PP3_O;QE,T M
P R%@_)%T%_7-TERF%,E M OPO
P SPO-UM7K M
P 7MPORT7-G
P 3%-GU%GE M
P -E@_%R,#7KE_P%R%MS M
P RESU3T M
EX,EPT7O-S
,%-,E3E) M 1
)EK7,E M 4
FORM M 9
OPT7O-S M ?
U-,3OSE) M 6
M%73_OPT7O-S M E
%R,#7KE_ERROR M 7
7-K%37)_F%X_-UM;ER M G
MORE_P%R%MS_-EE)E)_7-_;%T,# M H
SPOO3_ERROR M 15
,O)EP%GE M 11
March 4556
Pa*e 19
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
OT#ERS M 14
.
7F sy.s"!rc N/ 5.
P MESS%GE 7) SY.MSG7) TYPE SY.MSGTY -UM;ER SY.MSG-O
P @7T# SY.MSGK1 SY.MSGK4 SY.MSGK9 SY.MSGK?.
E-)7F.
Then8 &hi'e 'oopin* at 7_T%;8 Unit Price is ca'c"'ate an @R7TE_FORM is ca''e in each
iteration.
3OOP %T 7_T%;.
7F 7_T%;.F>7MG N/ 5.
UP M 7_T%;.-ET@R < 7_T%;.F>7MG.
E3SE.
UP M 5.
E-)7F.
,%33 FU-,T7O- O@R7TE_FORMO
EXPORT7-G
E3EME-T M OTEXT_E3EO
P FU-,T7O- M OSETO
P TYPE M O;O)YO
@7-)O@ M OM%7-O
P 7MPORT7-G
P PE-)7-G_37-ES M
EX,EPT7O-S
E3EME-T M 1
FU-,T7O- M 4
TYPE M 9
U-OPE-E) M ?
U-ST%RTE) M 6
@7-)O@ M E
;%)_P%GEFORM%T_FOR_PR7-T M 7
SPOO3_ERROR M G
,O)EP%GE M H
OT#ERS M 15
.
7F sy.s"!rc N/ 5.
P MESS%GE 7) SY.MSG7) TYPE SY.MSGTY -UM;ER SY.MSG-O
P @7T# SY.MSGK1 SY.MSGK4 SY.MSGK9 SY.MSGK?.
E-)7F.
Then at 'ast ,3OSE_FORM is ca''e to c'ose the $orm.
,%33 FU-,T7O- O,3OSE_FORMO
P 7MPORT7-G
P RESU3T M
P R)7_RESU3T M
P T%;3ES
March 4556
Pa*e 1?
SAP R/3 Release 4.7
Solutions: SAPScript SAP Development ABAP Training
P OTF)%T% M
EX,EPT7O-S
U-OPE-E) M 1
;%)_P%GEFORM%T_FOR_PR7-T M 4
SE-)_ERROR M 9
SPOO3_ERROR M ?
,O)EP%GE M 6
OT#ERS M E
.
7F sy.s"!rc N/ 5.
P MESS%GE 7) SY.MSG7) TYPE SY.MSGTY -UM;ER SY.MSG-O
P @7T# SY.MSGK1 SY.MSGK4 SY.MSGK9 SY.MSGK?.
E-)7F.
R"n the O"tp"t Pro*ram an chec+ the o"tp"t in APrint Pre(ie&B.

March 4556
Pa*e 16

S-ar putea să vă placă și