函数使用十五: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.

 

上一篇:L1-009 N个数求和


下一篇:C语言【微项目04】—数组随机存储器(采用依时间生成的随机数作为数组下标存储数据)