REPORT YTEST01. DATA:GS_POHEADER TYPE BAPIMEPOHEADER, GS_POHEADERX TYPE BAPIMEPOHEADERX, GT_RETURN TYPE STANDARD TABLE OF BAPIRET2, GWA_RETURN TYPE BAPIRET2, GT_ITEM TYPE STANDARD TABLE OF BAPIMEPOITEM, GWA_ITEM TYPE BAPIMEPOITEM, GT_ITEMX TYPE STANDARD TABLE OF BAPIMEPOITEMX, GWA_ITEMX TYPE BAPIMEPOITEMX, GT_POSCHEDULE TYPE STANDARD TABLE OF BAPIMEPOSCHEDULE, GWA_POSCHEDULE TYPE BAPIMEPOSCHEDULE, GT_POSCHEDULEX TYPE STANDARD TABLE OF BAPIMEPOSCHEDULX, GWA_POSCHEDULEX TYPE BAPIMEPOSCHEDULX, GT_POCOND TYPE STANDARD TABLE OF BAPIMEPOCOND, GWA_POCOND TYPE BAPIMEPOCOND, GT_POCONDX TYPE STANDARD TABLE OF BAPIMEPOCONDX, GWA_POCONDX TYPE BAPIMEPOCONDX, GT_POCOMPONENTS TYPE STANDARD TABLE OF BAPIMEPOCOMPONENT, GWA_POCOMPONENTS TYPE BAPIMEPOCOMPONENT, GWA_POCOMPONENTS_TEMP TYPE BAPIMEPOCOMPONENT, GT_POCOMPONENTSX TYPE STANDARD TABLE OF BAPIMEPOCOMPONENTX, GWA_POCOMPONENTSX TYPE BAPIMEPOCOMPONENTX. DATA:LV_NUM TYPE BAPIMEPOHEADER-PO_NUMBER. GS_POHEADER-DOC_TYPE = '913'. GS_POHEADER-VENDOR = '0000110727'. GS_POHEADER-PURCH_ORG = '1010'. GS_POHEADER-PUR_GROUP = 'A06'. GS_POHEADER-COMP_CODE = '1000'. GS_POHEADER-CURRENCY = 'CNY'."货币 GS_POHEADER-DOC_DATE = SY-DATUM. GS_POHEADER-LANGU = SY-LANGU. GS_POHEADER-STATUS = 'I'. * GS_POHEADER-INFO_UPD = 'I'. * GS_POHEADER-ITEM_INTVL = ''. * GS_POHEADER-ITEM_INTVL = ''. GS_POHEADERX-DOC_TYPE = 'X'. GS_POHEADERX-VENDOR = 'X'. GS_POHEADERX-PURCH_ORG = 'X'. GS_POHEADERX-PUR_GROUP = 'X'. GS_POHEADERX-COMP_CODE = 'X'. GS_POHEADERX-DOC_DATE = 'X'. GS_POHEADERX-LANGU = 'X'. GS_POHEADERX-CURRENCY = 'X'."货币 GS_POHEADERX-STATUS = 'X'."货币 * GS_POHEADERX-ITEM_INTVL = 'X'. GWA_ITEM-PO_ITEM = '00010'. "采购凭证的项目编号 GWA_ITEM-MATERIAL = '000000000018007349'. GWA_ITEM-ITEM_CAT = 'L'. GWA_ITEM-SHORT_TEXT = 'SHORT'."短文本 GWA_ITEM-QUANTITY = 1."采购订单数量 GWA_ITEM-PO_UNIT = 'PC' ."采购订单的计量单位 GWA_ITEM-PLANT = '1010'. "工厂 GWA_ITEM-STGE_LOC = '1002'."库存地点 GWA_ITEM-TAX_CODE = 'J0'. GWA_ITEM-DATE_QTY_FIXED = 'X'. APPEND GWA_ITEM TO GT_ITEM. GWA_ITEMX-PO_ITEM = '00010'. "采购凭证的项目编号 GWA_ITEMX-MATERIAL = 'X'. GWA_ITEMX-SHORT_TEXT = 'X'."短文本 GWA_ITEMX-QUANTITY = 'X'."采购订单数量 GWA_ITEMX-PO_UNIT = 'X' ."采购订单的计量单位 GWA_ITEMX-PLANT = 'X'."工厂 GWA_ITEMX-STGE_LOC = 'X'. "库存地点 GWA_ITEMX-ITEM_CAT = 'X'. GWA_ITEMX-TAX_CODE = 'X'. GWA_ITEMX-DATE_QTY_FIXED = 'X'. APPEND GWA_ITEMX TO GT_ITEMX. GWA_POSCHEDULE-PO_ITEM = '00010'. "采购凭证的项目编号 GWA_POSCHEDULE-SCHED_LINE = 0001. "采购凭证的项目编号 GWA_POSCHEDULE-DEL_DATCAT_EXT = 'D'."交货日期的类别 GWA_POSCHEDULE-DELIVERY_DATE = SY-DATUM."交货日期 GWA_POSCHEDULE-QUANTITY = 1."采购订单数量 APPEND GWA_POSCHEDULE TO GT_POSCHEDULE. GWA_POSCHEDULEX-PO_ITEM = '00010'. "采购凭证的项目编号 GWA_POSCHEDULEX-SCHED_LINE = 0001. "采购凭证的项目编号 GWA_POSCHEDULEX-DEL_DATCAT_EXT = 'X'."交货日期的类别 GWA_POSCHEDULEX-DELIVERY_DATE = 'X'."交货日期 GWA_POSCHEDULEX-QUANTITY = 'X'."采购订单数量 APPEND GWA_POSCHEDULEX TO GT_POSCHEDULEX. GWA_POCOND-ITM_NUMBER = '00010'. GWA_POCOND-COND_TYPE = 'PB00'. GWA_POCOND-COND_VALUE = 10. "价格 GWA_POCOND-COND_UNIT = 'PC'. "条件单位 GWA_POCOND-COND_P_UNT = 1."GS_EXCEL_RAW0-PEINH. "价格单位 GWA_POCOND-CURRENCY = 'CNY'. GWA_POCOND-CHANGE_ID = 'I'. APPEND GWA_POCOND TO GT_POCOND. GWA_POCONDX-ITM_NUMBER = '00010'. GWA_POCONDX-COND_TYPE = 'X'. GWA_POCONDX-COND_VALUE = 'X'. GWA_POCONDX-COND_UNIT = 'X'. "条件单位 GWA_POCONDX-COND_P_UNT = 'X'. "价格单位 GWA_POCONDX-CURRENCY = 'X'. GWA_POCONDX-CHANGE_ID = 'X'. APPEND GWA_POCONDX TO GT_POCONDX. "如果有BOM,自动带出组件,如果使用下面代码会添加组件 * GWA_POCOMPONENTS-PO_ITEM = '00010' . * GWA_POCOMPONENTS-SCHED_LINE = 0001. ** lwa_pocomponents-item_no = '0010'. * GWA_POCOMPONENTS-MATERIAL = '000000000013008278'. * GWA_POCOMPONENTS-ENTRY_QUANTITY = 1. * GWA_POCOMPONENTS-ENTRY_UOM = 'PC'. * GWA_POCOMPONENTS-REQ_DATE = SY-DATUM - 1. "组件需求日期 * GWA_POCOMPONENTS-PLANT = '1010'. * GWA_POCOMPONENTS-CHANGE_ID = 'I'. * APPEND GWA_POCOMPONENTS TO GT_POCOMPONENTS. * * GWA_POCOMPONENTSX-PO_ITEM = '00010'. * GWA_POCOMPONENTSX-SCHED_LINE = 0001. ** lwa_pocomponentsx-item_no = '0010'. * GWA_POCOMPONENTSX-MATERIAL = 'X'. * GWA_POCOMPONENTSX-ENTRY_QUANTITY = 'X'. * GWA_POCOMPONENTSX-ENTRY_UOM = 'X'. * GWA_POCOMPONENTSX-REQ_DATE = 'X'. * GWA_POCOMPONENTSX-PLANT = 'X'. * GWA_POCOMPONENTSX-CHANGE_ID = 'X'. * APPEND GWA_POCOMPONENTSX TO GT_POCOMPONENTSX. CALL FUNCTION 'BAPI_PO_CREATE1' EXPORTING POHEADER = GS_POHEADER POHEADERX = GS_POHEADERX * POADDRVENDOR = * TESTRUN = * MEMORY_UNCOMPLETE = * MEMORY_COMPLETE = * POEXPIMPHEADER = * POEXPIMPHEADERX = * VERSIONS = * NO_MESSAGING = * NO_MESSAGE_REQ = * NO_AUTHORITY = NO_PRICE_FROM_PO = 'X' * PARK_COMPLETE = * PARK_UNCOMPLETE = IMPORTING EXPPURCHASEORDER = LV_NUM * EXPHEADER = * EXPPOEXPIMPHEADER = TABLES RETURN = GT_RETURN POITEM = GT_ITEM POITEMX = GT_ITEMX * POADDRDELIVERY = POSCHEDULE = GT_POSCHEDULE POSCHEDULEX = GT_POSCHEDULEX * POACCOUNT = * POACCOUNTPROFITSEGMENT = * POACCOUNTX = * POCONDHEADER = * POCONDHEADERX = POCOND = GT_POCOND POCONDX = GT_POCONDX * POLIMITS = * POCONTRACTLIMITS = * POSERVICES = * POSRVACCESSVALUES = * POSERVICESTEXT = * EXTENSIONIN = * EXTENSIONOUT = * POEXPIMPITEM = * POEXPIMPITEMX = * POTEXTHEADER = * POTEXTITEM = * ALLVERSIONS = * POPARTNER = POCOMPONENTS = GT_POCOMPONENTS POCOMPONENTSX = GT_POCOMPONENTSX . IF SY-SUBRC = 0. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING WAIT = 'X'. WRITE LV_NUM. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. ENDIF.
审批:BAPI_PO_RELEASE
反审:BAPI_PO_RESET_RELEASE
参数:单号+批准代码
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/18606.html