其他分享
首页 > 其他分享> > 函数使用十五:BAPI_PO_RELEASE

函数使用十五:BAPI_PO_RELEASE

作者:互联网

*&---------------------------------------------------------------------*
*& Report  ZBAPI_PO_RELEASE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
"场景:采购部门主管根据业务流程或者业务部门提供的信息对采购订单进行审批
REPORT  zbapi_po_release.

DATA:v_po TYPE bapimmpara-po_number,
     v_re_code TYPE bapimmpara-po_rel_cod,
     gt_return TYPE TABLE OF bapireturn,
     gw_return LIKE LINE OF gt_return.

v_po = '4500011395'.
v_re_code = '01'.
CALL FUNCTION 'BAPI_PO_RELEASE'
  EXPORTING
    purchaseorder          = v_po
    po_rel_code            = v_re_code
  TABLES
    return                 = gt_return
  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.
ENDIF.

READ TABLE gt_return INTO gw_return WITH KEY type = 'E'.
IF sy-subrc = 0.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'.
  WRITE v_po.
ENDIF.

 

标签:BAPI,code,return,SY,po,gt,RELEASE,PO
来源: https://www.cnblogs.com/sapSB/p/15497478.html