SAP MM BAPI_PO_CREATE1的用法
SAP MM BAPI_PO_CREATE1的用法
初步對BAPI_PO_CREATE1有了一點了解,下面對這個bapi做一些我的體會講解:
下面先將程式上傳, 在程式中我只簡單的對poheader和poitem做了一些輸入,產生了一張po,並且po中只可以有一個項被採購,其實其中還有其他可以加入,例如: schedule,account,一起其他一些東西,,在這個程式中我就不在做介紹了,我將在後續的文章中說出我對這個bapi的其他體會,希望大家關注我的博克,謝!
REPORT ZCREATPOBAPI .
TABLES BAPIMEPOHEADER.
CONSTANTS : C_X VALUE 'X'.
DATA
WA_POHEADER TYPE BAPIMEPOHEADER. "所要增加的內容
DATA WA_POHEADERX TYPE BAPIMEPOHEADERX. "針對要增加的內容做一個標記,其實標記過了才可以被修改的
DATA WA_POITEM TYPE BAPIMEPOITEM. "po中item的內容,工作區
DATA ITAB_POITEM LIKE TABLE OF WA_POITEM. po中item的內容,內表
DATA WA_POITEMX
TYPE BAPIMEPOITEMX. "po中item增加內容的標記 工作區
DATA ITAB_POITEMX LIKE TABLE OF WA_POITEMX."po中item增加內容的標記 內表
DATA WA_RETURN TYPE BAPIRET2. "訊息 返回 ,工作區
DATA ITAB_RETURN LIKE TABLE OF WA_RETURN. "訊息返回, 內表
*HEADER.
PARAMETERS: P_NUMBER LIKE BAPIMEPOHEADER-PO_NUMBER,
P_COCODE
LIKE BAPIMEPOHEADER-COMP_CODE DEFAULT 'CN01',
P_DOTYPE
LIKE BAPIMEPOHEADER-DOC_TYPE DEFAULT 'ZST3',
P_STATUS
LIKE BAPIMEPOHEADER-STATUS DEFAULT 'I',
P_CRDATE
LIKE BAPIMEPOHEADER-CREAT_DATE ,
P_CRDABY
LIKE BAPIMEPOHEADER-CREATED_BY DEFAULT SY-UNAME,
P_ITEMIN
LIKE BAPIMEPOHEADER-ITEM_INTVL DEFAULT '1',
P_VENDOR
LIKE BAPIMEPOHEADER-VENDOR DEFAULT 'TWM4',
P_LANGU LIKE BAPIMEPOHEADER-LANGU,
P_PMNTTR
LIKE BAPIMEPOHEADER-PMNTTRMS DEFAULT 'COD',
P_PURCH LIKE BAPIMEPOHEADER-PURCH_ORG DEFAULT 'CN01',
P_PURGR LIKE BAPIMEPOHEADER-PUR_GROUP DEFAULT 'KXX',
P_DOCDAT
LIKE BAPIMEPOHEADER-DOC_DATE,
P_VATCN LIKE BAPIMEPOHEADER-VAT_CNTRY DEFAULT 'CNY'.
*ITEM
SELECTION-SCREEN SKIP.
PARAMETERS: P_POITEM LIKE BAPIMEPOITEM-PO_ITEM DEFAULT '1',
P_MATNER LIKE BAPIMEPOITEM-MATERIAL,
P_PLANT LIKE BAPIMEPOITEM-PLANT DEFAULT 'CKH1',
P_LOCT LIKE BAPIMEPOITEM-STGE_LOC DEFAULT '0000',
P_QUANTI LIKE BAPIMEPOITEM-QUANTITY ,
P_NETPRI LIKE BAPIMEPOITEM-NET_PRICE,
P_PRICEU LIKE BAPIMEPOITEM-PRICE_UNIT,
P_RENAME LIKE BAPIMEPOITEM-PREQ_NAME DEFAULT SY-UNAME,
P_PRDATE LIKE BAPIMEPOITEM-PERIOD_IND_EXPIRATION_DATE DEFAULT
'D'.
*herader data
wa_poheader-po_number = P_NUMBER .
wa_poheader-comp_code = P_COCODE .
wa_poheader-doc_type = P_DOTYPE .
wa_poheader-status = P_STATUS .
wa_poheader-creat_date = P_CRDATE.
wa_poheader-CREATED_BY = P_CRDABY.
wa_poheader-item_intvl = P_ITEMIN.
wa_poheader-vendor = P_VENDOR.
wa_poheader-langu = P_LANGU .
wa_poheader-pmnttrms = P_PMNTTR.
wa_poheader-purch_org = P_PURCH .
wa_poheader-pur_group = P_PURGR .
wa_poheader-doc_date = P_DOCDAT.
wa_poheader-vat_cntry = P_VATCN .
*po header flag
wa_poheaderx-po_number = 'X' .
wa_poheaderx-comp_code = 'X' .
wa_poheaderx-doc_type = 'X' .
wa_poheaderx-status = 'X' .
wa_poheaderx-creat_date = 'X'.
wa_poheaderx-created_by = 'X'.
wa_poheaderx-item_intvl = 'X'.
wa_poheaderx-vendor = 'X'.
wa_poheaderx-langu = 'X' .
wa_poheaderx-pmnttrms = 'X'.
wa_poheaderx-purch_org = 'X' .
wa_poheaderx-pur_group = 'X' .
wa_poheaderx-doc_date = 'X'.
wa_poheaderx-vat_cntry = 'X' .
*po item data
wa_poitem-po_item
= P_POITEM.
wa_poitem-MATERIAL
= P_MATNER .
wa_poitem-PLANT
= P_PLANT .
WA_POITEM-STGE_LOC
= P_LOCT .
wa_poitem-QUANTITY
= P_QUANTI .
wa_poitem-NET_PRICE
= P_NETPRI .
wa_poitem-PRICE_UNIT
= P_PRICEU .
wa_poitem-PREQ_NAME
= P_RENAME .
wa_poitem-PERIOD_IND_EXPIRATION_DATE = P_PRDATE .
APPEND WA_POITEM TO ITAB_POITEM.
*po item flag
wa_poitemx-po_item
= p_poitem.
wa_poitemx-po_itemx
= 'X'.
wa_poitemx-MATERIAL
= 'X' .
wa_poitemx-PLANT
= 'X'.
WA_POITEMX-STGE_LOC
= 'X'.
wa_poitemx-QUANTITY
= 'X'.
wa_poitemx-NET_PRICE
= 'X'.
wa_poitemx-PRICE_UNIT
= 'X'.
wa_poitemx-PREQ_NAME
= 'X'.
wa_poitemx-PERIOD_IND_EXPIRATION_DATE = 'X'.
append wa_poitemx to itab_poitemx.
*call bapi
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = wa_poheader
POHEADERX = wa_poheaderX
TABLES
RETURN =
ITAB_RETURN
POITEM =
ITAB_POITEM
POITEMX = itab_poitemx.
* POACCOUNT = I_PO_ACCOUNT
* POACCOUNTX = I_PO_ACCOUNTX
* POSCHEDULE = I_PO_SCHEDULE
* POSCHEDULEX = I_PO_SCHEDULEX.
DATA ERROR_LOG
TYPE C.
LOOP AT ITAB_RETURN INTO WA_RETURN.
IF WA_RETURN-TYPE = 'E'.
ERROR_LOG = 'X'.
EXIT.
ENDIF.
CLEAR WA_RETURN.
ENDLOOP.
IF ERROR_LOG = 'X'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
.
WRITE 'MESSAGE ERROR'.
LOOP AT ITAB_RETURN INTO WA_RETURN.
WRITE: / WA_RETURN-TYPE, WA_RETURN-MESSAGE.
CLEAR WA_RETURN.
ENDLOOP.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
LOOP AT ITAB_RETURN INTO WA_RETURN.
WRITE: / WA_RETURN-TYPE ,WA_RETURN-MESSAGE.
CLEAR WA_RETURN.
ENDLOOP.
ENDIF.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29829936/viewspace-1482196/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 「SAP技術」SAP MM 事務程式碼ME17的用法
- SAP MM Movement Type 503的使用
- 「SAP技術」SAP MM MPN物料的採購初探
- SAP MM PR 審批中的REJECT
- SAP MM Purchase Order History CategoryGo
- SAP MM The Table MBEWH Update Logic
- SAP MM 物料主資料的Document Data
- SAP MM 工廠級別的批次管理?
- SAP MM 外包 - 委外加工流程
- SAP MM Return Purchase Order之使用
- SAP MM MIGO介面裡的'Via Delivery'選項Go
- SAP MM MIGO介面上的Freight標籤頁Go
- SAP MM 盤點憑證上的posting blockBloC
- SAP ABAP FOR ALL ENTRIES 的用法
- SAP MM 採購預付款管理初探
- SAP MM 關於採購組設計的思考
- SAP Retail MM42不能修改物料的物料組AI
- SAP MM 預製發票相關的Function ModulesFunction
- SAP MM 關於STO步驟和配置
- SAP MM UB型別的退貨STO流程簡述型別
- SAP MM 採購價格裡的階梯價格
- SAP MM 物料成本價格修改歷史的查詢
- SAP MM MIGO介面‘Where’標籤頁裡的storage binGo
- SAP MM MD02與MS02的區別
- 「SAP技術」SAP MM 向交貨單的存在不阻止PO被刪除
- SAP MM T-code MD04的使用,是有前提的!
- 「SAP技術」SAP MM 委外加工採購流程裡副產品的收貨
- SAP MM模組調研問卷樣例
- SAP MM 特殊庫存之T庫存初探
- 【MM系列】SAP庫齡報表邏輯理解
- SAP MM 儲存條件 - Room Temperature Vs AmbientOOM
- SAP MM GR-based IV, 無GR不能IV?
- 「翻譯」SAP MM 供應商Rebate中的財務配置BAT
- SAP MM 物料主資料裡的‘Packaging Material Type'欄位
- SAP MM 給合同的ITEM上傳附件以及附件查詢
- SAP MM 某專案上產品層次的設計
- SAP MM 採購訂單抬頭資料裡的Condition
- SAP MM MB1C + 523 移動型別的使用型別
- SAP MM MM17裡不能修改物料主資料'Purchasing Value Key'欄位值?