Hi,
You can send purchase order via e-mail in SAP system, there are some configurations and pre-requisites to do as follow:
SPRO
Purchasing Doc. Type,
Purch. Organization,
Vendor
2. Access Sequences
SPRO -> Material Management-> Purchasing -> Message -> Output Control->Access Sequences->Define Condition Table for Purchase Order
3. Message Type
SPRO -> Material Management-> Purchasing -> Message -> Output Control->Message Types->Define Message Type for Purchase Order
呼叫PROGRAM中的FORM routine,而FORM routine呼叫smartForm Form
底下貼上ZSAPFM06P範例
4. Message Determination Schemas
4.1. Message Determination Schemas
SPRO -> Material Management-> Purchasing -> Message -> Output Control->Message Schema->Define Message Schema for Purchase Order-> Maintain Message Determination Schema
4.2. Assign Schema to Purchase Order
SPRO -> Material Management-> Purchasing -> Message -> Output Control->Message Schema->Define Message Schema for Purchase Order-> Assign Schema to Purchase Order
SPRO -> Material Management-> Purchasing -> Message -> Output Control-> Partner Roles per Message Type ->Define Partner Role for Purchase Order
6. Condition Record
Navigation Path: SAP Menu-> Logistics -> Material Management -> Purchasing-> Master data->Messages-> Purchase Order-> MN04-> Create
Now you create PO (ME21N) and save it. Go to ME22N and print the PO by giving output type.
FORM ZENTRY_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.
IF NAST-AENDE EQ SPACE.
L_DRUVO = '1'.
ELSE.
L_DRUVO = '2'.
ENDIF.
* "***************************************************
DATA: LS_PONUM LIKE EKKO-EBELN.
DATA: LF_FORMNAME TYPE TDSFNAME VALUE 'ZSFMM001',
LF_FM_NAME TYPE RS38L_FNAM.
DATA ITAB LIKE ZSMM001 OCCURS 10 WITH HEADER LINE.
DATA FRGKE LIKE EKKO-FRGKE.
DATA T_RTAX1U15 LIKE RTAX1U15 OCCURS 1 WITH HEADER LINE. "20080407 By Matt Calculate Tax
DATA: IT_PDF TYPE ITCOO OCCURS 0 WITH HEADER LINE, "@03
PDF_TAB LIKE TLINE OCCURS 0 WITH HEADER LINE,
BIN_FILESIZE TYPE I,
FILE_SIZE TYPE I,
LS_JOB_INFO TYPE SSFCRESCL,
PATH_NAME TYPE STRING,
VEKORG TYPE EKORG.
* "***************************
CLEAR LS_PONUM .
LS_PONUM = NAST-OBJKY+0(10) .
*
INCLUDE MM_MESSAGES_MAC. "useful macros for message handling
SELECT SINGLE FRGKE EKORG INTO (FRGKE, VEKORG) FROM EKKO WHERE EBELN = LS_PONUM.
IF FRGKE EQ 'B'. "Block doc cannot be printed, agreed on 4/20/07' PO process meeting
MMPUR_MESSAGE_FORCED 'E' 'ZMM01' '999' 'Unreleased document cannot be printed !' '' '' ''.
EXIT.
ENDIF.
*
SELECT H~EBELN H~LIFNR H~AEDAT H~BEDAT H~WKURS H~KUFIX
H~WAERS H~BUKRS H~ZTERM H~INCO1 H~INCO2 H~EKGRP
I~EBELP I~MATNR I~AFNAM I~MEINS I~MENGE I~WERKS
I~NETPR I~PEINH I~BPRME I~NETWR I~RETPO I~PSTYP
I~TXZ01 I~IDNLF I~MWSKZ I~ADRNR I~ADRN2 I~EMLIF I~KUNNR
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM EKKO AS H INNER JOIN EKPO AS I
ON I~EBELN = H~EBELN
WHERE H~EBELN = LS_PONUM
AND H~LOEKZ = ' ' AND I~LOEKZ = ' '. "2007/02/14[+1]JASON
LOOP AT ITAB.
IF ITAB-TXZ01 IS INITIAL .
SELECT SINGLE MAKTX INTO ITAB-TXZ01
FROM MAKT WHERE MATNR = ITAB-MATNR.
ENDIF.
IF ITAB-RETPO = 'X'. "Return Item
ITAB-NETPR = ITAB-NETPR * -1.
ITAB-NETWR = ITAB-NETWR * -1.
ENDIF.
*-- [ ADD BY Katy ITEM 交期 DATA +3 ]
SELECT SINGLE EINDT
INTO ITAB-EINDT
FROM EKET
WHERE EBELN = ITAB-EBELN AND EBELP = ITAB-EBELP.
*20080407 By Matt Calculate Tax
IF ITAB-MWSKZ NE ''.
CALL FUNCTION 'CALCULATE_TAX_FROM_NET_AMOUNT'
EXPORTING
I_BUKRS = ITAB-BUKRS
I_MWSKZ = ITAB-MWSKZ
I_WAERS = ITAB-WAERS
I_WRBTR = ITAB-NETWR
TABLES
T_MWDAT = T_RTAX1U15.
IF SY-SUBRC <> 0.
"MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
ENDIF.
ITAB-WMWST = T_RTAX1U15-WMWST.
ENDIF.
IF ITAB-ADRNR EQ ''. "20091201 Ship-to Address
IF ITAB-ADRN2 NE ''. "Address
ITAB-ADRNR = ITAB-ADRN2.
ELSEIF ITAB-EMLIF NE ''. "Vendor
SELECT SINGLE ADRNR INTO ITAB-ADRNR FROM LFA1
WHERE LIFNR EQ ITAB-EMLIF.
ELSEIF ITAB-KUNNR NE ''. "Customer
SELECT SINGLE ADRNR INTO ITAB-ADRNR FROM KNA1
WHERE KUNNR EQ ITAB-KUNNR.
ENDIF.
ENDIF.
MODIFY ITAB.
ENDLOOP.
**@04 2012/12/21 Add APPROVE_ID For 串簽名檔 (Begin) ===========================**
DATA: I_PURID1(12) TYPE C,
I_PURID2(12) TYPE C.
SELECT SINGLE APPROVE_ID INTO I_PURID1 FROM ZTMM019
WHERE DOC_NO EQ LS_PONUM AND SERIAL_NO EQ 1 AND DOC_TYPE EQ 'PO'.
SELECT SINGLE APPROVE_ID INTO I_PURID2 FROM ZTMM019
WHERE DOC_NO EQ LS_PONUM AND SERIAL_NO EQ 2 AND DOC_TYPE EQ 'PO'.
CONCATENATE 'ZPUR_' I_PURID1 INTO I_PURID1.
CONCATENATE 'ZPUR_' I_PURID2 INTO I_PURID2.
**@04 2012/12/21 Add APPROVE_ID For 串簽名檔 (End) ===========================**
* "**************************************
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = TNAPR-SFORM "Smartform name - Get from IMG 041207'
IMPORTING
FM_NAME = LF_FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF LF_FM_NAME IS INITIAL .
LF_FM_NAME = '/1bcdwb/sf00000001' .
ENDIF.
DATA ST_SFCTRLOP LIKE SSFCTRLOP.
DATA LS_COMPOSER_PARAM TYPE SSFCOMPOP.
LS_COMPOSER_PARAM-TDNEWID = 'X'. "CREATE NEW SPOOL ID EVERYTIME
IF TNAPR-FORMTYPE = '2'. "@03 Convert as PDF
ST_SFCTRLOP-GETOTF = 'X'.
ST_SFCTRLOP-NO_DIALOG = 'X'.
ENDIF.
ST_SFCTRLOP-LANGU = NAST-SPRAS.
CALL FUNCTION LF_FM_NAME
EXPORTING
CONTROL_PARAMETERS = ST_SFCTRLOP
OUTPUT_OPTIONS = LS_COMPOSER_PARAM
I_PURID1 = I_PURID1 "@04
I_PURID2 = I_PURID2 "@04
IMPORTING
JOB_OUTPUT_INFO = LS_JOB_INFO
TABLES
ITAB = ITAB
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4.
IF TNAPR-FORMTYPE = '2'. "@03 Convert as PDF file
PERFORM DOWNLOAD_AS_PDF TABLES LS_JOB_INFO-OTFDATA
USING VEKORG.
ENDIF.
ENDFORM. "ZENTRY_NEU
沒有留言:
張貼留言