‎2009 Jan 05 9:31 AM
‎2009 Jan 05 9:41 AM
Hi,
after the close form call the the below FM..and pass the value of 'X' to 'TDNOPREV' in parameter OPTIONS' of OPEN_FORM
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = c_pdf
IMPORTING
bin_filesize = filesize
TABLES
otf = otfdata_tab
lines = pdfdata_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
by doing above, the OTF data will get converted to PDF.
Hope i made u understand...
Kindly let me know for any further help..
Regards,
Pavan
‎2009 Jan 05 10:11 AM
Hi pavan
Thank you for your reply
The below coding is Subroutine coding
i want save pdf file how will changed
&----
*& 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.
*<--
>
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.
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 'F06' 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.
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 'F07' 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 = 'SET'
window = 'PAY_WIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
ENDIF. "if not line is initial
ENDLOOP.
ENDIF. "if read text is successful
ENDIF. "If table read is successful
*Terms and Condition
*************************************************************
if t_xekpo-knttp = 'E' and t_xekpo-pstyp = 3 and
t_xekkn-sakto = 221003.
ENDFORM. " MAIN_DISP
&----
& Form AMOUNT WORD &
&----
& AMOUNTWORD Display &
&----
FORM word_disp USING l_doc-xekko-rlwrt l_doc-xekko-waers.
DATA: point(8) TYPE c,
speller LIKE spell.
DATA: tmp(255) TYPE c,
v_amountno(20) TYPE c,
decim type p.
select single currdec into decim from tcurx
where currkey = l_doc-xekko-waers.
if decim = 3.
v_amountno = amttot / 10.
elseif decim = 2.
v_amountno = amttot.
else.
v_amountno = amttot.
endif.
if decim = 3.
v_amountno = nettotal / 10.
elseif decim = 2.
v_amountno = nettotal.
else.
v_amountno = nettotal.
endif.
*v_amountno = amttot.
CALL FUNCTION 'Z_JKC_SPELLAMOUNT'
EXPORTING
v_inwnumber = v_amountno "l_doc-xekko-rlwrt
CHANGING
spell = tmp.
clear : amttot.
IF sy-subrc EQ 0.
PERFORM set_text_symbol USING:
'&gross&' v_amountno,
'&SPELLER-WORD&' tmp. "speller-word,
data : tmp_ekpo like ekpo occurs 0 with header line .
data : sub_found(2) .
clear sub_found.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'AMOUNT_WORD'
function = 'APPEND'
window = 'WINDOW1'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
if t_xekpo-knttp = 'E' and ( t_xekpo-pstyp = 3 or
t_xekpo-matkl = '4' or
t_xekpo-matkl = '43' or
t_xekpo-matkl = '42' or
t_xekpo-matkl = '65' or
t_xekpo-matkl = '64' or
t_xekpo-matkl = '63' or
t_xekpo-matkl = '58' or
t_xekpo-matkl = '57' or
t_xekpo-matkl = '56' or
t_xekpo-matkl = '52' or
t_xekpo-matkl = '48' or
t_xekpo-matkl = '46' or
t_xekpo-matkl = '33' or
t_xekpo-matkl = '34' or
t_xekpo-matkl = '3' or
t_xekpo-matkl = '23' ).
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TERM'
function = 'SET'
window = 'WT'
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 = 'DEL'
function = 'SET'
window = 'DELWIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
else.
select * from ekpo into table tmp_ekpo where
ebeln eq t_xekpo-ebeln and
( matkl eq '59' or
matkl eq '6' or
matkl eq '26' or
matkl eq '58') .
if sy-subrc = 0 .
sub_found = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'DEL'
function = 'SET'
window = 'DELWIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
else .
clear sub_found.
endif.
ENDIF.
endif.
*
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEAD1'
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 + 1.
ENDIF.
ENDFORM. "WORD_DISP
----
FORM SET_TEXT_SYMBOL *
----
Std Set Text symbol Fuction for printing values in layout Set
----
--> VALUE(P_0542) *
--> P_VXBLNR *
----
FORM set_text_symbol USING value(p_0542)
p_vxblnr.
CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'
EXPORTING
name = p_0542
value = p_vxblnr
VALUE_LENGTH = 0
REPLACE_SYMBOLS = ' '
EXCEPTIONS
OTHERS = 1.
ENDFORM. "SET_TEXT_SYMBOL
Regards
Suresh
‎2009 Jan 05 10:14 AM
Hi pavan
Thanks for your reply
The following code Subroutine program for PO
I want save PDF file how will changed
&----
*& 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.
*<--
>
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.
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 'F06' 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.
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 'F07' 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 = 'SET'
window = 'PAY_WIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
ENDIF. "if not line is initial
ENDLOOP.
ENDIF. "if read text is successful
ENDIF. "If table read is successful
*Terms and Condition
*************************************************************
if t_xekpo-knttp = 'E' and t_xekpo-pstyp = 3 and
t_xekkn-sakto = 221003.
ENDFORM. " MAIN_DISP
&----
& Form AMOUNT WORD &
&----
& AMOUNTWORD Display &
&----
FORM word_disp USING l_doc-xekko-rlwrt l_doc-xekko-waers.
DATA: point(8) TYPE c,
speller LIKE spell.
DATA: tmp(255) TYPE c,
v_amountno(20) TYPE c,
decim type p.
select single currdec into decim from tcurx
where currkey = l_doc-xekko-waers.
if decim = 3.
v_amountno = amttot / 10.
elseif decim = 2.
v_amountno = amttot.
else.
v_amountno = amttot.
endif.
if decim = 3.
v_amountno = nettotal / 10.
elseif decim = 2.
v_amountno = nettotal.
else.
v_amountno = nettotal.
endif.
*v_amountno = amttot.
CALL FUNCTION 'Z_JKC_SPELLAMOUNT'
EXPORTING
v_inwnumber = v_amountno "l_doc-xekko-rlwrt
CHANGING
spell = tmp.
clear : amttot.
IF sy-subrc EQ 0.
PERFORM set_text_symbol USING:
'&gross&' v_amountno,
'&SPELLER-WORD&' tmp. "speller-word,
data : tmp_ekpo like ekpo occurs 0 with header line .
data : sub_found(2) .
clear sub_found.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'AMOUNT_WORD'
function = 'APPEND'
window = 'WINDOW1'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
if t_xekpo-knttp = 'E' and ( t_xekpo-pstyp = 3 or
t_xekpo-matkl = '4' or
t_xekpo-matkl = '43' or
t_xekpo-matkl = '42' or
t_xekpo-matkl = '65' or
t_xekpo-matkl = '64' or
t_xekpo-matkl = '63' or
t_xekpo-matkl = '58' or
t_xekpo-matkl = '57' or
t_xekpo-matkl = '56' or
t_xekpo-matkl = '52' or
t_xekpo-matkl = '48' or
t_xekpo-matkl = '46' or
t_xekpo-matkl = '33' or
t_xekpo-matkl = '34' or
t_xekpo-matkl = '3' or
t_xekpo-matkl = '23' ).
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TERM'
function = 'SET'
window = 'WT'
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 = 'DEL'
function = 'SET'
window = 'DELWIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
else.
select * from ekpo into table tmp_ekpo where
ebeln eq t_xekpo-ebeln and
( matkl eq '59' or
matkl eq '6' or
matkl eq '26' or
matkl eq '58') .
if sy-subrc = 0 .
sub_found = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'DEL'
function = 'SET'
window = 'DELWIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
else .
clear sub_found.
endif.
ENDIF.
endif.
*
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEAD1'
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 + 1.
ENDIF.
ENDFORM. "WORD_DISP
----
FORM SET_TEXT_SYMBOL *
----
Std Set Text symbol Fuction for printing values in layout Set
----
--> VALUE(P_0542) *
--> P_VXBLNR *
----
FORM set_text_symbol USING value(p_0542)
p_vxblnr.
CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'
EXPORTING
name = p_0542
value = p_vxblnr
VALUE_LENGTH = 0
REPLACE_SYMBOLS = ' '
EXCEPTIONS
OTHERS = 1.
ENDFORM. "SET_TEXT_SYMBOL
‎2009 Jan 05 10:19 AM
Hi
Thanks for your reply
The following Subroutine code using sapscript
how will change for PDF file?
&----
*& 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.
*<--
>
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.
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 'F06' 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.
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 'F07' 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 = 'SET'
window = 'PAY_WIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
ENDIF. "if not line is initial
ENDLOOP.
ENDIF. "if read text is successful
ENDIF. "If table read is successful
*Terms and Condition
*************************************************************
if t_xekpo-knttp = 'E' and t_xekpo-pstyp = 3 and
t_xekkn-sakto = 221003.
ENDFORM. " MAIN_DISP
&----
& Form AMOUNT WORD &
&----
& AMOUNTWORD Display &
&----
FORM word_disp USING l_doc-xekko-rlwrt l_doc-xekko-waers.
DATA: point(8) TYPE c,
speller LIKE spell.
DATA: tmp(255) TYPE c,
v_amountno(20) TYPE c,
decim type p.
select single currdec into decim from tcurx
where currkey = l_doc-xekko-waers.
if decim = 3.
v_amountno = amttot / 10.
elseif decim = 2.
v_amountno = amttot.
else.
v_amountno = amttot.
endif.
if decim = 3.
v_amountno = nettotal / 10.
elseif decim = 2.
v_amountno = nettotal.
else.
v_amountno = nettotal.
endif.
*v_amountno = amttot.
CALL FUNCTION 'Z_JKC_SPELLAMOUNT'
EXPORTING
v_inwnumber = v_amountno "l_doc-xekko-rlwrt
CHANGING
spell = tmp.
clear : amttot.
IF sy-subrc EQ 0.
PERFORM set_text_symbol USING:
'&gross&' v_amountno,
'&SPELLER-WORD&' tmp. "speller-word,
data : tmp_ekpo like ekpo occurs 0 with header line .
data : sub_found(2) .
clear sub_found.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'AMOUNT_WORD'
function = 'APPEND'
window = 'WINDOW1'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
if t_xekpo-knttp = 'E' and ( t_xekpo-pstyp = 3 or
t_xekpo-matkl = '4' or
t_xekpo-matkl = '43' or
t_xekpo-matkl = '42' or
t_xekpo-matkl = '65' or
t_xekpo-matkl = '64' or
t_xekpo-matkl = '63' or
t_xekpo-matkl = '58' or
t_xekpo-matkl = '57' or
t_xekpo-matkl = '56' or
t_xekpo-matkl = '52' or
t_xekpo-matkl = '48' or
t_xekpo-matkl = '46' or
t_xekpo-matkl = '33' or
t_xekpo-matkl = '34' or
t_xekpo-matkl = '3' or
t_xekpo-matkl = '23' ).
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'TERM'
function = 'SET'
window = 'WT'
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 = 'DEL'
function = 'SET'
window = 'DELWIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
else.
select * from ekpo into table tmp_ekpo where
ebeln eq t_xekpo-ebeln and
( matkl eq '59' or
matkl eq '6' or
matkl eq '26' or
matkl eq '58') .
if sy-subrc = 0 .
sub_found = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'DEL'
function = 'SET'
window = 'DELWIN'
EXCEPTIONS
element = 1
function = 2
type = 3
unopened = 4
unstarted = 5
window = 6
OTHERS = 7.
IF sy-subrc EQ 0.
count = count + 2.
ENDIF.
else .
clear sub_found.
endif.
ENDIF.
endif.
*
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'HEAD1'
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 + 1.
ENDIF.
ENDFORM. "WORD_DISP
----
FORM SET_TEXT_SYMBOL *
----
Std Set Text symbol Fuction for printing values in layout Set
----
--> VALUE(P_0542) *
--> P_VXBLNR *
----
FORM set_text_symbol USING value(p_0542)
p_vxblnr.
CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'
EXPORTING
name = p_0542
value = p_vxblnr
VALUE_LENGTH = 0
REPLACE_SYMBOLS = ' '
EXCEPTIONS
OTHERS = 1.
ENDFORM. "SET_TEXT_SYMBOL
‎2009 Jan 05 10:22 AM
Hi pavan
Thanks for your reply
any example available pls send
Thanks and Regards
Suresh
‎2009 Jan 05 10:25 AM
Hi Pavan
Thanks for your reply
Any example available using sapscript pls send
Thanks and Regards
Suresh
‎2009 Jan 05 9:43 AM
‎2009 Jan 05 9:47 AM
Hi Suresh,
This is used to convert the OTF format (From Script /Smartform) to the PDF or ASCI format.
OTF will be generated after the Smart form / Script displayed
You can get the OTF from the SMART_FORM function module parameters.
In case of SAP Script, it will come from CLOSE_FORM Function.
Regards,
Nitin.
‎2009 Jan 05 9:48 AM
Hi .Request you toand search SCN before posting....
however i have given useful linnk belo
https://weblogs.sdn.sap.com/pub/wlg/8613..take [original link is broken] [original link is broken] [original link is broken] a lok at the blog
‎2009 Jan 05 9:51 AM
Hi Suresh,
Refer this Help http://help.sap.com/saphelp_nw04/helpdata/en/d6/0dbadd494511d182b70000e829fbfe/frameset.htm
Regards,
PS
‎2009 Jan 10 4:13 AM