Вы находитесь на странице: 1из 7

Passing table data to the layout without changing the driver program

By Joyjit Ghosh, IBM India I have seen a typical requirement from client that SAP script layout need to be chan ed !additional data need to be displayed" #ithout modifyin the driver pro ram !mainly standard SAP pro ram"$ %his tip #ill sho# us ho# to pass table data !multiple records at a time" to layout #ithout chan in the driver pro ram$ Step&$ 'reate a standard te(t from S)&*$ 'reate a blan+ standard te(t$ %his #ill store the table data

Step,$ 'reate a subroutine pool and a routine in it that can be called from SAP script$ -rom transaction S./0 create a subroutine pool$

1o# create subroutine #ith proper interface to fetch the data from the table$

Step/$ 2ithin this routine #rite the lo ic to fetch the table data and populate the standard te(t$ *************************************************************** * Fetch table data and upload the data in proper format to the * standard text *************************************************************** DATA: i_zemployee TYPE TA!DA"D TA#$E %F zemployee &!&T&A$ &'E () *_zemployee TYPE zemployee) i_text TYPE TA!DA"D TA#$E %F tline &!&T&A$ &'E () *_header $&+E thead) *_text TYPE tline, -%! TA!T : c_par TYPE char. /A$0E 1))1, 2 i3n for tabs * Fetch data for employee E$E-T * F"%4 zemployee &!T% TA#$E i_zemployee,

* * *

* * * * * *

&F sy5subrc 6 (, -reate text table $%%P AT i_zemployee &!T% *_zemployee, tore default para3raph format *_text5tdformat 6 1*1, Add all the re7uired fields separated by tab -%!-ATE!ATE *_zemployee5empno *_zemployee5empname &!T% *_text5tdline EPA"ATED #Y c_par, tore table data APPE!D *_text T% i_text, E!D$%%P, chec8 sy5subrc 6 (, Populate header info Text ob9ect *_header5tdob9ect 6 1TE:T1, tandard text name *_header5tdname 6 1'_TA#$E_DATA1, Text id *_header5tdid 6 1 T1, $an3ua3e *_header5tdspras 6 1E1, Populate the standard text *ith table data -A$$ F0!-T&%! 1 A/E_TE:T1 E:P%"T&!; header 6 *_header insert 6 1:1 sa<emode_direct 6 1:1 TA#$E lines 6 i_text E:-EPT&%! id 6 = lan3ua3e 6 . name 6 > ob9ect 6 ? %T@E" 6 A , &F sy5subrc BC (, E!D&F, E!D&F,

Step3$ 'all the routine and standard te(t from the SAP script layout$ Note: For the sake of simplicity this tip is shown in a custom layout that is called from a custom report. D* D: D: D: D: D* D: -all the routine PE"F%"4 FET-@_TA#$E_DATA &! P"%;"A4 '_ 0#"%0T&!E_P%%$ 0 &!; E&!/A"=E -@A!;&!; E%0T/A"=E E!DPE"F%"4 !o* call the standard text &!-$0DE '_TA#$E_DATA %#FE-T TE:T &D T $A!;0A;E E!

Step4$ %est the SAP script form Activate the SAP script debu er

5un the custom report to test the SAPscript layout$ *E555555555555555555555555555555555555555555555555555555555555555* *E "eport '_TE T_ AP- "&PT *E555555555555555555555555555555555555555555555555555555555555555* "EP%"T '_TE T_ AP- "&PT , start5of5selection, -A$$ F0!-T&%! 1%PE!_F%"41 E:P%"T&!; DE/&-E 6 1P"&!TE"1 D&A$%; 6 1:1 F%"4 6 1'_DE4%_$AY%0T1 $A!;0A;E 6 Y5$A!;0 E:-EPT&%! -A!-E$ED 6 = DE/&-E 6 . F%"4 6 > %PT&%! 6 ? 0!-$% ED 6 A 4A&$_%PT&%! 6 G

A"-@&/E_E""%" 6 H &!/A$&D_FA:_!04#E" 6 I 4%"E_PA"A4 _!EEDED_&!_#AT-@ 6 J P%%$_E""%" 6 =( -%DEPA;E 6 == %T@E" 6 =. , &F sy5subrc 6 (, -A$$ F0!-T&%! 1K"&TE_F%"41 E:P%"T&!; E$E4E!T 6 1((=1 F0!-T&%! 6 1 ET1 TYPE 6 1#%DY1 K&!D%K 6 14A&!1 * &4P%"T&!; * PE!D&!;_$&!E 6 E:-EPT&%! E$E4E!T 6 = F0!-T&%! 6 . TYPE 6 > 0!%PE!ED 6 ? 0! TA"TED 6 A K&!D%K 6 G #AD_PA;EF%"4AT_F%"_P"&!T 6 H P%%$_E""%" 6 I -%DEPA;E 6 J %T@E" 6 =( , &F sy5subrc BC (, * 4E A;E &D Y54 ;&D TYPE Y54 ;TY !04#E" Y54 ;!% * K&T@ Y54 ;/= Y54 ;/. Y54 ;/> Y54 ;/?, E!D&F, -A$$ F0!-T&%! 1-$% E_F%"41 E:-EPT&%! 0!%PE!ED 6 = #AD_PA;EF%"4AT_F%"_P"&!T 6 . E!D_E""%" 6 > P%%$_E""%" 6 ? -%DEPA;E 6 A %T@E" 6 G , &F sy5subrc BC (, * 4E A;E &D Y54 ;&D TYPE Y54 ;TY !04#E" Y54 ;!% * K&T@ Y54 ;/= Y54 ;/. Y54 ;/> Y54 ;/?, E!D&F, E!D&F, After e(ecution of this report SAPscript debu er is tri ered$

As sho#n belo# layout is callin the code #ritten in the routine

Standard te(t is populated #ith the data fetched from table

)utput of SAP script6

%able entries6