交货单过账

CTS

FUNCTION Z_SD_DN_PGI1.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_VBELN) TYPE  VBELN
*"     REFERENCE(I_BUDAT) TYPE  BUDAT DEFAULT SY-DATUM
*"  EXPORTING
*"     REFERENCE(E_MBLNR) TYPE  MBLNR
*"  TABLES
*"      T_DATA STRUCTURE  ZSDS0015
*"      IT_RETURN STRUCTURE  BAPIRET2 OPTIONAL
*"----------------------------------------------------------------------
  DATA : LS_DATA LIKE LINE OF  T_DATA,
         LT_DATA LIKE TABLE OF ZSDS0015.

  DATA: LV_VBELN LIKE LIKP-VBELN,
        LW_VBKOK LIKE VBKOK,
        IT_PROTT LIKE PROTT OCCURS 0 WITH HEADER LINE,  "Return Message
        IT_VBPOK LIKE VBPOK OCCURS 0 WITH HEADER LINE.  "Delivery items

  DATA : LV_PGI,
         LV_VBTYP_N TYPE VBFA-VBTYP_N,
         LV_COUNT   TYPE I.

  REFRESH IT_RETURN.

* 检查交货单是否已经过账
  SELECT  VBELN VBTYP_N INTO (E_MBLNR,LV_VBTYP_N)
    FROM VBFA
    WHERE VBELV = I_VBELN
      AND POSNV = 10
      AND VBTYP_N IN (‘R‘,‘h‘).  "货物移动
  ENDSELECT.

  IF SY-SUBRC EQ 0 AND LV_VBTYP_N EQ ‘R‘."交货 h 取消交货
    EXIT.
  ENDIF.

  LW_VBKOK-VBELN_VL   = I_VBELN.   "<- Delivery number
  LW_VBKOK-WABUC      = ‘X‘.       "<- Automatic PGI
  LW_VBKOK-WADAT_IST  = I_BUDAT. "<- Automatic PGI Date

  LT_DATA[] = T_DATA[].

  LOOP AT LT_DATA INTO LS_DATA.
    CLEAR IT_VBPOK.
    IT_VBPOK-VBELN_VL = I_VBELN.
    IT_VBPOK-POSNR_VL = LS_DATA-POSNR.
    IT_VBPOK-VBELN    = I_VBELN.
    IT_VBPOK-POSNN    = LS_DATA-POSNR.
    IT_VBPOK-CHARG    = LS_DATA-CHARG. "批次
    IT_VBPOK-LGORT    = LS_DATA-LGORT. "库存地点
    IT_VBPOK-KZLGO    = ‘X‘.           "库存地点可修改
    IT_VBPOK-PIKMG    = LS_DATA-PIKMG. "捡配数量
    IT_VBPOK-LFIMG    = LS_DATA-LFIMG. "交货数量
    APPEND IT_VBPOK.

  ENDLOOP.

  PERFORM FRM_LOCK_DELIVERY(ZSDS0002) USING I_VBELN.

* DO PGI
  LV_PGI = ‘X‘.
  FREE MEMORY ID ‘PGI‘.
  EXPORT LV_PGI TO MEMORY ID ‘PGI‘.

  FREE MEMORY ID ‘PGI_DATA‘.
  EXPORT LT_DATA FROM LT_DATA TO MEMORY ID ‘PGI_DATA‘.

* Perform Pick and PGI
  CALL FUNCTION ‘WS_DELIVERY_UPDATE‘
    EXPORTING
      VBKOK_WA                 = LW_VBKOK
      SYNCHRON                 = ‘X‘
      UPDATE_PICKING           = ‘X‘
      COMMIT                   = ‘ ‘
      DELIVERY                 = I_VBELN
      NICHT_SPERREN            = ‘X‘
      IF_ERROR_MESSAGES_SEND_0 = ‘X‘
    TABLES
      PROT                     = IT_PROTT
      VBPOK_TAB                = IT_VBPOK
    EXCEPTIONS
      ERROR_MESSAGE            = 1
      OTHERS                   = 2.

  IF SY-SUBRC <> 0.
    ROLLBACK WORK.
  ELSE.

    LOOP AT IT_PROTT WHERE MSGTY EQ ‘E‘ OR MSGTY EQ ‘A‘ OR MSGTY EQ ‘X‘.
      EXIT.
    ENDLOOP.

    IF SY-SUBRC NE 0.

      COMMIT WORK AND WAIT.

      SELECT COUNT(*) INTO LV_COUNT
           FROM LIPS
           WHERE VBELN = I_VBELN
             AND LFIMG NE 0.

      IF LV_COUNT NE LINES( LT_DATA ).

        PERFORM FRM_REVERSE_POSTING(ZSDS0002) TABLES IT_RETURN USING I_VBELN I_BUDAT.

        MAC_APPEND_IT_RETURN: ‘00‘ ‘000‘ ‘E‘ ‘实际交货数量与请求交货数量不一致,停止交货‘
                              ‘实际交货数量与请求交货数量不一致‘
                              ‘,停止交货‘
                              I_VBELN
                              ‘‘.
        EXIT.
      ENDIF.

      SELECT MBLNR
        INTO E_MBLNR
        FROM MKPF
        WHERE LE_VBELN = I_VBELN
          AND BUDAT = I_BUDAT.
      ENDSELECT.
    ELSE.
      ROLLBACK WORK.
    ENDIF.

  ENDIF.

  LOOP AT IT_PROTT.

    CLEAR GS_RETURN.
    MOVE : IT_PROTT-MSGTY TO GS_RETURN-TYPE,
           IT_PROTT-MSGID TO GS_RETURN-ID,
           IT_PROTT-MSGNO TO GS_RETURN-NUMBER,
           IT_PROTT-MSGV1 TO GS_RETURN-MESSAGE_V1,
           IT_PROTT-MSGV2 TO GS_RETURN-MESSAGE_V2,
           IT_PROTT-MSGV3 TO GS_RETURN-MESSAGE_V3,
           IT_PROTT-MSGV4 TO GS_RETURN-MESSAGE_V4.
    MESSAGE ID IT_PROTT-MSGID TYPE IT_PROTT-MSGTY NUMBER IT_PROTT-MSGNO
          WITH IT_PROTT-MSGV1 IT_PROTT-MSGV2 IT_PROTT-MSGV3 IT_PROTT-MSGV4
          INTO GS_RETURN-MESSAGE.

    APPEND GS_RETURN TO IT_RETURN.
  ENDLOOP.

ENDFUNCTION.
FORM frm_lock_delivery  USING    p_delivery.
  DATA : lv_time TYPE p DECIMALS 2 VALUE ‘0.50‘.

  CHECK p_delivery IS NOT INITIAL.

  DO 50 TIMES.

    CALL FUNCTION ‘ENQUEUE_EVVBLKE‘
      EXPORTING
        vbeln          = p_delivery
      EXCEPTIONS
        foreign_lock   = 1
        system_failure = 2
        OTHERS         = 3.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

    IF sy-subrc EQ 0.

      CALL FUNCTION ‘DEQUEUE_EVVBLKE‘
        EXPORTING
          mode_likp = ‘E‘
          mandt     = sy-mandt
          vbeln     = p_delivery
          x_vbeln   = ‘ ‘
          _scope    = ‘3‘
          _synchron = ‘ ‘
          _collect  = ‘ ‘.
      WAIT UP TO lv_time SECONDS.
      EXIT.
    ELSE.
      WAIT UP TO lv_time SECONDS.
    ENDIF.
  ENDDO.

ENDFORM.                    " FRM_LOCK_DELIVERY
FORM frm_reverse_posting TABLES it_return USING p_vbeln p_budat.

  DATA:   BEGIN OF lt_mesg OCCURS 0.
          INCLUDE STRUCTURE mesg.
  DATA:   END OF lt_mesg.

  DATA :  lv_vbeln TYPE likp-vbeln,
          lv_budat TYPE sy-datlo.

  lv_vbeln = p_vbeln.
  lv_budat = p_budat.

  PERFORM frm_lock_delivery(zsds0002) USING p_vbeln.

  DO 10 TIMES.
    CALL FUNCTION ‘WS_REVERSE_GOODS_ISSUE‘
      EXPORTING
        i_vbeln                   = lv_vbeln
        i_budat                   = lv_budat
        i_tcode                   = ‘VL09‘
        i_vbtyp                   = ‘J‘
      TABLES
        t_mesg                    = lt_mesg
      EXCEPTIONS
        error_reverse_goods_issue = 1
        OTHERS                    = 2.
    IF sy-subrc =  0.
*   删除交货单
      COMMIT WORK.

      PERFORM  frm_delete_delivery_note TABLES it_return USING p_vbeln.

      EXIT.
    ENDIF.

    WAIT UP TO 1 SECONDS.
  ENDDO.

ENDFORM.                    " FRM_REVERSE_POSTING
FORM frm_delete_delivery_note TABLES it_return STRUCTURE bapiret2
                               USING p_vbeln.
  DATA : lv_delivery TYPE likp-vbeln.

  CHECK p_vbeln IS NOT INITIAL.

  lv_delivery = p_vbeln.

  PERFORM frm_lock_delivery(zsds0002) USING lv_delivery.

  REFRESH bdcdata.
* Go to VL02N
* Init Screen and input DN number
  PERFORM bdc_dynpro      USING ‘SAPMV50A‘ ‘4004‘.
  PERFORM bdc_field       USING ‘BDC_CURSOR‘
                                ‘LIKP-VBELN‘.
  PERFORM bdc_field       USING ‘BDC_OKCODE‘
                                ‘/00‘.
  PERFORM bdc_field       USING ‘LIKP-VBELN‘
                                 lv_delivery.
*  Delete DN
  PERFORM bdc_dynpro      USING ‘SAPMV50A‘ ‘1000‘.
  PERFORM bdc_field       USING ‘BDC_OKCODE‘
                                ‘/ELOES_T‘.

  PERFORM bdc_transaction TABLES it_return USING ‘VL02N‘.

ENDFORM.
时间: 2024-10-24 18:46:23

交货单过账的相关文章

交货单过账后 过账日期

交货单过账后 过账日期等于 实际发货日期 ,如实际发货日期填写为5.30 但是当前日期为5.27 那么过账后的凭证显示过账日期为5.30 但是文件操作日期是当前日期 原文地址:https://www.cnblogs.com/hdchen/p/8986439.html

SAP 公司间STO场景中外向交货单过账后自动触发内向交货单功能的实现

如下STO,是从公司代码SZSP转入CSAS, 如下图示的内向交货单180018660.该内向交货单是在外向交货单80016325 发货过账的时候自动触发的, 如何实现这个功能? 1)定义输出类型(output type)SPED SPRO > Logistic Execution > Shipping > Basic Shipping Functions > Output Control > Output Determination > Maintain Output

20170228 交货单过账增强 MV50AFZ1

MV50AFZ1   这个程序里面找个FORM 用户出口, FORM USEREXIT_SAVE_DOCUMENT_PREPARE.   用户出口如下: 例:需求: 开发要求:制作交货单的人员,需要同一张单的交货仓位保持一致,设计成在保存前将所有行都改为和第一行项的仓位一致. 在发货过时会检查如发现不一致,不于过账. *---------------------------------------------------------------------* * FORM USEREXIT_SA

交货单过账报错

DATA:LT_LIPS TYPE TABLE OF LIPS. DATA:LS_LIPS TYPE LIPS. DATA:LT_VBPOK_TAB TYPE TABLE OF VBPOK. DATA:LS_VBPOK_TAB TYPE VBPOK. DATA:LT_ITEM_DATA_SPL TYPE TABLE OF /SPE/BAPIOBDLVITEMCHG. DATA:LS_ITEM_DATA_SPL TYPE /SPE/BAPIOBDLVITEMCHG. DATA:LS_HEADER_

SAP MM 公司间STO里交货单PGI之后自动触发内向交货单功能的实现

笔者所在的项目上的公司间STO的流程里,发货公司在做PGI之后系统自动触发收货公司的内向交货单.这个功能是通过交货单的Output来实现的. 如下单据为例说明,STO 4600003199 (从香港转入墨西哥), 外向交货单80015085, 看这个交货单Header 输出,SPED这个输出类型就是用来创建内向交货单的. 过账后触发的内向交货单, 看看后台输出类型SPED的配置(V/34), 看SPED的配置里的程序名字,是用SAP标准的程序, 2019-03-29 写于苏州市高新区. 原文地址

SAP内向交货单的业务场景

内向交货单,可以将一个PO在收货的时候,分批创建多次内向交货: 实际业务是: 1.有的时候一张大的PO会分多次收货,需要创建多张内向交货单(对应多次收货计划),然后仓库按照每次实际收货情况,过账内向交货单. 2.比如说,企业(你们公司)的仓库是由第三方物流来管理的.(或者你们公司是租用第三方物流公司的仓库,而且由物流公司的人来管理)这时,从供应商那里来的产品要收货的时候需要跟物流公司传递信息. 这时就可以用到内向交货流程. Inbound Delivery(Shipping Notificati

销售订单、外向交货单、交货 bapi

转自[http://www.cnblogs.com/elegantok/archive/2009/10/18/1585398.html]***********SALES ORDER INPUT CREATION. REPORT soi. PARAMETERS: p_auart TYPE auart OBLIGATORY.PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.PARAM

GL_子模组过账至总账通过SLA修改会计方法改变科目(案列)

2014-06-02 BaoXinjian 一.摘要 通过SLA会计方法的重新定义,修改从子模组过账至总账的默认会计方法,修改会计科目逻辑,实现按不同的会计法设定不同的会计方法 二.案例 1. 定义Mapping set 2. 定义科目5个Segment对应的Account Derivation Rule 3. 定义Journal Line Defination 4. 定义Application Accounting Definitions 5. 定义Subledger Accounting D

AR_标准应收过账至总账基本操作(流程)

2014-06-04 BaoXinjian 一.标准应收过账汇总 1. 应收事物处理 2. 应收发票核销 3. 通过Program<Submit Accounting>, 将AR的此笔资料过账到GL 4. GL过账日记账 5. 通过试算平衡报表,明确所影响的账户的余额 二.操作明细 1. 应收事物处理 (1).建立Transaction Batch (2).建立Transaction (3).建立Transaction Line (4).系统自动带出的Tax信息 2. 应付发票核销 (1).建