冲销交货单WS_REVERSE_GOODS_ISSUE

LOOP AT ITAB.

    AT END OF VBELN.
      PERFORM FRM_LOCK_DELIVERY(ZSDS0002) USING ITAB-VBELN.


      CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
        EXPORTING
          I_VBELN                   = ITAB-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.

        WRITE : / ITAB-VBELN, '冲销成功'.
      ELSE.
        WRITE : / ITAB-VBELN, '冲销失败'.
      ENDIF.
    ENDAT.

  ENDLOOP.

*****************************************************
FORM FRM_LOCK_DELIVERY  USING    P_DELIVERY.
  DATA : LV_TIME TYPE P DECIMALS 2 VALUE '0.50'.

  CHECK P_DELIVERY IS NOT INITIAL.

  DO 10 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  = ' '.

      EXIT.
    ELSE.
      WAIT UP TO LV_TIME SECONDS.
    ENDIF.
  ENDDO.

ENDFORM.                    " FRM_LOCK_DELIVERY

 

你可能感兴趣的:(冲销交货单WS_REVERSE_GOODS_ISSUE)