PO to PDF Local fileUsing Sap Script
Hi Exports
I am trying new report po(sapscript) to pdf conversion in local system any sample code available
Thanks and regards
Suresh
Hi
Thanks for your Reply
In the following code how will change
*& SUBROUTINE-POOL ZPORDER *
INCLUDE fm06ptop.
TABLES: t001,adrc,kna1,lfa1,vbak,t005t,stxl,resb,makt,t685t,A053,T685.
DATA: t_xekkn LIKE ekkn OCCURS 0 WITH HEADER LINE,
t_xeket LIKE eket OCCURS 0 WITH HEADER LINE,
t_xekpo LIKE ekpo OCCURS 0 WITH HEADER LINE,
t_xkomv LIKE komv OCCURS 0 WITH HEADER LINE,
ctxt LIKE tline OCCURS 0 WITH HEADER LINE,
count TYPE i VALUE 0,
t_netwr TYPE ekkn-netwr,
werks like ekpo-werks,
t_totqty TYPE ekkn-menge,
qtytot type p decimals 3,
amttot type p decimals 2,
nettotal type p decimals 2,
t_itemdate(8) TYPE c,
w_ex(1),
t_itemdate1(8) TYPE c,
spstyp like ekpo-pstyp,
sknttp like ekpo-knttp,
KSCHL LIKE A053-KSCHL,
price like ekko-ebeln,
PO LIKE ekko-ebeln,
ICT TYPE N.
DATA tdname LIKE stxl-tdname.
data: ORDNO like vbkd-bstkd.
DATA :BEGIN OF v_term OCCURS 0,
content(20),
END OF v_term.
DATA :printtype(10) TYPE c.
MOVE-CORRESPONDING t_xekpo TO icond.
APPEND icond.
FORM entry_neu USING ent_retco ent_screen.
DATA: l_druvo LIKE t166k-druvo,
l_nast LIKE nast,
l_from_memory,
l_doc TYPE meein_purchase_doc_print.
CLEAR ent_retco.
printtype = nast-kschl.
IF nast-aende EQ space.
l_druvo = '1'.
ELSE.
l_druvo = '2'.
ENDIF.
CALL FUNCTION 'ME_READ_PO_FOR_PRINTING'
EXPORTING
ix_nast = nast
ix_screen = ent_screen
IMPORTING
ex_retco = ent_retco
ex_nast = l_nast
doc = l_doc
CHANGING
cx_druvo = l_druvo
cx_from_memory = l_from_memory.
PERFORM val_chk USING l_doc.
select sum( netwr ) into amttot from ekpo
where ebeln eq l_doc-xekko-ebeln and loekz eq ' '.
endselect.
SELECT single rlwrt INTO l_doc-xekko-rlwrt from ekko where EBELN eq nast-OBJKY.
price = amttot.
IF l_doc-xekko-frgke EQ 'R' OR PRICE EQ 0.
PERFORM display_sscript USING l_doc.
ELSE.
if sy-ucomm EQ 'PRNT' .
MESSAGE ID '8E' TYPE 'E' NUMBER '000'
WITH 'P.O has not been released'.
ENDIF.
endif.
ENDFORM. "entry_neu
& Form DISPLAY_SSCRIPT &
& Display SAP Script &
FORM display_sscript USING l_doc.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
device = 'PRINTER'
dialog = 'X'
form = 'ZPORDER_FORM'
language = sy-langu
EXCEPTIONS
canceled = 1
device = 2
form = 3
options = 4
unclosed = 5
OTHERS = 11.
PERFORM header_disp USING l_doc.
PERFORM main_disp USING l_doc.
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
unopened = 1
OTHERS = 5.
ENDFORM. " DISPLAY_SSCRIPT
& Form HEADER_DISP &
& CHECKING Header Part &
FORM val_chk USING l_doc TYPE meein_purchase_doc_print .
PO = l_doc-xekko-ebeln.
ENDFORM.
& Form HEADER_DISP &
& Display Header Part &
FORM header_disp USING l_doc TYPE meein_purchase_doc_print .
DATA : cst(30),
tngst(30).
CLEAR : ICT.
*ADDRESS
SELECT SINGLE adrnr INTO (t001-adrnr) FROM t001
WHERE bukrs EQ l_doc-xekko-bukrs.
*<--Modified by Bala Manikandan--
>
SELECT SINGLE name1 street city1 post_code1 country
tel_number fax_number str_suppl1 str_suppl2
INTO (adrc-name1,adrc-street,adrc-city1,
adrc-post_code1,adrc-country,adrc-tel_number,
adrc-fax_number,adrc-str_suppl1,adrc-str_suppl2)
FROM adrc WHERE addrnumber EQ t001-adrnr.
*VENDOR
SELECT SINGLE anred name1 stras ort01 ort02 pstlz land1
INTO (lfa1-anred,lfa1-name1,lfa1-stras,lfa1-ort01,lfa1-ort02,
lfa1-pstlz,lfa1-land1)
FROM lfa1 WHERE lifnr EQ l_doc-xekko-lifnr.
SELECT SINGLE landx FROM t005t INTO t005t-landx
WHERE land1 EQ lfa1-land1 AND
spras EQ 'EN'.
PERFORM set_text_symbol USING:
'&ADRC-NAME1&' adrc-name1,
'&ADRC-STR_SUPPL1&' adrc-str_suppl1,
'&ADRC-STR_SUPPL2&' adrc-str_suppl2,
'&ADRC-STREET&' adrc-street,
'&ADRC-CITY&' adrc-city1,
'&ADRC-POST_CODE1&' adrc-post_code1,
'&ADRC-COUNTRY&' adrc-country,
'&ADRC-TEL_NUMBER&' adrc-tel_number,
'&ADRC-FAX_NUMBER&' adrc-fax_number,
'&LFA1-NAME1&' lfa1-name1,
'&LFA1-ANRED&' lfa1-anred,
'&LFA1-STRAS&' lfa1-stras,
'&LFA1-ORT01&' lfa1-ort01,
'&LFA1-ORT02&' lfa1-ort02,
'&LFA1-PSTLZ&' lfa1-pstlz,
'&t005t-landx&' t005t-landx,
'&LFA1-NAME1&' lfa1-name1,
'&L_DOC-XEKKO-EBELN&' l_doc-xekko-ebeln,
'&L_DOC-XEKKO-AEDAT&' l_doc-xekko-aedat,
'&L_DOC-XEKKO-BEDAT&' l_doc-xekko-bedat.
select single werks into werks from ekpo
where ebeln eq l_doc-xekko-ebeln.
perform set_text_symbol using:
'&werks&' werks.
IF l_doc-xekko-bukrs EQ 'JKCH'.
cst = '611805'.
tngst = '2500907'.
ENDIF.
PERFORM set_text_symbol USING:
'&CST&' cst,
'&TNGST&' tngst.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'PDF'
function = 'SET'
window = 'PDF'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TITLE'
function = 'SET'
window = 'TITLE'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'FMNO'
function = 'SET'
window = 'FMNO'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'LOGO'
function = 'SET'
window = 'LOGO'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'VENDOR'
function = 'SET'
window = 'VENDOR'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_HEADER'
function = 'SET'
window = 'HITEM'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'FOOTER1'
function = 'SET'
window = 'WINDOW1'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'FOOTER2'
function = 'SET'
window = 'WINDOW2'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
select single pstyp knttp into (spstyp, sknttp)
from ekpo where ebeln eq l_doc-xekko-ebeln.
PERFORM set_text_symbol USING:
'&pstyp&' spstyp,
'&knttp&' sknttp.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'PORDER'
function = 'SET'
window = 'WINDOW4'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
ENDFORM. " HEADER_DISP
& Form MAIN_DISP &
& Main window Display &
FORM main_disp USING l_doc TYPE meein_purchase_doc_print .
DATA: BEGIN OF zekpo,
matnr LIKE ekpo-matnr,
meins LIKE ekpo-meins,
menge LIKE ekpo-menge,
netwr LIKE ekpo-netwr,
brtwr LIKE ekpo-brtwr,
netpr LIKE ekpo-netpr,
txz01 LIKE ekpo-txz01,
vbeln LIKE ekkn-vbeln,
vbelp LIKE ekkn-vbelp,
eindt LIKE eket-eindt,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
mwskz LIKE ekpo-mwskz,
Txjcd like ekpo-Txjcd,
charg LIKE eket-charg,
pstyp LIKE ekpo-pstyp,
LOEKZ LIKE ekpo-LOEKZ,
lgort like ekpo-lgort,
END OF zekpo.
DATA : po_tot LIKE komv-kwert,
item_tot LIKE komv-kwert,
item_price LIKE komv-kwert,
freight LIKE komv-kwert,
posnr(4),
comp TYPE i,
t1_ekpo LIKE zekpo OCCURS 0 WITH HEADER LINE,
t2_ekpo LIKE zekpo OCCURS 0 WITH HEADER LINE,
itab_comp LIKE zekpo OCCURS 0 WITH HEADER LINE,
t3_ekpo LIKE zekpo OCCURS 0 WITH HEADER LINE,
totpr1 type p decimals 2,
totpr2 type p decimals 3,
netpr1 type p decimals 2,
netpr2 type p decimals 3,
amttot1 type p decimals 2,
amttot2 type p decimals 3,
amttot3 type p decimals 2,
v_amountno(20) type c,
decim type p.
SELECT * FROM eket INTO CORRESPONDING FIELDS OF TABLE
l_doc-xeket WHERE ebeln EQ l_doc-xekko-ebeln.
SELECT SINGLE waers rlwrt FROM ekko INTO (l_doc-xekko-waers,
l_doc-xekko-rlwrt) WHERE ebeln EQ l_doc-xekko-ebeln.
select sum( menge ) into qtytot from ekpo
where ebeln eq l_doc-xekko-ebeln and loekz eq ' '.
select sum( netwr ) into amttot from ekpo
where ebeln eq l_doc-xekko-ebeln and loekz eq ' '.
select sum( effwr ) into amttot from ekpo
where ebeln eq l_doc-xekko-ebeln and loekz eq ' '.
LOOP AT l_doc-xekpo INTO t_xekpo WHERE LOEKZ EQ SPACE.
CLEAR t_xekkn.
READ TABLE l_doc-xekkn WITH KEY ebeln = t_xekpo-ebeln
ebelp = t_xekpo-ebelp
INTO t_xekkn.
SELECT SINGLE kunnr INTO vbak-kunnr FROM vbak
WHERE vbeln EQ t_xekkn-vbeln.
SELECT SINGLE name1 INTO kna1-name1 FROM kna1
WHERE kunnr EQ vbak-kunnr.
clear t_xeket.
READ TABLE l_doc-xeket WITH KEY ebeln = t_xekpo-ebeln
ebelp = t_xekpo-ebelp
etenr = 1
INTO t_xeket.
CLEAR: item_price, item_tot,po_tot.
Add the for SUM of the mat depends on the sale order and del date.
MOVE-CORRESPONDING t_xekpo TO t1_ekpo.
t1_ekpo-vbeln = t_xekkn-vbeln.
t1_ekpo-eindt = t_xeket-eindt.
t1_ekpo-vbelp = t_xekkn-vbelp.
t1_ekpo-charg = t_xeket-charg.
APPEND t1_ekpo.
ENDLOOP.
select single bstkd into ordno from vbkd where vbeln = t1_ekpo-vbeln.
amttot = t_xekpo-effwr.
LOOP AT t1_ekpo WHERE LOEKZ EQ SPACE..
MOVE-CORRESPONDING t1_ekpo TO t2_ekpo.
APPEND t2_ekpo.
MOVE-CORRESPONDING t1_ekpo TO itab_comp.
APPEND itab_comp.
item_price = t1_ekpo-brtwr / t1_ekpo-menge.
For decimal place check
select single currdec into decim from tcurx
where currkey = l_doc-xekko-waers.
if decim = 3.
netpr2 = item_price / 10.
totpr2 = t1_ekpo-brtwr / 10.
amttot2 = amttot / 10.
elseif decim = 2.
netpr1 = item_price.
totpr1 = t1_ekpo-brtwr.
amttot1 = amttot.
else.
netpr1 = item_price.
totpr1 = t1_ekpo-brtwr.
amttot1 = amttot.
endif.
amttot3 = amttot1.
posnr = t3_ekpo-vbelp+2(4).
WRITE t3_ekpo-eindt TO t_itemdate DD/MM/YY.
DATA: Yebelp LIKE t1_ekpo-ebelp.
Yebelp = t1_ekpo-ebelp / 10 .
PERFORM set_text_symbol USING:
'&T_XEKET-CHARG&' t1_ekpo-charg, "t1_ekpo-eindt,
'&DELDT&' t_itemdate,
'&VBAK-VBELN&' t1_ekpo-vbeln,
'&VBAK-VBELP&' posnr,
'&VBAK-KUNNR1&' kna1-name1,
'&T_XEKPO-TXZ01&' t1_ekpo-txz01(34),
'&T_XEKPO-MATNR&' t1_ekpo-matnr,
'&T_XEKPO-MENGE&' t1_ekpo-menge,
'&T_XEKPO-MEINS&' t1_ekpo-meins,
'&L_DOC-XEKKO-WAERS&' l_doc-xekko-waers,
'&T_XEKPO-NETPR&' t1_ekpo-netpr,
'&T_XEKPO-NETWR&' t1_ekpo-netwr,
'&RATE&' item_price,
'&T_XEKPO-BRTWR&' t1_ekpo-brtwr,
'&T_XEKPO-EBELP1&' Yebelp ,
'&T_XEKET-EINDT&' t1_ekpo-eindt,
'&ordno&' ordno,
'&LGORT&' t1_ekpo-lgort,
'&ekkn-gsber&' t_xekkn-gsber,
'&decim&' decim,
'&netpr1&' netpr1,
'&netpr2&' netpr2,
'&amttot1&' amttot1,
'&amttot2&' amttot2,
'&totpr1&' totpr1,
'&totpr2&' totpr2.
'&CNT&' count.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_LINE'
function = 'APPEND'
window = 'MAIN'
EXCEPTIONS
OTHERS = 7.
if t1_ekpo-lgort = 'RT01'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'REVNO'
function = 'SET'
window = 'REVNO'
EXCEPTIONS
OTHERS = 7.
endif.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
CONCATENATE t1_ekpo-ebeln t1_ekpo-ebelp INTO tdname.
SELECT SINGLE * FROM stxl WHERE relid EQ 'TX' AND
tdobject EQ 'EKPO' AND
tdname EQ tdname AND
tdid EQ 'F01' AND
tdspras EQ 'EN'.
IF sy-subrc EQ 0.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = stxl-tdid
language = stxl-tdspras
name = stxl-tdname
object = stxl-tdobject
TABLES
lines = ctxt
EXCEPTIONS
OTHERS = 8.
IF sy-subrc EQ 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TEXT_HEAD'.
LOOP AT ctxt.
IF ( ctxt-tdline IS NOT INITIAL ).
PERFORM set_text_symbol USING: '&TEXT_LINE1&' ctxt-tdline.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TEXT'
function = 'APPEND'
window = 'MAIN'
EXCEPTIONS
OTHERS = 7.
ENDIF. "if not line is initial
ENDLOOP.
ENDIF. "if read text is successful
ENDIF. "If table read is successful
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_TEXT_LINE'
function = 'SET'
window = 'MAIN'
EXCEPTIONS
OTHERS = 7.
ENDLOOP.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'REVNO'
function = 'SET'
window = 'REVNO'
EXCEPTIONS
OTHERS = 7.
t_netwr = 0.
t_totqty = 0.
LOOP AT t1_ekpo WHERE LOEKZ EQ SPACE..
CLEAR zekpo.
LOOP AT t2_ekpo
WHERE vbeln = t1_ekpo-vbeln.
" Matnr, Dev date and Rate is EQ.
IF ( t2_ekpo-matnr = t1_ekpo-matnr
AND t2_ekpo-eindt = t1_ekpo-eindt
AND t2_ekpo-netpr = t1_ekpo-netpr ).
zekpo-matnr = t2_ekpo-matnr.
zekpo-meins = t2_ekpo-meins.
zekpo-menge = t2_ekpo-menge + zekpo-menge.
zekpo-netwr = t2_ekpo-netwr + zekpo-netwr.
t_netwr = t_netwr + t2_ekpo-netwr. " Total price
t_totqty = t_totqty + t2_ekpo-menge. "Total Qty
zekpo-netpr = t2_ekpo-netpr + zekpo-netpr.
zekpo-netpr = t2_ekpo-netpr.
zekpo-txz01 = t2_ekpo-txz01.
zekpo-vbeln = t2_ekpo-vbeln.
zekpo-vbelp = t2_ekpo-vbelp.
zekpo-eindt = t2_ekpo-eindt.
zekpo-ebeln = t2_ekpo-ebeln.
zekpo-ebelp = t2_ekpo-ebelp.
ENDIF.
ENDLOOP.
*Place to notice
MOVE-CORRESPONDING zekpo TO t3_ekpo.
APPEND t3_ekpo.
DELETE t1_ekpo WHERE vbeln = zekpo-vbeln
AND matnr = zekpo-matnr
AND eindt = zekpo-eindt.
DELETE t2_ekpo WHERE vbeln = zekpo-vbeln
AND matnr = zekpo-matnr
AND eindt = zekpo-eindt.
*Changed by srini 31/12/2007
DELETE t1_ekpo WHERE vbeln = zekpo-vbeln
AND matnr = zekpo-matnr
AND eindt = zekpo-eindt
AND netpr = zekpo-netpr.
DELETE t2_ekpo WHERE vbeln = zekpo-vbeln
AND matnr = zekpo-matnr
AND eindt = zekpo-eindt
AND netpr = zekpo-netpr.
ENDLOOP.
IF t_xkomv-kschl NE 'FRA1' AND t_xkomv-kschl NE 'FRB1'.
item_tot = item_tot + t_xkomv-kwert.
ELSE.
freight = freight + t_xkomv-kwert.
ENDIF.
LOOP AT t3_ekpo WHERE LOEKZ EQ SPACE..
LOOP AT l_doc-xtkomv INTO t_xkomv. " WHERE kposn EQ t3_ekpo-ebelp.
icond-KNUMV = Ic-KNUMV .
icond-KPOSN = Ic-KPOSN .
icond-KSCHL = Ic-KSCHL .
icond-KAWRT = IC-KAWRT .
APPEND t_xkomv-icOND.
APPEND .
ENDLOOP.
ENDLOOP.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM_HEADER'
function = 'SET'
window = 'HITEM'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
po_tot = po_tot + freight.
SELECT waers rlwrt FROM ekko INTO (l_doc-xekko-waers,
l_doc-xekko-rlwrt) WHERE ebeln EQ l_doc-xekko-ebeln.
ENDSELECT.
PERFORM set_text_symbol USING:
'&L_DOC-XEKKO-WAERS&' l_doc-xekko-waers,
'&FREIGHT&' freight,
'&L_DOC-XEKKO-RLWRT&' t_netwr,
'&L_DOC-XEKKO-TotQty&' t_totqty,
'&qtytot&' qtytot,
'&amttot&' amttot,
'&CNT&' count.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'FRIGHT'
function = 'APPEND'
window = 'MAIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TOTAL'
function = 'SET'
window = 'MAIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
clear : amttot1, amttot2.
*P.O Summary
CLEAR t_xekpo.
REFRESH t_xekpo.
t_xekpo[] = l_doc-xekpo[].
SORT t_xekpo BY matnr.
LOOP AT t_xekpo.
AT NEW matnr.
SUM.
PERFORM set_text_symbol USING:
'&T_XEKPO-TXZ01&' t_xekpo-txz01,
'&T_XEKPO-MENGE&' t_xekpo-menge.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'SUM_MATNR'
function = 'APPEND'
window = 'MAIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 1.
ENDIF.
ENDAT.
ENDLOOP.
comp = 0.
LOOP AT itab_comp WHERE pstyp = 3 AND LOEKZ EQ SPACE..
SELECT * FROM resb WHERE ebeln = l_doc-xekko-ebeln AND
ebelp = itab_comp-ebelp AND
baugr = itab_comp-matnr.
SELECT SINGLE maktx FROM makt INTO makt-maktx WHERE
matnr EQ resb-matnr.
IF comp = 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'COMP'
function = 'SET'
window = 'MAIN'
EXCEPTIONS
OTHERS = 7.
comp = 1 .
ENDIF.
PERFORM set_text_symbol USING:
'&T_XEKPO-MATNR&' makt-maktx,
'&T_XEKET-EINDT&' resb-charg,
'&T_XEKPO-MENGE&' resb-bdmng,
'&T_XEKPO-MEINS&' resb-meins,
'&T_XEKPO-EBELP1&' itab_comp-ebelp.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'COMP1'
function = 'APPEND'
window = 'MAIN'
EXCEPTIONS
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
ENDSELECT.
ENDLOOP.
Find the total price for each item from condition table
DATA: con_amt LIKE freight.
DATA: def TYPE string,
sep(2) TYPE c,
sep1(3) TYPE c,
kwer(15) TYPE c,
txt(15) TYPE c,
con_win(1),
con1(1),
con(1),
grpr1 type p decimals 2,
grpr2 type p decimals 3.
con = 1.
DATA: ic LIKE l_doc-xtkomv WITH HEADER LINE.
DATA: begin of icond occurs 0,
KSCHL like komv-KSCHL ,
KWERT like komv-KWERT ,
KNUMV like komv-KNUMV ,
KPOSN like komv-KPOSN ,
end of icond.
*loop at t3_ekpo.
LOOP AT l_doc-xtkomv INTO IC WHERE kinak eq space.
kposn EQ t3_ekpo-ebelp.
APPEND ic.
ENDLOOP.
*endloop.
LOOP AT IC.
icond-KSCHL = Ic-KSCHL .
icond-KWERT = IC-KWERT .
icond-KNUMV = Ic-KNUMV .
icond-KPOSN = Ic-KPOSN .
APPEND icOND.
ENDLOOP.
con_win = 0.
sort icond by KSCHL.
LOOP AT icond .
AT END OF KSCHL.
SUM.
w_ex = 'X'.
IF w_ex = 'X'.
IF con_win = 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'CON'
function = 'SET'
window = 'MAIN'
EXCEPTIONS
OTHERS = 7.
con_win = 1 .
ENDIF.
CLEAR t685t-vtext.
SELECT SINGLE vtext INTO t685t-vtext FROM t685t
WHERE kschl = icond-kschl AND
spras = 'EN'.
IF icond-KWERT NE 0.
if decim = 3.
grpr2 = icond-kwert / 10.
elseif decim = 2.
grpr1 = icond-kwert.
else.
grpr1 = icond-kwert.
endif.
PERFORM set_text_symbol USING:
'&icond-kwert&' icond-KWERT,
'&grpr1&' grpr1,
'&grpr2&' grpr2,
'&t685t-vtext&' t685t-vtext.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'CON_WIN1'
function = 'APPEND'
window = 'MAIN'
EXCEPTIONS
OTHERS = 7.
IF sy-subrc EQ 0.
con_win = 1.
ENDIF.
ENDIF.
CLEAR: w_ex,icond-KWERT .
ENDAT.
ENDLOOP.
CLEAR zekpo.
SORT t3_ekpo BY matnr.
LOOP AT t3_ekpo WHERE LOEKZ EQ SPACE.
MOVE-CORRESPONDING t3_ekpo TO zekpo.
MOVE t3_ekpo-txz01 TO zekpo-txz01.
AT NEW matnr.
SUM.
PERFORM set_text_symbol USING:
'&T_XEKPO-TXZ01&' zekpo-txz01,
'&T_XEKPO-MENGE&' zekpo-menge.
PERFORM set_text_symbol USING:
'&T_XEKPO-TXZ01&' zekpo-txz01,
'&T_XEKPO-MENGE&' t3_ekpo-menge.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'SUM_MATNR'
function = 'APPEND'
window = 'MAIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 1.
ENDIF.
ENDAT.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'LINE5'
function = 'APPEND'
window = 'MAIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 1.
ENDIF.
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*Tax Code Printed Here
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SELECT SINGLE mwskz Txjcd FROM ekpo INTO
(t3_ekpo-mwskz, t3_ekpo-Txjcd)
WHERE ebeln = t3_ekpo-ebeln
and EBELP = t3_ekpo-EBELP.
select single KSCHL INTO A053-KSCHL FROM A053
WHERE MWSKZ EQ T3_EKPO-MWSKZ AND
TXJCD EQ T3_EKPO-TXJCD.
SELECT SINGLE VTEXT INTO T685T-VTEXT
FROM T685T WHERE KSCHL EQ A053-KSCHL.
DATA : GT type p decimals 2,
PER(5).
vat cal.
if T3_EKPO-MWSKZ eq 'X1'.
GT = T3_EKPO-NETWR * 4 / 100.
GT = GT + ( T3_EKPO-NETWR * 4 / 100 ).
PER = '4%'.
ICT = ICT + 1.
ELSEIF T3_EKPO-MWSKZ eq 'X3'.
GT = T3_EKPO-NETWR * 125 / 1000.
GT = GT + ( T3_EKPO-NETWR * 125 / 1000 ).
PER = '12.5%'.
ICT = ICT + 1.
ELSEIF T3_EKPO-MWSKZ eq 'X5'.
GT = T3_EKPO-NETWR * 2 / 100.
GT = GT + ( T3_EKPO-NETWR * 2 / 100 ).
PER = '2%'.
ICT = ICT + 1.
ELSEif T3_EKPO-MWSKZ eq 'Z1'.
GT = T3_EKPO-NETWR * 4 / 100.
GT = GT + ( T3_EKPO-NETWR * 4 / 100 ).
PER = '4%'.
ICT = ICT + 1.
ELSEIF T3_EKPO-MWSKZ eq 'Z3'.
GT = T3_EKPO-NETWR * 125 / 1000.
GT = GT + ( T3_EKPO-NETWR * 125 / 1000 ).
PER = '12.5%'.
ICT = ICT + 1.
ELSE.
ENDIF.
nettotal = amttot3 + GT.
ENDLOOP.
PERFORM set_text_symbol USING:
'&EKPO-MWSKZ&' t3_ekpo-mwskz,
'>&' GT,
'&ICT&' ICT,
'&nettotal&' nettotal,
'&per&' per,
'&VTEXT&' T685T-VTEXT,
*Added by srini
'&printtype&' printtype.
'&printtype&' nast-kschl.
PERFORM word_disp USING t_netwr l_doc-xekko-waers.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TAX_CODE'
function = 'SET'
window = 'MAIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
clear : T3_EKPO-MWSKZ,GT,PER,T685T-VTEXT.
*terms and Condition from Master Table
*Terms and Condition
*Get header Text Data
CONCATENATE t3_ekpo-ebeln t3_ekpo-ebelp INTO tdname.
SELECT SINGLE * FROM stxl WHERE relid EQ 'TX' AND
tdobject EQ 'EKPO' AND
tdname EQ tdname AND
tdid EQ 'F03' AND
tdspras EQ 'EN'.
IF sy-subrc EQ 0.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = stxl-tdid
language = stxl-tdspras
name = stxl-tdname
object = stxl-tdobject
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
TABLES
lines = ctxt
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8 .
IF sy-subrc EQ 0.
LOOP AT ctxt.
IF ( ctxt-tdline IS NOT INITIAL ).
PERFORM set_text_symbol USING: '&TEXT_LINE1&' ctxt-tdline.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TEXT_LINE1'
function = 'APPEND'
window = 'WINDOW0'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TEXT_LINE'
function = 'APPEND'
window = 'MAIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 1.
ENDIF.
ENDIF. "if not line is initial
ENDLOOP.
ENDIF. "if read text is successful
ENDIF. "If table read is successful
*Get header Text Data
SELECT SINGLE * FROM stxl WHERE relid EQ 'TX' AND
tdobject EQ 'EKKO' AND
tdname EQ l_doc-xekko-ebeln AND
tdid EQ 'F05' AND
tdspras EQ 'EN'.
IF sy-subrc EQ 0.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = stxl-tdid
language = stxl-tdspras
name = stxl-tdname
object = stxl-tdobject
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
TABLES
lines = ctxt
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8 .
IF sy-subrc EQ 0.
LOOP AT ctxt.
IF ( ctxt-tdline IS NOT INITIAL ).
PERFORM set_text_symbol USING: '&TEXT_LINE&' ctxt-tdline.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TEXT_LINE'
function = 'APPEND'
window = 'MAIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 1.
ENDIF.
ENDIF. "if not line is initial
ENDLOOP.
Similar Messages
-
Print JPEG/PDF Files in SAP Script
Hi,
I just want to know is it possible to print an Image of type JPEG/JPG in SAP Script, these images are
uploaded from transaction OAOR not from Se78, so is it possible to display images uploaded from
OAOR in SAP Script, if it is possible then please tell how to display these Images in SCript?
Thanks In advance..
Kalyan..Hi,
[How to Print PDF Format In SAP SCRIPT]
[Re: How to Print PDF Format In SAP SCRIPT]
[https://forums.sdn.sap.com/click.jspa?searchID=22871024&messageID=7056757] -
Write Special Characters in PDF file from SAP Script
Hi there,
Need a quick help...
We are converting SAP Script to PDF using the function module CONVERT_OTF
and saving the file on presentation server using GUI_DOWNLOAD...
But in certain cases where the item text is maintained with some special
characters like @#$% u03B1 u03B2 u03B3 u03B4 ®... then, some of these characters are seen
as junk/garbage characters...
how do we handle this??
P.S. Our Forms are already using Korean Font...
Any help is highly appreciated
Kind Regards,
TanujaHi,
Use the FM CONVERT_OTF to get the Binary data and down load it as PDF .
sample
*/ Convert the OTF data into PDF.
call function 'CONVERT_OTF'
exporting
format = 'PDF'
importing
bin_filesize = lv_bin_filesize
bin_file = lv_xstring
tables
otf = lt_otf_data-otfdata[]
lines = lt_pdf_data
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
others = 5 .
*/ Convert the Xstring data into PDF
call method cl_document_bcs=>xstring_to_solix
exporting
ip_xstring = lv_xstring
receiving
rt_solix = lt_mess_att .
Then down load the table lt_mess_att with extension PDF.
Edited by: UmaMaheswaraRao Surapaneni on Apr 1, 2009 5:44 PM -
Send email with PDF attachements (Smartform/SAP script)
Hello All,
I have 3 existing programs A, B & C whose output is in SAP Script/Smartform. Now I need to create new program D which needs to execute program A, B & C and then convert their smartform/SAP script output into PDF format and send email with attachements (PDF files). Any pointers how I can proceed. Thanks a lot.hi Sarita,
v_ctrlparams-no_dialog = 'X'.
v_ctrlparams-getotf = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Smartform name'
IMPORTING
fm_name = v_func_mod.
CALL FUNCTION v_func_mod
EXPORTING
control_parameters = v_ctrlparams
IMPORTING
job_output_info = v_joboutput
TABLES
t_nonsigner = t_nonsigner.
fill the document
doc_chng-obj_name = 'Descriptoipn'.
Fill the subject line
doc_chng-obj_descr = 'Manpowe'.
doc_chng-obj_descr = 'Reminder .
doc_chng-sensitivty = 'P'.
Fill the content of the mail
objcont = 'Dear all,'.
APPEND objcont.
CLEAR objcont.
APPEND objcont.
CLEAR objcont.
objcont =
'The manpower sign-off is pending for the list of employees as per th' &
'e attached sheet.'
APPEND objcont.
CLEAR objcont.
APPEND objcont.
CLEAR objcont.
objcont =
'Please click on the following link for the manpower sign-off:'.
APPEND objcont.
CLEAR objcont.
APPEND objcont.
CLEAR objcont.
DESCRIBE TABLE objcont LINES entries.
READ TABLE objcont INDEX entries.
doc_chng-doc_size = ( entries - 1 ) * 255 + STRLEN( objcont ).
Creating the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = entries.
objpack-doc_type = 'RAW'.
APPEND objpack.
Creating the document attachment
(Assume the data in OBJBIN are given in BMP format)
LOOP AT v_joboutput-otfdata INTO wa_otfdata.
APPEND wa_otfdata TO objbin.
CLEAR wa_otfdata.
ENDLOOP.
DESCRIBE TABLE objbin LINES tab_lines.
objhead = 'NonSignerDetails.otf'. APPEND objhead.
Creating the entry for the compressed attachment
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'OTF'.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = 'NonSignerDetails'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objcont
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
hope this will help u..
regards,
Santosh Thorat -
How to attach Pacakge for Local made SAP Script
Hi,
I have created a SAP Script, initially I have made it as local without assigning any package, ow I want to attach one package for that SAP Script form to transfer it to quality and production but in chnage mode the package filed is disable.
Also other option is there to copy existing form to new and give the package name but i want to know insted of copy how to add package for existing form.
regards,
zafarGoto SE03>object directory>change object directory entries> enter FORM in the first text box and script name in the object name select checkbox and execute.....>select the form and press button change object directory above....
-
How to Print PDF Format In SAP SCRIPT
Hi All,
I have a requirement to print the output in PDF format.
First we can pass the parameter from Excel sheet,through on the parameters , we can fetch the output and print the PDF format.
Please help me.
regards
raghavaHi Ragha,
SAP has created a standard program RSTXPDFT4 to convert your Sapscripts spools into a PDF format.
You will get the spool number from transaction SP02.
Also go through the following document:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/49e15474-0e01-0010-9cba-e62df8244556
Regards,
Nitin. -
What are methods for converting otf to pdf format in sap script
Hi,
I have a requirement in script i have to convert that that otf file to pdf format,when i use function modules its corrupting that pdf file,So i want convert otf to pdf using class method any one can help me for that.If any sample coding for class method.
Thanks.ok
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
* max_linewidth = 255
IMPORTING
bin_filesize = lv_bin_filesize
* bin_file = pdf_xstring
TABLES
otf = lt_otf
lines = lt_pdf_table
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lv_bin_filesize
filename = c_name
filetype = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* VIRUS_SCAN_PROFILE = '/SCET/GUI_DOWNLOAD'
* IMPORTING
* FILELENGTH =
TABLES
data_tab = lt_pdf_table
* FIELDNAMES =
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
TRY.
GET PARAMETER ID 'RECEIPTENT' FIELD lvs_recipient1.
send_request = cl_bcs=>create_persistent( ).
* lt_attach_bin = cl_document_bcs=>xstring_to_solix( ip_xstring = lt_solix ).
APPEND 'Test message' TO lt_text.
l_sub_50 = lc_test1.
document = cl_document_bcs=>create_document( i_type = 'RAW'
i_text = lt_text
i_subject = l_sub_50 ).
document->add_attachment( i_attachment_type = 'PDF'
i_attachment_subject = 'script.pdf'
i_att_content_hex = lt_attach_bin ).
l_sub_line = lc_test1.
TRY.
* Build subject line for email.
CALL METHOD send_request->set_message_subject
EXPORTING
ip_subject = l_sub_line.
CATCH cx_send_req_bcs INTO loref_obj_error.
PERFORM sub_catch_error1 USING loref_obj_error.
ENDTRY.
send_request->set_document( document ).
* sender = cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
recipient1 = lvs_recipient1-objkey.
recipient = cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
* send_request->set_sender( sender ).
send_request->add_recipient( i_recipient = recipient
i_express = 'X' ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK.
CATCH cx_bcs INTO bcs_exception.
MESSAGE 'eee' TYPE 'S'.
EXIT.
ENDTRY. -
Insert a pdf file in the SAP SCRIPT
Hi Experts,
could u tell me is it possible to <b>insert a pdf file in SAP script</b> if so please let me know thanks in advanceHi Prabu,
you can use the pdf viewer or any other (freeware) pdf installed on your client (PC) for display. There is no way to display a pdf inside the smartform.
Regards,
Clemens -
How to display line items twice in a single page in sap script
HI,
I am working on check printing. I copied the standard driver program and form to Zprogram and ZForm. Which are RFFOUS_C(print program) and F110_PRENUM_CHECK(Form Name).
I want to display the line items twice in the same page and sub sequent pages.
Currently I am able to display line items only once.
Example:
PAGE1.
line item1
line item2
line item3
line item4
line item5
line item1
line item2
line item3
line item4
line item5
line items 1 to 5 which are in main window.
How to achive this problem.
Regards,
vinodHi
I had the same request for a check form in Canada. I solved it by writing the line item output into variables and print these variables in a second window. It was ~10 hours of effort, not a real nice technical solution but it worked.
If you require I can send you a PDF of the sap script form definition. You can contact me at [email protected] Answers can take 1 week or more.
Best regards
JD -
Regarding Adding multiple SAP Scripts in one Transaction
Hi All,
I have a requirement where i will have to develop one custom transaction which will have multiple SAP Script Forms to it.
The scenario is as below:
First i will have to create a Program with Selection-Screen with 10 Radio buttons in one Block - Here Each Radio Button indicated Diffrent FORM[SAP SCRIPT].
Down to it i will create another Block with some selection-screen fields. Like Order Type, Order No, Customer PO number, SOLD TO, BILL TO, SHIP TO etc.
And based on Radio button selected allowed order types will vary!
So after selecting one Form[Radio button] and enetring other selection fields once i press execute button.
i need to display list of Orders in ALV List output with check boxes for each record in the List Output.
Here all the radio button Forms are related to <b>Sales Order document and Delivery document</b>
So do we need to create new ALV List Report (or) We can use submit <b>VF31</b> transaction's program <b>[sd70av3a]</b>.
After we are displayed with orders in the output.
Then we should provide a functionality as such if user selects mutiple Orders/Check boxes he should be able to view multiple Orders one after other, and simultaneously generate PDF Files for Each Order Selected and attach them in Mail send them to Block of users.
Can anybody give there sujjestions.
Without generating spool request no's is it possible to generate PDF files for SAP SCript output!
Is it possible to Generate & attach one/multiple PDF files to mail ID and send them to list of users!
Can anybody give inputs.
Thanks in advance.
Thanks & Regards,
Prasad.hi prasad,
There is one concept called Print Work Bench(PWB) to print the multiple scripts or smartforms which r assigned to a same transaction.
If u need the info related to PWB shoot me a test mail to [email protected]
i will send u the same
fot the same u can check the below link also
http://help.sap.com/saphelp_nw04/helpdata/en/64/bf2f12ed1711d4b655006094192fe3/content.htm
<b>Prasad i didn't get the mail from you plz check it once again</b>
If u find it useful plz mark the points
Regards,
Naveen
Message was edited by: NAVEENKUMAR GUDURI -
SAP Script Check printing Layout, Line Items to display twice in First Page
Hi All,
This requirement is for US check printing Layout.
My Requirement is to display Items twice on the first page.
Eg : Main Window has 10 Items, I need to display all the Items at the bottom in another window at the bottom.
I can't create 2 Main windows in the first page, as the data from the Main window 1 overflows to Main window 2 in the first page.
I copied print program RFFOUS_C into a Z-version and try to implement the logic, however unable to print the line items in the bottom window.
Kindly give your valuable Inputs.
Thanks
VinayakHi
I had the same request for a check form in Canada. I solved it by writing the line item output into variables and print these variables in a second window. It was ~10 hours of effort, not a real nice technical solution but it worked.
If you require I can send you a PDF of the sap script form definition. You can contact me at [email protected] Answers can take 1 week or more.
Best regards
JD -
Same set of data should print twice on same page in SAP SCRIPT
Hi Experts,
I come across a requirement where I need same set of data in sap script should print twice as it is on same page.
and if first page overflow, then same scenario should continue till complete data is printed. Basically main window data should print twice in two blocks on same page.
E.g.
If I have 10 line item which is to be printed on top window on first page. Now I want that same 10 lines should be printed in a block below the first block. Data should flow similarly across multiple pages.
Hope my question is pretty clear. I am expecting suitable answers from experts.
Thanks in advance.
Regards,
VijayHi
I had the same request for a check form in Canada. I solved it by writing the line item output into variables and print these variables in a second window. It was ~10 hours of effort, not a real nice technical solution but it worked.
If you require I can send you a PDF of the sap script form definition. You can contact me at [email protected] Answers can take 1 week or more.
Best regards
JD -
To convert Sap Script output to PDF format and send it via email.
Hi Friends,
Could any one please tell me, how to convert the Sap Script output to PDF format and send it via email. If any one have the code, kindly mail me to [email protected]
Thanks & Regards,
JohnPlese check this sample code from other thread.
REPORT zzz_jaytest .
Types Declaration
TYPES : BEGIN OF ty_pa0001,
pernr TYPE pa0001-pernr,
bukrs TYPE pa0001-bukrs,
werks TYPE pa0001-werks,
END OF ty_pa0001.
Internal Table Declaration
DATA : i_pa0001 TYPE STANDARD TABLE OF ty_pa0001, "For pa0001 Details
i_otf TYPE STANDARD TABLE OF itcoo, "For OTF data
i_content_txt TYPE soli_tab, "Content
i_content_bin TYPE solix_tab, "Content
i_objhead TYPE soli_tab,
Work Area Declaration
w_pa0001 TYPE ty_pa0001, "For pa0001 Details
w_res TYPE itcpp, "SAPscript output
"parameters
w_otf TYPE itcoo, "For OTF
w_pdf TYPE solisti1, "For PDF
w_transfer_bin TYPE sx_boolean, "Content
w_options TYPE itcpo, "SAPscript output
"interface
Variable Declaration
v_len_in TYPE so_obj_len,
v_size TYPE i.
Constants Declaration
CONSTANTS : c_x TYPE c VALUE 'X', "X
c_locl(4) TYPE c VALUE 'LOCL', "Local Printer
c_otf TYPE sx_format VALUE 'OTF', "OTF
c_pdf TYPE sx_format VALUE 'PDF', "PDF
c_printer TYPE sx_devtype VALUE 'PRINTER', "PRINTER
c_bin TYPE char10 VALUE 'BIN', "BIN
c_name TYPE string VALUE 'C:\ZZZ_JAYTEST.PDF',"Downloading
"File Name
c_form(11) TYPE c VALUE 'ZZZ_JAYTEST'. "Form Name
START-OF-SELECTION.
Selecting the records from pa0001
SELECT pernr bukrs werks FROM pa0001
INTO TABLE i_pa0001 UP TO 10 ROWS.
Setting the options
w_options-tdcopies = 1 ."Number of copies
w_options-tdnoprev = c_x."No print preview
w_options-tdgetotf = c_x."Return of OTF table
w_options-tddest = c_locl."Spool: Output device
Opening the form
CALL FUNCTION 'OPEN_FORM'
EXPORTING
form = c_form
device = c_printer
language = sy-langu
OPTIONS = w_options
IMPORTING
RESULT = w_res.
LOOP AT i_pa0001 INTO w_pa0001.
Writting into the form
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'MAIN'
window = 'MAIN'.
ENDLOOP.
Closing the form
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = w_res
TABLES
otfdata = i_otf
EXCEPTIONS
unopened = 1
bad_pageformat_for_print = 2
send_error = 3
spool_error = 4
codepage = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Converting OTF data to single line
LOOP AT i_otf INTO w_otf.
CONCATENATE w_otf-tdprintcom w_otf-tdprintpar
INTO w_pdf.
APPEND w_pdf TO i_content_txt.
ENDLOOP.
Converting to PDF Format
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
format_src = c_otf
format_dst = c_pdf
devtype = c_printer
CHANGING
transfer_bin = w_transfer_bin
content_txt = i_content_txt
content_bin = i_content_bin
objhead = i_objhead
len = v_len_in
EXCEPTIONS
err_conv_failed = 1
OTHERS = 2.
v_size = v_len_in.
Downloading the PDF File
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = v_size
filename = c_name
filetype = c_bin
TABLES
data_tab = i_content_bin.
The extension is put the it_mailpack-obj_name parameter of 'SO_NEW_DOCUMENT_ATT_SEND_API1'. -
hi experts,
how to convert sap-script to PDF format?
and where we get option to print script directly.
thanks in advance.HI,
SAP have created a standard program <b>RSTXPDFT4</b> to convert your Sapscripts spools into a PDF format.
Specify the spool number and you will be able to download the sapscripts spool into your local harddisk.
It look exactly like what you see during a spool display.
If you want a Program, look at the below link
http://searchsap.techtarget.com/tip/1,289483,sid21_gci1121833,00.html
To print the Script directly, you can give this option in the NACE transaction, there we can give Print Immedialt option ..
Regards
Sudheer -
Hi All,
I have one report prg wich gives op in sap script.
I want same output in pdf and have to save on hard disk.
please suggest me wat procedure i have to follow.
It's urgentA very common requirement for programmers writing ABAP code for printing using SAPScript Forms is to redirect output to a PDF (Adobe Acrobat) file. I struggled for a few days trying to find a solution to this. Though I found quite a few examples on the web, it was difficult figuring out which technique was optimal. This tip is borne out of these struggles.
This is an example of how to use ABAP code to save output of a print routine using a SAPScript form into PDF format and also display it within the SAP frontend itself. This routine proves extremely useful to provide users the ability to save local copies of output and preview it within the user-friendly Acrobat Reader control, all without leaving the SAP frontend or your program. Since function modules are used, the code is portable and this technique can be used in any other ABAP program as well.
Two function modules, Z_DS_CREATE_LOCAL_PDF_FILE and Z_DS_CALL_PDF_VIEWER need to be created. I have used a function group called Z5_DS_PDF for this purpose. The function group contains the ABAP objects code for declaration and implementation of a class that encapsulates the Acrobat application functionality. The function group also contains a screen '0901', that epresents our PDF viewer and one PBO and one PAI block for the same screen.
Note: The following example has been stripped of essential error-handling for the sake of simplicity and the programmer is assumed to possess knowledge of creation of function groups, function modules, screens and SAPScript forms. ABAP objects or custom controls knowledge is not mandatory. Be patient when trying this out and follow all instructions thoroughly. The results will be worth the effort.
Steps to follow to get this example running:
1) Create a function group (Example : Z5_DS_PDF)
2) Define the top include and place the code listed below into it (LZ5_DS_PDFTOP)
3) Create screen '0901' in function group with three elements:
a) Pushbutton CLOSE at the top with function code 'CLO' (this is to exit preview screen)
b) Custom control container (Large- spanning entire screen) named MY_CONTAINER
c) The customary OK code field called OK_CODE
Note: The names of the elements should be exactly as described above
4) Create one output and one input module in the flow logic of screen '0901' for which the code is provided below
5) Define two function modules with the following signatures:
a) FUNCTION Z_DS_CREATE_LOCAL_PDF_FILE
EXPORTING
REFERENCE(AFILENAME) LIKE RLGRAP-FILENAME
TABLES
OTF_LINES STRUCTURE ITCOO
b) FUNCTION Z_DS_CALL_PDF_VIEWER
IMPORTING
VALUE(FILENAME) TYPE STRING
Code is provided below.
6) Compile and activate the function group
7) Create a simple SAPScript form with one page and one window
8) Define one element in the text for the main window called 'HELLO' and some static text in it
9) Check and activate the form
10) Create the example program (Example : Z5_DS_SCRIPT2PDF) with the below code
11) Run the example
NOTES: I tested this code in R/3 version 4.6C but it should work in all 4.6 setups. I'm pretty sure some of the ABAP objects code I have used may not work with R/3 4.0 versions and earlier. Also, it works perfectly only when Acrobat Reader is installed on the presentation server. I have checked it with Acrobat versions 4 and 5 but I haven't had the opportunity to check it with Acrobat Reader 6.
Code
Code inside top include LZ5_DS_PDFTOP of function group Z5_DS_PDF
FUNCTION-POOL Z5_DS_PDF. "MESSAGE-ID ..
CLASS CL_GUI_PDF DEFINITION *
CLASS CL_GUI_PDF DEFINITION
INHERITING FROM CL_GUI_CONTROL.
PUBLIC SECTION.
TYPES:
COL_TYPE TYPE INT4.
METHODS:
CONSTRUCTOR
IMPORTING
!PARENT TYPE REF TO CL_GUI_CONTAINER
VALUE(SHELLSTYLE) TYPE I OPTIONAL
VALUE(DISP_MODE) TYPE I OPTIONAL
VALUE(LIFE_TIME) TYPE I OPTIONAL
VALUE(NAME) TYPE STRING OPTIONAL
EXCEPTIONS
CNTL_ERROR
CNTL_INSTALL_ERROR.
METHODS:
LOADFILE
IMPORTING
VALUE(FILENAME) TYPE STRING
EXCEPTIONS
FILE_NOT_FOUND.
METHODS:
REFRESH.
METHODS:
DISPATCH REDEFINITION.
ENDCLASS.
DATA: MY_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: MY_PDF TYPE REF TO CL_GUI_PDF.
data: ok_code like sy-ucomm.
data: file_name type string.
custom control class implementation
CLASS CL_GUI_PDF IMPLEMENTATION.
METHOD CONSTRUCTOR.
DATA:
CTRL_NAME(80) TYPE C.
IF NOT CL_GUI_OBJECT=>ACTIVEX IS INITIAL.
CTRL_NAME = '{CA8A9780-280D-11CF-A24D-444553540000}'.
ELSE.
RAISE CNTL_ERROR.
ENDIF.
CALL METHOD SUPER->CONSTRUCTOR
EXPORTING
CLSID = CTRL_NAME
SHELLSTYLE = SHELLSTYLE
PARENT = PARENT
LIFETIME = LIFE_TIME
NAME = NAME
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
OTHERS = 2.
CASE SY-SUBRC.
WHEN 1.
RAISE CNTL_INSTALL_ERROR.
WHEN 2.
RAISE CNTL_ERROR.
ENDCASE.
CALL METHOD CL_GUI_CFW=>SUBSCRIBE
EXPORTING
REF = ME
SHELLID = ME->H_CONTROL-SHELLID
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC NE 0.
RAISE CNTL_ERROR.
ENDIF.
ENDMETHOD.
METHOD LOADFILE.
CALL METHOD ME->CALL_METHOD
EXPORTING
METHOD = 'LoadFile'
P_COUNT = 1
P1 = FILENAME.
ENDMETHOD.
METHOD REFRESH.
CALL METHOD ME->CALL_METHOD
EXPORTING
METHOD = 'Refresh'
P_COUNT = 0.
ENDMETHOD.
METHOD DISPATCH.
CALL METHOD CL_GUI_CFW=>FLUSH.
IF SY-SUBRC NE 0.
RAISE CNTL_ERROR.
ENDIF.
ENDMETHOD.
ENDCLASS.
End of code for LZ5_DS_PDFTOP
Code for Function Module Z_DS_CREATE_LOCAL_PDF_FILE
FUNCTION Z_DS_CREATE_LOCAL_PDF_FILE .
""Local interface:
*" EXPORTING
*" REFERENCE(AFILENAME) LIKE RLGRAP-FILENAME
*" TABLES
*" OTF_LINES STRUCTURE ITCOO
DATA: PDF_LINES
LIKE TLINE OCCURS 1000 WITH HEADER LINE,
ARCH LIKE TOA_DARA, NO_LINES TYPE I.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = NO_LINES
TABLES
OTF = OTF_LINES
LINES = PDF_LINES.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
BIN_FILESIZE = NO_LINES
FILENAME = 'c:test.pdf'
FILETYPE = 'BIN'
IMPORTING
ACT_FILENAME = AFILENAME
TABLES
DATA_TAB = PDF_LINES.
ENDFUNCTION.
End of Code for Z_DS_CREATE_LOCAL_PDF_FILE
Code for Function Module Z_DS_CALL_PDF_VIEWER
FUNCTION Z_DS_CALL_PDF_VIEWER .
""Local interface:
*" IMPORTING
*" VALUE(FILENAME) TYPE STRING
FILE_NAME = FILENAME.
IF MY_CONTAINER IS INITIAL.
CREATE OBJECT MY_CONTAINER
EXPORTING
CONTAINER_NAME = 'MY_CONTAINER'.
CREATE OBJECT MY_PDF
EXPORTING
NAME = 'MY_PDF'
PARENT = MY_CONTAINER.
ENDIF.
CALL SCREEN 901. " Ensure screen is created as per instructions
ENDFUNCTION.
End of Code for Z_DS_CALL_PDF_VIEWER
Flow Logic for screen '0901'
PROCESS BEFORE OUTPUT.
MODULE INIT.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0901.
End of Flow Logic for screen '0901'
PBO module INIT for screen '0901'
MODULE init OUTPUT.
call method my_pdf->loadfile
exporting filename = file_name.
ENDMODULE. " init OUTPUT
End of PBO module INIT for screen '0901'
PAI module USER_COMMAND_901 for screen '0901'
MODULE USER_COMMAND_0901 INPUT.
case ok_code.
when 'CLO'.
set screen 0.
endcase.
ENDMODULE. " USER_COMMAND_0901 INPUT
End of PAI module USER_COMMAND_901 for screen '0901'
Example program Z5_DS_SCRIPT2PDF
*& Report Z5_DS_SCRIPT2PDF *
*& This report works only if the function modules *
*& Z_DS_CREATE_LOCAL_PDF_FILE and Z_DS_CALL_PDF_VIEWER already exist *
*& Also use an already existing simple SAPScript Form that contains a *
*& window "MAIN" and rework printing code if necessary, remember to *
*& change the output device name in OPTIONS-TDDEST *
REPORT Z5_DS_SCRIPT2PDF.
PARAMETERS: FORM LIKE RSSCF-TDFORM DEFAULT 'Z5_DS_HELLO2'. "your form
DATA: OTF_LINES LIKE ITCOO OCCURS 1000 WITH HEADER LINE,
OPTIONS TYPE ITCPO, FILENAME LIKE RLGRAP-FILENAME,
FILENAME_S TYPE STRING.
START-OF-SELECTION.
OPTIONS-TDDEST = 'LP01'.
Replace 'LP01' above with your default output device
OPTIONS-TDCOPIES = 1.
OPTIONS-TDGETOTF = 'X'. " the key to returning OTF data
Open the SapScript Form with the name "form" *
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = FORM " name of form (SE71)
OPTIONS = OPTIONS
DIALOG = ' '.
Execute the element "HELLO" in window MAIN
- Nothing happens if /E HELLO is not declared in MAIN
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'HELLO' "execute element /E HELLO
TYPE = 'BODY'. "normal output
Close the current SapScript Form
CALL FUNCTION 'CLOSE_FORM'
TABLES
OTFDATA = OTF_LINES. " Retrieve all the OTF so far
Code for PDF Formatting and creation of local File
CALL FUNCTION 'Z_DS_CREATE_LOCAL_PDF_FILE'
IMPORTING
AFILENAME = FILENAME
TABLES
OTF_LINES = OTF_LINES.
FILENAME_S = FILENAME.
Code to launch Adobe Acrobat inplace in SAPGUI
CALL FUNCTION 'Z_DS_CALL_PDF_VIEWER'
EXPORTING
FILENAME = FILENAME_S.
End of example program Z5_DS_SCRIPT2PDF
Maybe you are looking for
-
Single virtual channel with multiple digital ports
Hi all, I have created a program that creates a task to read continuously from 3 digital port lines from the same device (PXI-6133). I am trying to figure out how I can retrieve the data from each port line to put into a waveform graph. Currently, I
-
For the new iPhone 5s - is there not an option anymore to edit imessages without deleting the whole stream? There are some things I need to keep within a stream and some not necessary, and it looks as like no editing within a conversation?
-
Hi can i connect hifi digital and my home wifi to airport express.
Hi i have been thinking about adding my hifi and sony digital TV to my home network which consist of three mac computers and has a wifi internet connection. What are the advantages of using airport express over bluetooth hardware. Using the male sin
-
Watermak draft doesn't appear when printing
Hi everybody, i'm facing a printing issue with watermark draft, there is my problem: i have made a PO (production order) and i would like to print with the watermak draft on it. When i click on Print Preview i can see it (the watermark) but when i pr
-
My two year contract with my Blackberry Curve has ended and I want to purchase an Iphone 3G. Will the sim card I have in my Blackberry work in the Iphone? If not, how do I get all my addresses etc. over to the Iphone from the Curve?