본문 바로가기
MM/ETC

[MM] Release PO BAPI

by clode 2023. 3. 2.
728x90
반응형

릴리즈 T-CODE : ME29N 헤더 릴리즈 전략 탭

PO 릴리즈 ( BAPI_PO_RELEASE )

  DATA: LV_PO_REL_COD    LIKE BAPIMMPARA-PO_REL_COD,
        LV_STATUS_NEW    LIKE BAPIMMPARA-REL_STATUS,
        LV_INDICATOR_NEW LIKE BAPIMMPARA-PO_REL_IND,
        LT_RETURN        LIKE TABLE OF BAPIRETURN.


  LV_PO_REL_COD = GC_3.

  CALL FUNCTION 'BAPI_PO_RELEASE'
    EXPORTING
      PURCHASEORDER            = GS_DATA-EBELN
      PO_REL_CODE              = LV_PO_REL_COD
      USE_EXCEPTIONS           = ABAP_TRUE
    IMPORTING
      REL_STATUS_NEW           = LV_STATUS_NEW
      REL_INDICATOR_NEW        = LV_INDICATOR_NEW
*     RET_CODE                 =
    TABLES
      RETURN                   = LT_RETURN
    EXCEPTIONS
      AUTHORITY_CHECK_FAIL     = 1
      DOCUMENT_NOT_FOUND       = 2
      ENQUEUE_FAIL             = 3
      PREREQUISITE_FAIL        = 4
      RELEASE_ALREADY_POSTED   = 5
      RESPONSIBILITY_FAIL      = 6
      NO_RELEASE_ALREADY       = 7
      NO_NEW_RELEASE_INDICATOR = 8
      OTHERS                   = 9.

  READ TABLE LT_RETURN INTO DATA(LS_RETURN) WITH KEY TYPE = GC_E.
  IF SY-SUBRC EQ 0.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
*    GV_ERROR = GC_X.
*    GS_DATA = VALUE #( BASE GS_DATA
*                        STATUS = '@5C@' "RED
*                        TYPE = GC_E
*                        MSG = LS_RETURN-MESSAGE ).
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
*    GS_DATA = VALUE #( BASE GS_DATA
*                        STATUS = '@5D@' "YELLOW
*                        TYPE = GC_S
*                        MSG = LS_RETURN-MESSAGE ).
  ENDIF.

PO 릴리즈 취소 ( BAPI_PO_RESET_RELEASE )

  DATA: LV_PO_REL_COD LIKE BAPIMMPARA-PO_REL_COD,
        LV_STATUS     LIKE BAPIMMPARA-REL_STATUS,
        LV_INDICATOR  LIKE BAPIMMPARA-PO_REL_IND,
        LT_RETURN     LIKE TABLE OF BAPIRETURN.

  LV_PO_REL_COD = GC_3.

  CALL FUNCTION 'BAPI_PO_RESET_RELEASE'
    EXPORTING
      PURCHASEORDER            = GS_DATA-EBELN
      PO_REL_CODE              = LV_PO_REL_COD
      USE_EXCEPTIONS           = ABAP_TRUE
    IMPORTING
      REL_STATUS_NEW           = LV_STATUS
      REL_INDICATOR_NEW        = LV_INDICATOR
    TABLES
      RETURN                   = LT_RETURN
    EXCEPTIONS
      AUTHORITY_CHECK_FAIL     = 1
      DOCUMENT_NOT_FOUND       = 2
      ENQUEUE_FAIL             = 3
      PREREQUISITE_FAIL        = 4
      RELEASE_ALREADY_POSTED   = 5
      RESPONSIBILITY_FAIL      = 6
      NO_RELEASE_ALREADY       = 7
      NO_NEW_RELEASE_INDICATOR = 8
      OTHERS                   = 9.

  READ TABLE LT_RETURN INTO DATA(LS_RETURN) WITH KEY TYPE = GC_E.
  IF SY-SUBRC EQ 0.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    GV_ERROR = GC_X.
    GS_DATA = VALUE #( BASE GS_DATA
                        STATUS = '@5C@' "RED
                        TYPE = GC_E
                        MSG = LS_RETURN-MESSAGE ).
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    WAIT UP TO '0.2' SECONDS.
    GS_DATA = VALUE #( BASE GS_DATA
                        STATUS = '@5D@' "YELLOW
                        TYPE = GC_S
                        MSG = TEXT-M02 ). "릴리즈 취소되었습니다.
  ENDIF.
728x90
반응형

'MM > ETC' 카테고리의 다른 글

ALV로 조회하기 (feat. ME1M)  (0) 2024.07.10
[MM] 월별 대비 실적 조회  (0) 2023.03.02
[MM] Create PO BAPI  (0) 2023.03.02
User-exit  (0) 2023.02.27
Batch Job  (0) 2023.02.24

댓글