CALL FUNCTION 'BAPI_PO_CREATE1' 相关报错
*&---------------------------------------------------------------------*
*& Report ZQJ06
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*& Report ZQJ06
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZQJ06.
CONSTANTS : C_X VALUE 'X'.
CONSTANTS : C_X VALUE 'X'.
data: wa_POHEADER TYPE BAPIMEPOHEADER.
DATA WA_POHEADERX TYPE BAPIMEPOHEADERX. "针对要增加的内容做一个标记,其实标记过了才可以被修改的
data: EXPPURCHASEORDER TYPE BAPIMEPOHEADER-PO_NUMBER.
data: EXPHEADER LIKE BAPIMEPOHEADER.
data: wa_poitem like BAPIMEPOITEM .
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_POSCHEDULE type BAPIMEPOSCHEDULE.
data: itab_poshedule like TABLE OF wa_poschedule.
data: EXPHEADER LIKE BAPIMEPOHEADER.
data: wa_poitem like BAPIMEPOITEM .
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_POSCHEDULE type BAPIMEPOSCHEDULE.
data: itab_poshedule like TABLE OF wa_poschedule.
DATA WA_RETURN TYPE BAPIRET2. "消息 返回 ,工作区
DATA ITAB_RETURN LIKE TABLE OF WA_RETURN. "消息返回, 内表
data:RETURN LIKE table of BAPIRET2.
wa_POHEADER-comp_code = '1000'. "公司代碼
wa_POHEADER-doc_type = 'NB'. "採購文件類型
wa_POHEADER-purch_org = '1000'. "採購組織
wa_POHEADER-pur_group = '000'. "採購群組
wa_POHEADER-vendor = '0000000015'. "供貨(發貨)工廠 有可能是位数不够
wa_POHEADER-CREAT_DATE = sy-datum.
wa_POHEADER-doc_type = 'NB'. "採購文件類型
wa_POHEADER-purch_org = '1000'. "採購組織
wa_POHEADER-pur_group = '000'. "採購群組
wa_POHEADER-vendor = '0000000015'. "供貨(發貨)工廠 有可能是位数不够
wa_POHEADER-CREAT_DATE = sy-datum.
wa_poheader-created_by = sy-uname.
wa_poheader-doc_date = sy-datum.
wa_poheader-doc_date = sy-datum.
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' .
wa_poitem-po_item = '10'. "行项目
*wa_poitem-PO_UNIT = 'M'.
wa_poitem-MATERIAL = '100-100'.
wa_poitem-QUANTITY = '1320' .
wa_poitem-MATL_GROUP = '001'.
wa_poitem-PLANT = '1000'.
wa_poitem-PREQ_NAME = 'qianjun'
.
wa_poitem-PLAN_DEL = 20.
wa_poitem-PERIOD_IND_EXPIRATION_DATE = sy-datum.
append wa_poitem to itab_poitem.
wa_poitem-PLAN_DEL = 20.
wa_poitem-PERIOD_IND_EXPIRATION_DATE = sy-datum.
append wa_poitem to itab_poitem.
wa_poitemx-po_item = '10'.
wa_poitemx-po_itemx = 'Y'.
wa_poitemx-MATERIAL = 'Y' .
wa_poitemx-PLANT = 'X'.
WA_POITEMX-STGE_LOC = 'X'.
wa_poitemx-QUANTITY = 'Y'.
wa_poitemx-NET_PRICE = 'Y'.
wa_poitemx-PRICE_UNIT = 'Y'.
wa_poitemx-PREQ_NAME = 'X'.
wa_poitemx-PERIOD_IND_EXPIRATION_DATE = 'Y'.
append wa_poitemx to itab_poitemx.
wa_poschedule-po_item = 10.
wa_POSCHEDULE-DELIVERY_DATE = '20110510'.
append wa_POSCHEDULE to itab_poshedule.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = wa_poheader
POHEADERX = wa_poheaderx
* POADDRVENDOR =
* TESTRUN =
* MEMORY_UNCOMPLETE =
* MEMORY_COMPLETE =
* POEXPIMPHEADER =
* POEXPIMPHEADERX =
* VERSIONS =
* NO_MESSAGING =
* NO_MESSAGE_REQ =
* NO_AUTHORITY =
* NO_PRICE_FROM_PO =
IMPORTING
EXPPURCHASEORDER = EXPPURCHASEORDER
EXPHEADER = EXPHEADER
* EXPPOEXPIMPHEADER =
TABLES
RETURN = ITAB_RETURN
POITEM = itab_poitem
POITEMX = itab_poitemx
* POADDRDELIVERY =
* POSCHEDULE = itab_poshedule
* POSCHEDULEX =
* POACCOUNT =
* POACCOUNTPROFITSEGMENT =
* POACCOUNTX =
* POCONDHEADER =
* POCONDHEADERX =
* POCOND =
* POCONDX =
* POLIMITS =
* POCONTRACTLIMITS =
* POSERVICES =
* POSRVACCESSVALUES =
* POSERVICESTEXT =
* EXTENSIONIN =
* EXTENSIONOUT =
* POEXPIMPITEM =
* POEXPIMPITEMX =
* POTEXTHEADER =
* POTEXTITEM =
* ALLVERSIONS =
* POPARTNER =
* POCOMPONENTS =
* POCOMPONENTSX =
* POSHIPPING =
* POSHIPPINGX =
* POSHIPPINGEXP =
.
DATA ERROR_LOG TYPE C.
POITEMX = itab_poitemx
* POADDRDELIVERY =
* POSCHEDULE = itab_poshedule
* POSCHEDULEX =
* POACCOUNT =
* POACCOUNTPROFITSEGMENT =
* POACCOUNTX =
* POCONDHEADER =
* POCONDHEADERX =
* POCOND =
* POCONDX =
* POLIMITS =
* POCONTRACTLIMITS =
* POSERVICES =
* POSRVACCESSVALUES =
* POSERVICESTEXT =
* EXTENSIONIN =
* EXTENSIONOUT =
* POEXPIMPITEM =
* POEXPIMPITEMX =
* POTEXTHEADER =
* POTEXTITEM =
* ALLVERSIONS =
* POPARTNER =
* POCOMPONENTS =
* POCOMPONENTSX =
* POSHIPPING =
* POSHIPPINGX =
* POSHIPPINGEXP =
.
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.
本人常年接收SAP运维和远程项目,ECC,S/4HANA,CRM,WDA.
远程人天可谈,终身售后,有活请联系V信:18925782767(问问题免费,欢迎交流!)
!!请关注本人技术分享公众号:SAP翔子(可扫头像二维码)
每天分享新知识,博客文章也会陆续整理并迁移至公众号,与您一起共同学习