無名经验总结与分享(SAP)            十年树木,百年树人

WMS函数组:19.WMS创建PO

FUNCTION ZRFC_WMS_PO_CREATE .
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     REFERENCE(IP_POHEADER1) LIKE  ZMM0005X STRUCTURE  ZMM0005X
*"     REFERENCE(IP_HISTORY) LIKE  ZRFC_HISTORY STRUCTURE  ZRFC_HISTORY
*"     VALUE(IN_FRGKX) TYPE  FRGKX OPTIONAL
*"  EXPORTING
*"     REFERENCE(EP_SUBRC) LIKE  SY-SUBRC
*"     REFERENCE(EP_EBELN) LIKE  EKKO-EBELN
*"     REFERENCE(EP_FRGKX) TYPE  FRGKX
*"  TABLES
*"      IT_ZMM0004 STRUCTURE  ZWMS_ORDER_DETAIL
*"      ET_ZMM0012 STRUCTURE  ZMM0012
*"      ET_LOG STRUCTURE  BAPIRET2
*"----------------------------------------------------------------------
*{   INSERT         DEVK911580                                        1
INCLUDE ZRFC_CNT.
TABLES: LFA1,T001W,T030,MBEW,EKKO,EKKN.
DATA :   IT_POITEM       LIKE  BAPIMEPOITEM         OCCURS    0   WITH HEADER  LINE,
           IT_POITEMX      LIKE  BAPIMEPOITEMX        OCCURS    0   WITH HEADER  LINE,
           IT_POSCHEDULE   LIKE  BAPIMEPOSCHEDULE     OCCURS    0   WITH HEADER  LINE,
           IT_POSCHEDULEX  LIKE  BAPIMEPOSCHEDULX     OCCURS    0   WITH HEADER  LINE,
           IT_POACCOUNT    LIKE  BAPIMEPOACCOUNT      OCCURS    0   WITH HEADER  LINE,
           IT_POACCOUNTX   LIKE  BAPIMEPOACCOUNTX     OCCURS    0   WITH HEADER  LINE,
           IT_POCOND       LIKE  BAPIMEPOCOND         OCCURS    0   WITH HEADER  LINE,
           IT_POCONDX      LIKE  BAPIMEPOCONDX        OCCURS    0   WITH HEADER  LINE,
           IT_POTEXTHEADER LIKE  BAPIMEPOTEXTHEADER   OCCURS    0   WITH HEADER  LINE,
           IT_POTEXTITEM   LIKE  BAPIMEPOTEXT         OCCURS    0   WITH HEADER  LINE,
           IP_POHEADER     LIKE  BAPIMEPOHEADER,
           IP_POHEADERX     LIKE  BAPIMEPOHEADERX,
           IP_POADDRVENDOR LIKE  BAPIMEPOADDRVENDOR,
           FLAG,
           BWKEY           LIKE  T001W-BWKEY,
           BKLAS           LIKE  MBEW-BKLAS,
           NAME1           LIKE  LFA1-NAME1,
           I_LOG           LIKE  BAPIRETURN1          OCCURS 0 WITH HEADER LINE,
           IT_INPUT        LIKE  ZPORELEASE           OCCURS 0 WITH HEADER LINE
.
CLEAR :  IT_POITEM,
           IT_POITEMX,
           IT_POSCHEDULE,
           IT_POSCHEDULEX,
           IT_POACCOUNT,
           IT_POACCOUNTX,
           IT_POCOND,
           IT_POCONDX,
           IT_POTEXTHEADER,
           IT_POTEXTITEM,
           IP_POHEADER,
           IP_POHEADERX,
           IP_POADDRVENDOR,
           FLAG,
           NAME1,
           EP_EBELN,
           EP_SUBRC,
           I_LOG,
           EP_FRGKX,
           IT_INPUT,
           ET_ZMM0012
.
REFRESH: IT_POITEM,
           IT_POITEMX,
           IT_POSCHEDULE,
           IT_POSCHEDULEX,
           IT_POACCOUNT,
           IT_POACCOUNTX,
           IT_POCOND,
           IT_POCONDX,
           IT_POTEXTHEADER,
           IT_POTEXTITEM,
           I_LOG,
           IT_INPUT,
           ET_ZMM0012
.
*&修改记录
IF IP_HISTORY-OANO IS INITIAL.
    EP_SUBRC = -1.
    ET_LOG-MESSAGE = '请输入OA流水号!'.
    ET_LOG-TYPE    = 'E'.
APPEND ET_LOG.
CLEAR  ET_LOG.
ENDIF.
IF IP_HISTORY-OANAME IS INITIAL.
    EP_SUBRC       = -1.
    ET_LOG-MESSAGE = '请输入操作姓名!'.
    ET_LOG-TYPE    = 'E'.
APPEND ET_LOG.
CLEAR  ET_LOG.
ENDIF.
CHECK EP_SUBRC = 0.
IF IP_HISTORY-OAMODULE IS INITIAL.
    EP_SUBRC       = -1.
    ET_LOG-MESSAGE = '请输入OA模块!'.
    ET_LOG-TYPE    = 'E'.
APPEND ET_LOG.
CLEAR  ET_LOG.
ENDIF.
IF   EP_SUBRC = -1.
EXIT.
ENDIF.
**********  header         公司代码
  IP_POHEADER-COMP_CODE   =  IP_POHEADER1-COMP_CODE.
  IP_POHEADERX-COMP_CODE  =  'X'.
**********  采购凭证类型
  IP_POHEADER-DOC_TYPE    =  IP_POHEADER1-DOC_TYPE.
  IP_POHEADERX-DOC_TYPE   =  'X'.
**********  供应商帐户号
*  PERFORM f_add_zero USING   ip_poheader1-vendor .
  IP_POHEADER-VENDOR      =  IP_POHEADER1-VENDOR.
  IP_POHEADERX-VENDOR     =  'X'.
********  1次性供应商
SELECT  SINGLE  *  FROM  LFA1  WHERE  LIFNR  =   IP_POHEADER-VENDOR.
IF  SY-SUBRC   =   0  .
    NAME1    =  LFA1-NAME1.
FIND   '一次性供应商'   IN   NAME1.
IF  SY-SUBRC   =   0 .
      FLAG    =   'X'.
      IP_POADDRVENDOR-NAME       = IP_POHEADER1-NAME1.
      IP_POADDRVENDOR-STREET_LNG = IP_POHEADER1-STREET_LNG.
      IP_POADDRVENDOR-HOUSE_NO   = IP_POHEADER1-HOUSE_NO.
      IP_POADDRVENDOR-POSTL_COD1 = IP_POHEADER1-POSTL_COD1.
      IP_POADDRVENDOR-CITY       = IP_POHEADER1-CITY .
      IP_POADDRVENDOR-COUNTRY    = IP_POHEADER1-COUNTRY .
      IP_POADDRVENDOR-TEL1_NUMBR = IP_POHEADER1-TEL1_NUMBR.
      IP_POADDRVENDOR-TEL1_EXT   = IP_POHEADER1-TEL1_EXT.
ENDIF.
ENDIF.
********** 采购组织
  IP_POHEADER-PURCH_ORG   =  IP_POHEADER1-PURCH_ORG.
  IP_POHEADERX-PURCH_ORG  =  'X'.
********** 采购组
  IP_POHEADER-PUR_GROUP   =  IP_POHEADER1-PUR_GROUP.
  IP_POHEADERX-PUR_GROUP  =  'X'.
**********收付条件代码
IF   NOT   IP_POHEADER1-PMNTTRMS  IS INITIAL.
    IP_POHEADER-PMNTTRMS    =  IP_POHEADER1-PMNTTRMS.
    IP_POHEADERX-PMNTTRMS   =  'X'.
ENDIF.
**********供应商电话号码
IF  NOT   IP_POHEADER1-TELEPHONE  IS  INITIAL.
    IP_POHEADER-TELEPHONE   =  IP_POHEADER1-TELEPHONE.
    IP_POHEADERX-TELEPHONE  =  'X'.
ENDIF.
**********我方参考
IF  NOT   IP_POHEADER1-UNSEZ  IS  INITIAL.
    IP_POHEADER-OUR_REF   =  IP_POHEADER1-UNSEZ.
    IP_POHEADERX-OUR_REF  =  'X'.
ENDIF.
**********供应商办公室的责任销售员
IF  NOT   IP_POHEADER1-SALES_PERS  IS  INITIAL.
    IP_POHEADER-SALES_PERS   =  IP_POHEADER1-SALES_PERS.
    IP_POHEADERX-SALES_PERS  =  'X'.
ENDIF.
***********货币代码
IF  NOT   IP_POHEADER1-CURRENCY  IS  INITIAL.
    IP_POHEADER-CURRENCY   =  IP_POHEADER1-CURRENCY.
    IP_POHEADERX-CURRENCY  =  'X'.
ENDIF.
***********表头文本
IF  NOT  IP_POHEADER1-HEADR_TEXT   IS   INITIAL.
    IT_POTEXTHEADER-TEXT_ID       =   'F01'.
    IT_POTEXTHEADER-TEXT_LINE     =   IP_POHEADER1-HEADR_TEXT.
APPEND  IT_POTEXTHEADER.
ENDIF.
**-------------CHA JWY 20170811
*  SORT IT_ZMM0004.
**-------------CHA JWY 20170811
LOOP  AT  IT_ZMM0004.
********订单原因
IF  NOT    IT_ZMM0004-ORDER_REASON  IS INITIAL  .
      IT_POITEM-ORDER_REASON   =     IT_ZMM0004-ORDER_REASON.
      IT_POITEMX-ORDER_REASON =     'X'.
ENDIF.
********  免费项目
IF  NOT    IT_ZMM0004-FREE_ITEM  IS INITIAL  .
      IT_POITEM-FREE_ITEM   =     IT_ZMM0004-FREE_ITEM.
      IT_POITEMX-FREE_ITEM =     'X'.
ENDIF.
********  返回项目
IF  NOT    IT_ZMM0004-RET_ITEM  IS INITIAL  .
      IT_POITEM-RET_ITEM   =     IT_ZMM0004-RET_ITEM.
*    IT_POITEMX-RET_ITEM =    IT_ZMM0004-RET_ITEM.
      IT_POITEMX-RET_ITEM =     'X'.
ENDIF.
******* ITEM  DATA   采购凭证的项目编号
PERFORM F_ADD_ZERO USING  IT_ZMM0004-PO_ITEM.
    IT_POITEM-PO_ITEM   =     IT_ZMM0004-PO_ITEM.
    IT_POITEMX-PO_ITEM  =     IT_ZMM0004-PO_ITEM.
    IT_POITEMX-PO_ITEMX =     'X'.
*******    物料号
IF  NOT   IT_ZMM0004-MATERIAL  IS INITIAL.
PERFORM F_ADD_ZERO USING  IT_ZMM0004-MATERIAL.
      IT_POITEM-MATERIAL   =    IT_ZMM0004-MATERIAL.
      IT_POITEMX-MATERIAL  =    'X'.
ENDIF.
*******短文本
IF  NOT   IT_ZMM0004-SHORT_TEXT  IS INITIAL  .
      IT_POITEM-SHORT_TEXT  =    IT_ZMM0004-SHORT_TEXT.
      IT_POITEMX-SHORT_TEXT =    'X'.
ELSE.
CLEAR  :   IT_ZMM0004-SHORT_TEXT.
      IT_POITEM-SHORT_TEXT  =    IT_ZMM0004-SHORT_TEXT.
      IT_POITEMX-SHORT_TEXT =    ''.
ENDIF.
*******工厂
    IT_POITEM-PLANT         =  IT_ZMM0004-PLANT.
    IT_POITEMX-PLANT        =  'X'.
IF IT_ZMM0004-BATCH IS NOT INITIAL.
*   *******批次
      IT_POITEM-BATCH         =  IT_ZMM0004-BATCH.
      IT_POITEMX-BATCH        =  'X'.
ENDIF.
*******库存地点
IF  NOT   IT_ZMM0004-STGE_LOC  IS INITIAL.
      IT_POITEM-STGE_LOC     =    IT_ZMM0004-STGE_LOC.
      IT_POITEMX-STGE_LOC    =    'X'.
ENDIF.
*******物料组
IF  NOT   IT_ZMM0004-MATL_GROUP  IS INITIAL.
      IT_POITEM-MATL_GROUP    =    IT_ZMM0004-MATL_GROUP.
      IT_POITEMX-MATL_GROUP   =    'X'.
ENDIF.
*******采购订单数量
    IT_POITEM-QUANTITY      =    IT_ZMM0004-QUANTITY.
    IT_POITEMX-QUANTITY     =    'X'.
*******订单单位
PERFORM     F_UNIT_IN   USING   IT_ZMM0004-PO_UNIT  CHANGING    IT_POITEM-PO_UNIT.
*    it_poitem-po_unit       =    it_zmm0004-po_unit.
    IT_POITEMX-PO_UNIT      =    'X'.
*******采购凭证中的项目类别
IF  NOT   IT_ZMM0004-ITEM_CAT  IS INITIAL.
      IT_POITEM-ITEM_CAT    =    IT_ZMM0004-ITEM_CAT.
      IT_POITEMX-ITEM_CAT   =    'X'.
ENDIF.
*******科目设置类型
IF  NOT   IT_ZMM0004-ACCTASSCAT  IS INITIAL.
      IT_POITEM-ACCTASSCAT    =    IT_ZMM0004-ACCTASSCAT.
      IT_POITEMX-ACCTASSCAT   =    'X'.
ENDIF.
*******销售/购买税代码
IF  NOT   IT_ZMM0004-TAX_CODE  IS INITIAL.
      IT_POITEM-TAX_CODE     =    IT_ZMM0004-TAX_CODE.
      IT_POITEMX-TAX_CODE    =    'X'.
ENDIF.
*******BAPIs 的货币金额(带有 9 个小数位)
    IT_POITEM-NET_PRICE      =  IT_ZMM0004-COND_VALUE.
    IT_POITEMX-NET_PRICE     =  'X'.
    IT_POITEM-PRICE_UNIT      =  IT_ZMM0004-COND_P_UNT.
    IT_POITEMX-PRICE_UNIT     =  'X'.
*******  CHEDULE DATA      交货日期
IF  NOT   IT_ZMM0004-DELIVERY_DATE  IS INITIAL.
      IT_POSCHEDULE-DELIVERY_DATE  =  IT_ZMM0004-DELIVERY_DATE.
      IT_POSCHEDULEX-DELIVERY_DATE =  'X'.
IF IP_POHEADER-DOC_TYPE = 'UB'.
        IP_POHEADER-DOC_DATE = IT_ZMM0004-DELIVERY_DATE.
        IP_POHEADERX-DOC_DATE = 'X'.
ENDIF.
ENDIF.
*******  采购凭证的项目编号
    IT_POSCHEDULE-PO_ITEM        =  IT_ZMM0004-PO_ITEM.
    IT_POSCHEDULEX-PO_ITEM       =  IT_ZMM0004-PO_ITEM.
    IT_POSCHEDULEX-PO_ITEMX      =  'X'.
*******计划行
    IT_POSCHEDULE-SCHED_LINE     = '0001'.
    IT_POSCHEDULEX-SCHED_LINE    = '0001'.
    IT_POSCHEDULEX-SCHED_LINEX   = 'X'.
*******计划数量
    IT_POSCHEDULE-QUANTITY     = IT_ZMM0004-QUANTITY.
    IT_POSCHEDULEX-QUANTITY    = 'X'.
APPEND   IT_POSCHEDULE.
CLEAR :  IT_POSCHEDULE.
APPEND   IT_POSCHEDULEX.
CLEAR :  IT_POSCHEDULEX.
********** 总帐科目编号
*    CLEAR   :  BWKEY,  BKLAS.
*    IF  IT_ZMM0004-GL_ACCOUNT  IS INITIAL AND  NOT IT_ZMM0004-MATERIAL  IS INITIAL  AND  IT_ZMM0004-ACCTASSCAT =  'K'.
*      SELECT SINGLE *  FROM  T001W  WHERE  WERKS  = IT_ZMM0004-PLANT.
*      IF  SY-SUBRC  =  0 .
*        BWKEY    =  T001W-BWKEY.
*      ENDIF.
*      SELECT SINGLE  * FROM MBEW  WHERE MATNR = IT_ZMM0004-MATERIAL AND BWKEY  =  BWKEY.
*      IF  SY-SUBRC   =  0  .
*        BKLAS     =  MBEW-BKLAS.
*      ENDIF.
*      SELECT SINGLE * FROM T030  WHERE KTOPL = 'Z001' AND KTOSL = 'GBB' AND KOMOK = 'VBR' AND BKLAS   = BKLAS.
*      IF  SY-SUBRC  =  0  .
*        IT_ZMM0004-GL_ACCOUNT     =  T030-KONTS.
*      ENDIF.
*    ENDIF.
*******  采购订单的帐户分配字段
*    IF  NOT  IT_ZMM0004-GL_ACCOUNT  IS INITIAL.
IF IT_ZMM0004-ACCTASSCAT IS NOT INITIAL.
      IT_POACCOUNT-PO_ITEM        =  IT_ZMM0004-PO_ITEM.
      IT_POACCOUNTX-PO_ITEM       =  IT_ZMM0004-PO_ITEM.
      IT_POACCOUNTX-PO_ITEMX      =  'X'.
********** 帐户分配的序列号
      IT_POACCOUNT-SERIAL_NO      =  '01'.
      IT_POACCOUNTX-SERIAL_NO     =  '01'.
      IT_POACCOUNTX-SERIAL_NOX    =  'X'.
IF IT_ZMM0004-GL_ACCOUNT IS NOT INITIAL.
PERFORM F_ADD_ZERO USING  IT_ZMM0004-GL_ACCOUNT.
        IT_POACCOUNT-GL_ACCOUNT     =  IT_ZMM0004-GL_ACCOUNT.
        IT_POACCOUNTX-GL_ACCOUNT    =  IT_ZMM0004-GL_ACCOUNT.
ENDIF.
********** 成本中心
IF IT_ZMM0004-COSTCENTER  IS  NOT INITIAL.
PERFORM F_ADD_ZERO USING  IT_ZMM0004-COSTCENTER.
        IT_POACCOUNT-COSTCENTER     =  IT_ZMM0004-COSTCENTER.
        IT_POACCOUNTX-COSTCENTER    =  IT_ZMM0004-COSTCENTER.
ENDIF.
**********主资产号
IF  NOT   IT_ZMM0004-ASSET_NO  IS INITIAL.
PERFORM F_ADD_ZERO USING  IT_ZMM0004-ASSET_NO  .
        IT_POACCOUNT-ASSET_NO    =  IT_ZMM0004-ASSET_NO.
        IT_POACCOUNTX-ASSET_NO   =  'X'.
ENDIF.
**********     次级编号
IF  NOT   IT_ZMM0004-SUB_NUMBER  IS INITIAL.
PERFORM F_ADD_ZERO USING    IT_ZMM0004-SUB_NUMBER.
        IT_POACCOUNT-SUB_NUMBER  =  IT_ZMM0004-SUB_NUMBER.
        IT_POACCOUNTX-SUB_NUMBER =  'X'.
ENDIF.
************  订单号
IF  NOT  IT_ZMM0004-ORDERID  IS INITIAL.
PERFORM F_ADD_ZERO USING    IT_ZMM0004-ORDERID.
        IT_POACCOUNT-ORDERID  =  IT_ZMM0004-ORDERID.
        IT_POACCOUNTX-ORDERID =  'X'.
ENDIF.
***      **************WBS
IF   IT_ZMM0004-WBS_ELEMENT IS NOT INITIAL.
        IT_POACCOUNT-WBS_ELEMENT  =  IT_ZMM0004-WBS_ELEMENT.
        IT_POACCOUNTX-WBS_ELEMENT =  'X'.
ENDIF.
***      **************销售订单
IF   IT_ZMM0004-SD_DOC IS NOT INITIAL.
        IT_POACCOUNT-SD_DOC  =  IT_ZMM0004-SD_DOC.
        IT_POACCOUNTX-SD_DOC =  'X'.
        IT_POACCOUNT-ITM_NUMBER  =  IT_ZMM0004-ITM_NUMBER.
        IT_POACCOUNTX-ITM_NUMBER =  'X'.
ENDIF.
APPEND  IT_POACCOUNT.
APPEND  IT_POACCOUNTX.
CLEAR : IT_POACCOUNT, IT_POACCOUNTX.
ENDIF.
******采购订单中的条件       采购凭证的项目编号
IF   NOT  IT_ZMM0004-COND_TYPE IS  INITIAL.
      IT_POCOND-ITM_NUMBER        =  IT_ZMM0004-PO_ITEM.
      IT_POCONDX-ITM_NUMBER       =  IT_ZMM0004-PO_ITEM.
      IT_POCONDX-ITM_NUMBERX      =  'X'.
IF  IT_POCOND-COND_TYPE  = 'PBXX'.
        IT_POCOND-COND_ST_NO     = '001'.
        IT_POCOND-COND_COUNT     = '01'.
        IT_POCONDX-COND_ST_NO    = '001'.
        IT_POCONDX-COND_ST_NOX   = 'X'.
        IT_POCONDX-COND_COUNT    = '01'.
        IT_POCONDX-CONDITION_NOX = 'X'.
ENDIF.
********** 条件类型
      IT_POCOND-COND_TYPE        =  IT_ZMM0004-COND_TYPE.
      IT_POCONDX-COND_TYPE       =  'X'.
**********  条件单位
PERFORM F_UNIT_IN   USING   IT_ZMM0004-COND_UNIT  CHANGING   IT_POCOND-COND_UNIT.
      IT_POCONDX-COND_UNIT       =  'X'.
********** 条件定价单位
      IT_POCOND-COND_P_UNT       =  IT_ZMM0004-COND_P_UNT.
      IT_POCONDX-COND_P_UNT      =  'X'.
**********定价比率
      IT_POCOND-COND_VALUE    =   IT_ZMM0004-COND_VALUE.
      IT_POCONDX-COND_VALUE   =   'X'.
      IT_POCOND-CHANGE_ID    = 'I'.
      IT_POCONDX-CHANGE_ID   = 'X'.
      IT_POCOND-CURRENCY     = 'CNY'.
      IT_POCONDX-CURRENCY    = 'X'.
      IT_POITEM-CALCTYPE      = 'G'.
      IT_POITEMX-CALCTYPE     = 'X'.
APPEND  IT_POCOND.
APPEND  IT_POCONDX.
CLEAR : IT_POCOND,  IT_POCONDX.
ENDIF.
*******  项目文本
IF   NOT  IT_ZMM0004-ITEM_TEXT IS  INITIAL.
      IT_POTEXTITEM-PO_ITEM   = IT_ZMM0004-PO_ITEM.
      IT_POTEXTITEM-TEXT_ID   = 'F01' .
      IT_POTEXTITEM-TEXT_LINE = IT_ZMM0004-ITEM_TEXT.
APPEND  IT_POTEXTITEM.
CLEAR : IT_POTEXTITEM.
ENDIF.
IF  IT_POITEM-VEND_MAT IS INITIAL.
      IT_POITEM-VEND_MAT = IT_ZMM0004-ITEM_TEXT.
      IT_POITEMX-VEND_MAT = 'X'.
ENDIF.
IF  IT_POITEM-TRACKINGNO IS INITIAL.
      IT_POITEM-TRACKINGNO = IT_ZMM0004-TRACKINGNO.
      IT_POITEMX-TRACKINGNO = 'X'.
ENDIF.
IF  IT_POITEM-PREQ_NO IS INITIAL.
      IT_POITEM-PREQ_NO = IT_ZMM0004-PREQ_NO.
      IT_POITEMX-PREQ_NO = 'X'.
      IT_POITEM-PREQ_ITEM = IT_ZMM0004-PREQ_ITEM.
      IT_POITEMX-PREQ_ITEM = 'X'.
ENDIF.
IF  IT_POITEM-SUPPL_STLOC IS INITIAL.
      IT_POITEM-SUPPL_STLOC = IT_ZMM0004-SUPPL_STLOC.
      IT_POITEMX-SUPPL_STLOC = 'X'.
DATA: V_VENDOR LIKE ZMM0005X-VENDOR.
MOVE IP_POHEADER1-VENDOR TO V_VENDOR.
PERFORM F_CUT_ZERO USING V_VENDOR.
MOVE V_VENDOR TO IP_POHEADER-SUPPL_PLNT.
*    IP_POHEADER-SUPPL_PLNT = '6000'.
      IP_POHEADERX-SUPPL_PLNT = 'X'.
ENDIF.
APPEND   IT_POITEM.
APPEND   IT_POITEMX.
CLEAR :  IT_POITEM,  IT_POITEMX.
ENDLOOP.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
        POHEADER         = IP_POHEADER
        POHEADERX        = IP_POHEADERX
*       POADDRVENDOR     =
*       TESTRUN          =
*       MEMORY_UNCOMPLETE            =
*       MEMORY_COMPLETE  =
*       POEXPIMPHEADER   =
*       POEXPIMPHEADERX  =
*       VERSIONS         =
*       NO_MESSAGING     =
*       NO_MESSAGE_REQ   =
*       NO_AUTHORITY     =
        NO_PRICE_FROM_PO = 'X'
IMPORTING
        EXPPURCHASEORDER = EP_EBELN
*       EXPHEADER        =
*       EXPPOEXPIMPHEADER            =
TABLES
RETURN           = ET_LOG
        POITEM           = IT_POITEM
        POITEMX          = IT_POITEMX
*       POADDRDELIVERY   =
        POSCHEDULE       = IT_POSCHEDULE
        POSCHEDULEX      = IT_POSCHEDULEX
        POACCOUNT        = IT_POACCOUNT
*       POACCOUNTPROFITSEGMENT       =
        POACCOUNTX       = IT_POACCOUNTX
*       POCONDHEADER     =
*       POCONDHEADERX    =
        POCOND           = IT_POCOND
        POCONDX          = IT_POCONDX
*       POLIMITS         =
*       POCONTRACTLIMITS =
*       POSERVICES       =
*       POSRVACCESSVALUES            =
*       POSERVICESTEXT   =
*       EXTENSIONIN      =
*       EXTENSIONOUT     =
*       POEXPIMPITEM     =
*       POEXPIMPITEMX    =
        POTEXTHEADER     = IT_POTEXTHEADER
        POTEXTITEM       = IT_POTEXTITEM
*       ALLVERSIONS      =
*       POPARTNER        =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
IF  EP_EBELN  IS  INITIAL.
    EP_SUBRC     =  -1.
EXIT.
ELSE.
WAIT UP  TO  3 SECONDS.
SELECT SINGLE *  FROM  EKKO  WHERE  EBELN = EP_EBELN.
IF  SY-SUBRC  =  0 .
      EP_FRGKX   =  EKKO-FRGKE.
IF   NOT  EP_FRGKX IS INITIAL.
        EP_FRGKX   =  'X'.
ENDIF.
ENDIF.
SELECT EBELN
           EBELP
           MATNR
           MENGE
           MEINS
INTO  CORRESPONDING FIELDS OF TABLE  ET_ZMM0012
FROM  EKPO
WHERE EBELN   =   EP_EBELN.
**-------------CHA JWY 20170811
*    SORT ET_ZMM0012.
**-------------CHA JWY 20170811
LOOP  AT  ET_ZMM0012.
SELECT  SINGLE  *  FROM  EKKN  WHERE  EBELN  = ET_ZMM0012-EBELN  AND EBELP = ET_ZMM0012-EBELP AND  ZEKKN = '01'.
IF  SY-SUBRC    =   0  .
        ET_ZMM0012-SAKTO     =  EKKN-SAKTO.
ENDIF.
*      PERFORM f_cut_zero  USING   et_zmm0012-matnr.
*      PERFORM f_cut_zero  USING   et_zmm0012-ebeln.
*      PERFORM f_cut_zero  USING   et_zmm0012-ebelp.
*      PERFORM f_cut_zero  USING   et_zmm0012-sakto.
MODIFY  ET_ZMM0012.
ENDLOOP.
ENDIF.
*&修改记录
*  ip_history-rfc    = 'ZRFC_MM_ME21N_V1'.
*  ip_history-mblnr  = ep_ebeln.
CALL FUNCTION 'ZRFC_CREATE_HISTORY'
EXPORTING
      IP_HEAD  = IP_HISTORY
IMPORTING
      EP_SUBRC = EP_SUBRC
TABLES
      ET_LOG   = I_LOG.
**-------------CHA JWY 20170811
*  SORT I_LOG.
**-------------CHA JWY 20170811
LOOP AT I_LOG.
MOVE:
    IP_HISTORY-SAPNO TO ET_LOG-MESSAGE_V1,
    I_LOG-TYPE  TO  ET_LOG-TYPE ,
    I_LOG-ID  TO  ET_LOG-ID ,
    I_LOG-NUMBER  TO  ET_LOG-NUMBER ,
    I_LOG-MESSAGE TO  ET_LOG-MESSAGE  .
APPEND ET_LOG.CLEAR ET_LOG.
ENDLOOP.
IF   EP_FRGKX   =  'X' AND IN_FRGKX IS INITIAL.
CLEAR   :   I_LOG.
REFRESH :   I_LOG.
    IT_INPUT-EBELN   =  EP_EBELN.
APPEND  IT_INPUT.
*    ip_history-rfc    = 'ZRFC_MM_ME21N_V1'.
CALL FUNCTION 'ZRFC_WMS_PO_RELEASE'
EXPORTING
        IP_HISTORY = IP_HISTORY
* IMPORTING
*       EP_SUBRC   =
*       EP_MSG     =
TABLES
        IT_INPUT   = IT_INPUT
        ET_LOG     = I_LOG.
**-------------CHA JWY 20170811
*    SORT I_LOG.
**-------------CHA JWY 20170811
LOOP AT I_LOG.
MOVE:
      IP_HISTORY-SAPNO TO ET_LOG-MESSAGE_V1,
      I_LOG-TYPE  TO  ET_LOG-TYPE ,
      I_LOG-ID  TO  ET_LOG-ID ,
      I_LOG-NUMBER  TO  ET_LOG-NUMBER ,
      I_LOG-MESSAGE TO  ET_LOG-MESSAGE  .
APPEND ET_LOG.CLEAR ET_LOG.
ENDLOOP.
ENDIF.
*}   INSERT
ENDFUNCTION.


image

image

image

posted @ 2021-01-25 21:27  無名  阅读(233)  评论(0编辑  收藏  举报
Twttafku@163.com
十年树木,百年树人