FUNCTION ZRFC_WMS_EBELN.
*"----------------------------------------------------------------------
*"*"本地接口:
*" TABLES
*" IT_HEADER STRUCTURE ZMM0005X OPTIONAL
*" IT_DETAIL STRUCTURE ZMM0004X OPTIONAL
*" ET_LOG STRUCTURE BAPIRET2 OPTIONAL
*" IT_RETURN STRUCTURE ZINTERFACE_RETURN OPTIONAL
*"----------------------------------------------------------------------
*2014.12.1 加入电商控制
*2016.01.08 支持多公司转储
*2016.07.13 去除无库存不能创建订单提示
*2016.04.30 灯带买赠处理
INCLUDE ZRFC_CNT.
DATA:
EP_EBELN LIKE EKKO-EBELN,
EP_FRGKX TYPE FRGKX,
* EX_VLELN LIKE EKKO-EBELN,
IP_VBELN LIKE LIPS-VBELN,
EP_SUBRC0 TYPE SY-SUBRC.
DATA:
******* ME21N
ET_ZMM0012 LIKE ZMM0012 OCCURS 0 WITH HEADER LINE,
IP_DETAIL LIKE ZWMS_ORDER_DETAIL OCCURS 0 WITH HEADER LINE,
IP_POHEADER1 LIKE ZMM0005X,
IP_HISTORY LIKE ZRFC_HISTORY,
ET_LOG_1 LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
****** RECORD DATA
IT_REC LIKE ZWMS_CONVERT OCCURS 0 WITH HEADER LINE,
**************
IT_DELETE LIKE IT_HEADER OCCURS 0 WITH HEADER LINE.
RANGES:
R_PURCH_ORG FOR IP_POHEADER1-PURCH_ORG. "不参加自动转储采购组
R_PURCH_ORG-SIGN = 'I'.
R_PURCH_ORG-OPTION = 'EQ'.
SELECT EKORG INTO R_PURCH_ORG-LOW FROM ZWMS_EKORG WHERE FA = 'X'.
* R_PURCH_ORG-LOW = '1006'.
* APPEND R_PURCH_ORG.
* R_PURCH_ORG-LOW = '1008'.
* APPEND R_PURCH_ORG.
* R_PURCH_ORG-LOW = '1009'.
* APPEND R_PURCH_ORG.
* R_PURCH_ORG-LOW = '1010'.
* APPEND R_PURCH_ORG.
* R_PURCH_ORG-LOW = '1026'.
* APPEND R_PURCH_ORG.
APPEND R_PURCH_ORG.
ENDSELECT.
*******************删除SAP中已经存在的外部单据
IT_HEADER-BILLNO = '0'.
APPEND IT_HEADER.
SELECT BILLNO
INTO IT_DELETE
FROM ZWMS_CONVERT AS C
FOR ALL ENTRIES IN IT_HEADER
WHERE C~BILLNO = IT_HEADER-BILLNO.
DELETE IT_HEADER WHERE BILLNO = IT_DELETE-BILLNO.
ENDSELECT.
DELETE IT_HEADER WHERE BILLNO = '0'.
LOOP AT IT_HEADER.
CLEAR :
IP_POHEADER1,
IP_DETAIL,
IP_HISTORY.
IP_HISTORY-MANDT = SY-MANDT.
IP_HISTORY-OANO = IT_HEADER-BILLNO.
IP_HISTORY-OANAME = SY-UNAME.
IP_HISTORY-OAMODULE = 'WMS-WJ'.
IP_HISTORY-SAPNO = IT_HEADER-BILLNO.
IT_REC-BILLNO = IT_HEADER-BILLNO.
IT_REC-EBELN_DAT = SY-DATUM.
IT_REC-MANDT = SY-MANDT.
IT_REC-CHARG = IT_HEADER-CHARG.
IT_REC-LGPBE = IT_HEADER-LGPBE.
IT_RETURN-BILLNO = IT_HEADER-BILLNO.
MOVE-CORRESPONDING IT_HEADER TO IP_POHEADER1.
IP_POHEADER1-DOC_TYPE = 'NB'.
* IF IP_POHEADER1-PURCH_ORG IN R_PURCH_ORG or IP_POHEADER1-PUR_GROUP = '204' .
* ELSE.
* IP_POHEADER1-COMP_CODE = '6000'.
* PERFORM F_ADD_ZERO USING IP_POHEADER1-COMP_CODE.
* IP_POHEADER1-PURCH_ORG = '1002'."初始化一下
* IP_POHEADER1-VENDOR = '8100'."初始化一下
*
* IP_POHEADER1-PUR_GROUP = '201'."默认内销
*
* ENDIF.
IP_POHEADER1-HEADR_TEXT = IT_HEADER-BILLNO.
CLEAR: IP_DETAIL[].
LOOP AT IT_DETAIL WHERE BILLNO = IT_HEADER-BILLNO.
MOVE-CORRESPONDING IT_DETAIL TO IP_DETAIL.
MOVE-CORRESPONDING IT_DETAIL TO IT_REC.
* IF IP_POHEADER1-PURCH_ORG IN R_PURCH_ORG or IP_POHEADER1-PUR_GROUP = '204'.
** IP_DETAIL-FREE_ITEM = 'X'.
* ELSE.
* IP_POHEADER1-VENDOR = IT_DETAIL-PLANT2.
* IF IP_POHEADER1-VENDOR = '8100'.
* IP_POHEADER1-PURCH_ORG = '1002'.
* ENDIF.
* IF IP_POHEADER1-VENDOR = '8000'.
* IP_POHEADER1-PURCH_ORG = '1003'.
* ENDIF.
* ENDIF.
*
* PERFORM F_ADD_ZERO USING IP_POHEADER1-VENDOR.
* 康向林 11:18:40
* 目前是:8000-8009流向6000-8009;8100-4000流向6000-4000;8100-3009流向6000-6009
* 欧洲新规则
* 8000-8000-8061 -> 6000公司 6700工厂 6700库 1003(采购组织) 采购组 201 产生采购订单NB->交货单->过帐
* 8100-8100-8167 -> 6000公司 6700工厂 6700库 1003(采购组织) 采购组 201 只产生采购订单NB
IF IP_POHEADER1-COMP_CODE IS INITIAL.
SELECT SINGLE BUKRS INTO IP_POHEADER1-COMP_CODE
FROM T001K AS K
JOIN T001W AS W ON W~BWKEY = K~BWKEY
WHERE
WERKS = IT_DETAIL-PLANT. "通过工厂取公司,适应一个公司不同工厂情况
IF SY-SUBRC > 0.
IP_POHEADER1-COMP_CODE = IT_DETAIL-PLANT.
ENDIF.
ENDIF.
IF IP_POHEADER1-VENDOR IS INITIAL.
IP_POHEADER1-VENDOR = IT_DETAIL-PLANT2.
ENDIF.
********************1002 欧普8100-6000组织
********************1003 欧普8000-6000组织
********************1004 欧普8000-8100组织
********************1005 欧普6000-7000组织
********************1006 欧普6000-6100组织
********************1007 欧普6000-6300组织
********************1008 欧普6000-8000组织
********************1009 欧普6000-6200组织
********************1010 欧普6000-2001组织
********************1011 欧普8000-6100组织
IF IP_POHEADER1-PURCH_ORG IS INITIAL.
PERFORM F_ADD_ZERO USING IP_POHEADER1-VENDOR.
SELECT SINGLE EKORG INTO IP_POHEADER1-PURCH_ORG
FROM ZWMS_EKORG
WHERE LIFNR = IP_POHEADER1-VENDOR
AND BUKRS = IP_POHEADER1-COMP_CODE
AND WERKS = IT_DETAIL-PLANT.
* IF IP_POHEADER1-COMP_CODE = '6000' AND IP_POHEADER1-VENDOR = '8100' .
* IP_POHEADER1-PURCH_ORG = '1002'.
* ENDIF.
* IF IP_POHEADER1-COMP_CODE = '6000' AND IP_POHEADER1-VENDOR = '8000'.
* IP_POHEADER1-PURCH_ORG = '1003'.
* ENDIF.
* IF IP_POHEADER1-COMP_CODE = '8000' AND IP_POHEADER1-VENDOR = '8100' .
* IP_POHEADER1-PURCH_ORG = '1004'.
* ENDIF.
*
* IF IP_POHEADER1-COMP_CODE = '7000' AND IP_POHEADER1-VENDOR = '6000' .
* IP_POHEADER1-PURCH_ORG = '1005'.
* ENDIF.
* IF IP_POHEADER1-COMP_CODE = '6100' AND IP_POHEADER1-VENDOR = '6000' .
* IP_POHEADER1-PURCH_ORG = '1006'.
* ENDIF.
* IF IP_POHEADER1-COMP_CODE = '8000' AND IP_POHEADER1-VENDOR = '6000' .
* IP_POHEADER1-PURCH_ORG = '1008'.
* ENDIF.
* IF IP_POHEADER1-COMP_CODE = '6200' AND IP_POHEADER1-VENDOR = '6000' .
* IP_POHEADER1-PURCH_ORG = '1009'.
* ENDIF.
* IF IP_POHEADER1-COMP_CODE = '2100' AND IP_POHEADER1-VENDOR = '6000' .
* IP_POHEADER1-PURCH_ORG = '1010'.
* ENDIF.
* IF IP_POHEADER1-COMP_CODE = '6100' AND IP_POHEADER1-VENDOR = '8000' .
* IP_POHEADER1-PURCH_ORG = '1011'.
* ENDIF.
*
*
* IF IP_POHEADER1-COMP_CODE = '2002' AND IP_POHEADER1-VENDOR = '8000' .
* IP_POHEADER1-PURCH_ORG = '1012'.
* ENDIF.
* IF IP_POHEADER1-COMP_CODE = '6600' AND IP_POHEADER1-VENDOR = '8000' .
* IP_POHEADER1-PURCH_ORG = '1013'.
* ENDIF.
*
*
* IF IP_POHEADER1-COMP_CODE = '6800' AND IP_POHEADER1-VENDOR = '8000' .
* IP_POHEADER1-PURCH_ORG = '1014'.
* ENDIF.
*
*
* IF IP_POHEADER1-COMP_CODE = '6900' AND IP_POHEADER1-VENDOR = '6000' .
* IP_POHEADER1-PURCH_ORG = '1015'.
* ENDIF.
*
* IF IP_POHEADER1-COMP_CODE = '6300' AND IP_POHEADER1-VENDOR = '6900' .
* IP_POHEADER1-PURCH_ORG = '1016'.
* ENDIF.
* IF IP_POHEADER1-COMP_CODE = '6000' AND IP_POHEADER1-VENDOR = '6600' .
* IP_POHEADER1-PURCH_ORG = '1017'.
* ENDIF.
*
***************1018 欧普6000-6800组织
***************1019 欧普6800-6000组织
***************1020 欧普6800-6100组织
***************1021 欧普6800-6300组织
***************1022 欧普6600-8100组织
***************1023 灯饰1168-1169组织
*
* IF IP_POHEADER1-COMP_CODE = '6800' AND IP_POHEADER1-VENDOR = '6000' .
* IP_POHEADER1-PURCH_ORG = '1018'.
* ENDIF.
*
* IF IP_POHEADER1-COMP_CODE = '6000' AND IP_POHEADER1-VENDOR = '6800' .
* IP_POHEADER1-PURCH_ORG = '1019'.
* ENDIF.
*
* IF IP_POHEADER1-COMP_CODE = '6100' AND IP_POHEADER1-VENDOR = '6800' .
* IP_POHEADER1-PURCH_ORG = '1020'.
* ENDIF.
*
* IF IP_POHEADER1-COMP_CODE = '6300' AND IP_POHEADER1-VENDOR = '6800' .
* IP_POHEADER1-PURCH_ORG = '1021'.
* ENDIF.
*
* IF IP_POHEADER1-COMP_CODE = '8100' AND IP_POHEADER1-VENDOR = '6600' .
* IP_POHEADER1-PURCH_ORG = '1022'.
* ENDIF.
*
* IF IP_POHEADER1-COMP_CODE = '1169' AND IP_POHEADER1-VENDOR = '1168' .
* IP_POHEADER1-PURCH_ORG = '1023'.
* ENDIF.
*
* IF IP_POHEADER1-COMP_CODE = '1169' AND IP_POHEADER1-VENDOR = '6000' .
* IP_POHEADER1-PURCH_ORG = '1026'.
* ENDIF.
*
ENDIF.
***外贸出口业务需求建立UB单 从8000工厂转到8005工厂
IF IP_POHEADER1-COMP_CODE = '8000' AND IP_POHEADER1-VENDOR = '8000' AND IT_DETAIL-PLANT = '8005'.
IP_POHEADER1-DOC_TYPE = 'UB'.
IP_POHEADER1-PURCH_ORG = '8005'.
ENDIF.
IF IP_POHEADER1-PUR_GROUP IS INITIAL.
IP_POHEADER1-PUR_GROUP = '201'."默认内销
ENDIF.
IF IP_POHEADER1-PUR_GROUP = '201' .
IP_DETAIL-SUPPL_STLOC = IT_DETAIL-LGPBE2.
ENDIF.
IF IT_DETAIL-LGPBE2 = '8167' OR IT_DETAIL-LGPBE2 = '8061'.
IP_POHEADER1-PUR_GROUP = '800'."外销
ENDIF.
* IF IT_DETAIL-STGE_LOC = '8009' OR IT_DETAIL-STGE_LOC = '6009' OR IT_DETAIL-STGE_LOC = '4000'.
* IP_POHEADER1-PUR_GROUP = '202'."外销
* ENDIF.
IF IP_POHEADER1-PUR_GROUP = '204' .
IF IP_POHEADER1-LGPBE IS NOT INITIAL.
MOVE IP_POHEADER1-LGPBE TO IP_DETAIL-ORDER_REASON.
ELSE.
IP_DETAIL-ORDER_REASON = '82' .
ENDIF.
** 電商退貨業務
IF IT_DETAIL-RET_ITEM = 'X' .
*************20180125
*************杜丹丹 9:30:50
*************额,这个是这样的6004工厂的,客户退货入6004的8032---6900的3017---6000的3017
*************杜丹丹 9:32:36
************中山,客户退货入6004的8032---6900的3013---6000的3013
***
*** IF IP_POHEADER1-VENDOR = '6900' OR IP_POHEADER1-VENDOR = '6000' .
*** IF IP_DETAIL-ORDER_REASON = '28' .
*** IP_DETAIL-SUPPL_STLOC = '3013'.
*** ELSE.
*** IP_DETAIL-SUPPL_STLOC = '3017'.
*** ENDIF.
*** ENDIF.
***
*************库位是1174公司的1201
*** IF IP_POHEADER1-VENDOR = '1174'.
*** IP_DETAIL-SUPPL_STLOC = '1101'.
*** ENDIF.
* IP_POHEADER1-VENDOR = IT_DETAIL-PLANT2.
******Ref-2018040200030 WMS回写转储单库位修改
IP_DETAIL-SUPPL_STLOC = IT_DETAIL-LGPBE2.
ENDIF.
ENDIF.
IF IP_POHEADER1-PURCH_ORG = '1040'.
IP_DETAIL-ORDER_REASON = '02' .
ENDIF.
PERFORM F_ADD_ZERO USING IP_POHEADER1-VENDOR.
IP_DETAIL-DELIVERY_DATE = SY-DATUM.
APPEND IP_DETAIL.
ENDLOOP.
* IF IP_POHEADER1-PURCH_ORG IN R_PURCH_ORG OR IP_POHEADER1-PUR_GROUP = '204'. "不判断库存
* ELSE.
* DATA: IT_MARD LIKE MARD.
* PERFORM F_ADD_ZERO USING IT_REC-MATERIAL.
* IF IT_DETAIL-RET_ITEM = 'X'."* 如果是返回项目,判断6000公司是否有库存
* SELECT SINGLE * INTO IT_MARD
* FROM MARD
* WHERE LGORT = IT_REC-LGPBE AND WERKS = IT_REC-PLANT AND MATNR = IT_REC-MATERIAL.
* ELSE." * 正常项目,判断3000公司是否有库存
* SELECT SINGLE * INTO IT_MARD FROM MARD WHERE LGORT = IT_REC-LGPBE2 AND WERKS = IT_REC-PLANT2 AND MATNR = IT_REC-MATERIAL.
* ENDIF.
* ENDIF.
* MOVE IT_HEADER-BILLNO TO ET_LOG-ID.
* ET_LOG-MESSAGE = IT_REC-LGPBE2.
* ET_LOG-MESSAGE_V1 = IT_REC-PLANT2.
* ET_LOG-MESSAGE_V2 = IT_REC-MATERIAL.
* ET_LOG-MESSAGE_V3 = IT_MARD-LABST.
* ET_LOG-MESSAGE_V4 = IT_REC-QUANTITY.
* APPEND ET_LOG.
********扩展物料视图
LOOP AT IP_DETAIL.
CLEAR: ET_LOG,ET_LOG[].
CALL FUNCTION 'ZRFC_AUTO_MAT'
EXPORTING
V_MATNR = IP_DETAIL-MATERIAL
V_WERKS = IP_DETAIL-PLANT
V_LIFNR = IP_POHEADER1-VENDOR
* IMPORTING
* LS_RETURN = LS_LOG
TABLES
RETURNMSG = ET_LOG_1.
APPEND LINES OF ET_LOG_1 TO ET_LOG.
ENDLOOP.
DATA: BEGIN OF ITM OCCURS 0 ,
MATERIAL TYPE MATNR,
END OF ITM.
* IF IT_MARD-LABST >= IT_REC-QUANTITY
* OR IP_POHEADER1-PURCH_ORG IN R_PURCH_ORG
* OR IP_POHEADER1-PUR_GROUP = '204'
* OR IP_POHEADER1-COMP_CODE = '6900' .
**1.创建采购订单
IF IP_POHEADER1-PURCH_ORG IN R_PURCH_ORG.
DATA:IP_DETAIL1 LIKE IP_DETAIL OCCURS 0 WITH HEADER LINE.
CLEAR IP_DETAIL1.
MOVE IP_DETAIL[] TO IP_DETAIL1[].
LOOP AT IP_DETAIL WHERE QUANTITY < 1.
ITM-MATERIAL = IP_DETAIL-MATERIAL.
COLLECT ITM.
IP_DETAIL-QUANTITY = 1.
MODIFY IP_DETAIL.
ENDLOOP.
ENDIF.
CALL FUNCTION 'ZRFC_WMS_PO_CREATE'
EXPORTING
IP_POHEADER1 = IP_POHEADER1
IP_HISTORY = IP_HISTORY
IMPORTING
EP_SUBRC = EP_SUBRC0
EP_EBELN = EP_EBELN
EP_FRGKX = EP_FRGKX
TABLES
IT_ZMM0004 = IP_DETAIL
ET_ZMM0012 = ET_ZMM0012
ET_LOG = ET_LOG_1.
APPEND LINES OF ET_LOG_1 TO ET_LOG.
LOOP AT ET_LOG_1.
IF ET_LOG_1-TYPE = 'E'.
CONCATENATE IT_RETURN-MSG ET_LOG_1-MESSAGE INTO IT_RETURN-MSG.
ENDIF.
ENDLOOP.
IF EP_EBELN IS NOT INITIAL AND IP_POHEADER1-PURCH_ORG IN R_PURCH_ORG."处理电商灯带小数位问题
DATA: V_PURCHASEORDER LIKE BAPIMEPOHEADER-PO_NUMBER.
MOVE EP_EBELN TO V_PURCHASEORDER.
DATA:L_FLAG(1),G_TEXT TYPE STRING.
DATA: LT_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA: T_POITEM LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE.
DATA: T_POITEMX LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE.
DATA: T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF ITP OCCURS 0 ,
PO_ITEM LIKE T_POITEM-PO_ITEM,
QUANTITY LIKE T_POITEM-QUANTITY,
FLAG(1),
END OF ITP.
LOOP AT IP_DETAIL1. "仅处理灯带
MOVE IP_DETAIL1-MATERIAL TO ITM-MATERIAL.
PERFORM F_ADD_ZERO USING IP_DETAIL1-MATERIAL.
SELECT SINGLE MATNR INTO IP_DETAIL1-MATERIAL FROM ZMM022 WHERE MATNR = IP_DETAIL1-MATERIAL.
IF SY-SUBRC = 0.
COLLECT ITM.
ENDIF.
ENDLOOP.
DATA: LN TYPE I.
LOOP AT ITM.
PERFORM F_ADD_ZERO USING ITM-MATERIAL.
SELECT EBELP AS PO_ITEM
MENGE AS QUANTITY
INTO CORRESPONDING FIELDS OF TABLE ITP
FROM EKPO
WHERE EBELN = V_PURCHASEORDER AND MATNR = ITM-MATERIAL .
* AND EXISTS ( SELECT MATNR FROM ZMM022 WHERE MATNR = ITM-MATERIAL ).
CHECK SY-SUBRC = 0.
LN = 0.
PERFORM F_CUT_ZERO USING ITM-MATERIAL.
LOOP AT IP_DETAIL1 WHERE MATERIAL = ITM-MATERIAL .
LN = LN + 1.
READ TABLE ITP INDEX LN.
MOVE ITP-QUANTITY TO T_POITEM-QUANTITY.
MOVE ITP-PO_ITEM TO T_POITEM-PO_ITEM .
IF SY-SUBRC = 0 AND T_POITEM-QUANTITY <> IP_DETAIL1-QUANTITY.
MOVE T_POITEM-PO_ITEM TO T_POITEMX-PO_ITEM.
T_POITEM-QUANTITY = IP_DETAIL1-QUANTITY.
T_POITEMX-QUANTITY = 'X'.
T_POITEMX-PO_ITEMX = 'X'.
APPEND T_POITEM.
APPEND T_POITEMX.
ENDIF.
ENDLOOP.
ENDLOOP.
* LOOP AT IP_DETAIL1.
*
* PERFORM F_ADD_ZERO USING IP_DETAIL1-MATERIAL.
* SELECT SINGLE EBELP MENGE INTO (T_POITEM-PO_ITEM,T_POITEM-QUANTITY)
* FROM EKPO
* WHERE EBELN = V_PURCHASEORDER AND MATNR = IP_DETAIL1-MATERIAL
* AND EXISTS ( SELECT MATNR FROM ZMM022 WHERE MATNR = IP_DETAIL1-MATERIAL ).
*
* IF SY-SUBRC = 0 AND T_POITEM-QUANTITY <> IP_DETAIL1-QUANTITY.
* MOVE T_POITEM-PO_ITEM TO T_POITEMX-PO_ITEM.
* T_POITEM-QUANTITY = IP_DETAIL1-QUANTITY.
* T_POITEMX-QUANTITY = 'X'.
* T_POITEMX-PO_ITEMX = 'X'.
* APPEND T_POITEM.
* APPEND T_POITEMX.
* ENDIF.
* ENDLOOP.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
PURCHASEORDER = V_PURCHASEORDER
TABLES
RETURN = LT_RETURN
POITEM = T_POITEM
POITEMX = T_POITEMX.
APPEND LINES OF LT_RETURN TO ET_LOG.
CLEAR L_FLAG.
LOOP AT LT_RETURN.
IF LT_RETURN-TYPE = 'E' OR LT_RETURN-TYPE = 'A'
OR ( LT_RETURN-TYPE = 'I' AND LT_RETURN-ID = 'VD' ).
G_TEXT = LT_RETURN-MESSAGE.
WRITE / G_TEXT .
L_FLAG = 'X'.
ENDIF.
ENDLOOP.
IF L_FLAG = 'X'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
IF L_FLAG = SPACE .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
CONCATENATE EP_EBELN '灯带数量修改 - OK' INTO G_TEXT.
WRITE /: G_TEXT .
ENDIF.
ENDIF.
* ELSE.
* EP_SUBRC0 = 1.
* IT_RETURN-MSG = '库存不足'.
* ENDIF.
CLEAR ET_LOG_1[].
IT_REC-EBELN = EP_EBELN.
IT_RETURN-BILLNO = IT_HEADER-BILLNO.
IT_RETURN-SAPNO = EP_EBELN.
IT_RETURN-SUBRC = EP_SUBRC0.
IF EP_SUBRC0 = 0.
* 8100-8100-8167 -> 6000公司 6700工厂 6700库 1003(采购组织) 采购组 201 只产生采购订单NB
IF IT_DETAIL-LGPBE2 = '8167' OR IP_POHEADER1-PURCH_ORG IN R_PURCH_ORG.
IT_REC-ISOK = 'X'.
ENDIF.
APPEND IT_REC.
MODIFY ZWMS_CONVERT FROM IT_REC .
COMMIT WORK.
ENDIF.
APPEND IT_RETURN.
CLEAR IT_RETURN.
ENDLOOP.
* INSERT ZWMS_CONVERT FROM TABLE IT_REC .
ENDFUNCTION.