• 采购订单审批与撤销审批BAPI


    *"----------------------------------------------------------------------
    *"*"本地接口:
    *"  IMPORTING
    *"     REFERENCE(IN_EBELN) TYPE  BAPIMMPARA-PO_NUMBER
    *"     REFERENCE(IN_FLAG) TYPE  CHAR01
    *"     REFERENCE(IN_FRGCO) TYPE  BAPIMMPARA-PO_REL_COD
    *"  EXPORTING
    *"     REFERENCE(OUT_MSG) TYPE  STRING
    *"----------------------------------------------------------------------
      CLEAR:OUT_MSG.
      IF IN_FLAG = 'Y'.
        CALL FUNCTION 'BAPI_PO_RELEASE'
          EXPORTING
            PURCHASEORDER               = IN_EBELN
            PO_REL_CODE                 = IN_FRGCO
         EXCEPTIONS
           AUTHORITY_CHECK_FAIL         = 1
           DOCUMENT_NOT_FOUND           = 2
           ENQUEUE_FAIL                 = 3
           PREREQUISITE_FAIL            = 4
           RELEASE_ALREADY_POSTED       = 5
           RESPONSIBILITY_FAIL          = 6
           OTHERS                       = 7.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ELSE.
          OUT_MSG = 'S'.
        ENDIF.
      ELSEIF IN_FLAG = 'N'.
        CALL FUNCTION 'BAPI_PO_RESET_RELEASE'
          EXPORTING
            PURCHASEORDER                 = IN_EBELN
            PO_REL_CODE                   = IN_FRGCO
         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.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ELSE.
          OUT_MSG = 'S'.
        ENDIF.
      ENDIF.

    相关表:

    透明表             T16FS   批准策略

     

    T16FE                          批准标识的描述:采购凭证

    使用ME25K 审批按钮跟踪:

    标准事物: ME29N  采购订单审批

                       ME35K  采购合同审批

    都会走程序  SAPLMEREP

    包含文件     LMEREPI20

     调用函数   BAPI_PO_RELEASE

    标准代码

      METHOD rel_resetrel.
    
        DATA: ls_outtab       TYPE merep_outtab_purchdoc_rel,
              l_model         TYPE REF TO lcl_reporting_model,
              l_datablade     TYPE REF TO lcl_datablade_general,
              l_frgab         TYPE rm06b-frgab,
              l_frgzu         TYPE ekko-frgzu,
              l_frgke         TYPE ekko-frgke,
              l_ebeln         TYPE ekko-ebeln.
    
        FIELD-SYMBOLS: <line> LIKE LINE OF gt_outtab_purchdoc_rel.
    
        l_model = my_view->get_model( ).
        l_datablade ?= l_model->get_current_datablade( ).
        l_frgab = l_datablade->get_option( 'FRGAB' ).
        CHECK NOT l_frgab IS INITIAL.
    
        MOVE-CORRESPONDING im_wa TO ls_outtab.
        CASE ls_outtab-icon_release.
          WHEN lcl_datablade_purchdoc_rel=>my_icon_allowed.
    * release
            CALL FUNCTION 'BAPI_PO_RELEASE'
              EXPORTING
                purchaseorder     = ls_outtab-ebeln
                po_rel_code       = l_frgab
                use_exceptions    = 'X'
              IMPORTING
                rel_status_new    = l_frgzu
                rel_indicator_new = l_frgke
              EXCEPTIONS
                error_message     = 1
                OTHERS            = 2.
            IF sy-subrc <> 0.
              MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
                      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            ELSE.
    * update output table
              LOOP AT gt_outtab_purchdoc_rel ASSIGNING <line> WHERE
                                                      ebeln = ls_outtab-ebeln.
                IF l_ebeln NE ls_outtab-ebeln.
                  <line>-icon_release = lcl_datablade_purchdoc_rel=>my_icon_done.
                  l_ebeln = ls_outtab-ebeln.
                ELSE.
                  CLEAR <line>-icon_release.
                ENDIF.
                <line>-frgzu = l_frgzu.
                <line>-frgke = l_frgke.
                SELECT SINGLE frget FROM t16fe INTO <line>-frget WHERE
                                           spras EQ sy-langu AND
                                           frgke EQ l_frgke.
              ENDLOOP.
            ENDIF.
    
          WHEN lcl_datablade_purchdoc_rel=>my_icon_done.
    * reset release
            CALL FUNCTION 'BAPI_PO_RESET_RELEASE'
              EXPORTING
                purchaseorder     = ls_outtab-ebeln
                po_rel_code       = l_frgab
                use_exceptions    = 'X'
              IMPORTING
                rel_status_new    = l_frgzu
                rel_indicator_new = l_frgke
              EXCEPTIONS
                error_message     = 1
                OTHERS            = 2.
    
            IF sy-subrc <> 0.
              MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
                      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            ELSE.
              LOOP AT gt_outtab_purchdoc_rel ASSIGNING <line> WHERE
                                                      ebeln = ls_outtab-ebeln.
                IF l_ebeln NE ls_outtab-ebeln.
                  <line>-icon_release = lcl_datablade_purchdoc_rel=>my_icon_allowed.
                  l_ebeln = ls_outtab-ebeln.
                ELSE.
                  CLEAR <line>-icon_release.
                ENDIF.
                <line>-frgzu = l_frgzu.
                <line>-frgke = l_frgke.
                SELECT SINGLE frget FROM t16fe INTO <line>-frget WHERE
                                           spras EQ sy-langu AND
                                           frgke EQ l_frgke.
              ENDLOOP.
            ENDIF.
    
        ENDCASE.
      ENDMETHOD.                    "rel_resetrel
  • 相关阅读:
    Django
    ionic创建项目报错Error: read ECONNRESET at _errnoException (util.js:992:11) at TLSWrap.onread (net.js:618:25)
    转《vue引入第三方js库》
    转《在浏览器中使用tensorflow.js进行人脸识别的JavaScript API》
    微信小程序自定义组件
    小程序中尽量少使用定时器
    解决小程序webview缓存机制
    小程序获取当前页面URL
    6s ios9.0平台 微信小程序的fixed定位兼容性问题
    如何使用nodejs快速搭建本地服务器
  • 原文地址:https://www.cnblogs.com/rainysblog/p/11095946.html
Copyright © 2020-2023  润新知