SAP MM- BAPI_PO_CHANGE 更新PO version 信息(version management)

 

 

实例程序

*&---------------------------------------------------------------------*
*& Report Z_PO_CHANGE
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT z_po_change.
DATA:lv_ponumber          TYPE bapimepoheader-po_number,
     ls_version           TYPE bapimedcm,
     ls_expheader         LIKE  bapimepoheader,
     ls_exppoexpimpheader LIKE  bapieikp,
     lt_return            TYPE TABLE OF  bapiret2,
     lt_allversions       TYPE TABLE OF bapimedcm_allversions,
     lt_poitem            TYPE TABLE OF bapimepoitem,
     lt_poitemx           TYPE TABLE OF  bapimepoitemx,
     ls_poitem            TYPE bapimepoitem,
     ls_poitemx           TYPE bapimepoitemx.

ls_poitem-po_item = '00010'.
APPEND ls_poitem TO lt_poitem.

ls_poitemx-po_item = '00010'.
ls_poitemx-po_itemx = 'U'.
APPEND ls_poitemx TO lt_poitemx.

lv_ponumber            = '4551701247'.
ls_version-post_date   = '20210510'.
ls_version-completed   = 'X'.
ls_version-description = 'Testing'.
ls_version-reason      = 'CR03'.
ls_version-req_by      = 'WANGZ94'.

APPEND INITIAL LINE TO lt_allversions ASSIGNING FIELD-SYMBOL(<fs_v>).
<fs_v>-doc_type      = 'F'.
<fs_v>-doc_number    =  '4551701247'.
<fs_v>-item_number   = '00000'.
<fs_v>-version       = '00000000'.
<fs_v>-created_by    = 'LIS72'.
<fs_v>-cr_on         = '20210510'.
<fs_v>-rec_time      = '094927'.
<fs_v>-reason        = 'CR03'.
<fs_v>-completed     = 'X'.
*<fs_v>-net_value     = '850'.
*<fs_v>-value_changed = '150'.
<fs_v>-currency      = 'CNY'.

CALL FUNCTION 'BAPI_PO_CHANGE'
  EXPORTING
    purchaseorder     = lv_ponumber
    versions          = ls_version
  IMPORTING
    expheader         = ls_expheader
    exppoexpimpheader = ls_exppoexpimpheader
  TABLES
    return            = lt_return
    poitem            = lt_poitem
    poitemx           = lt_poitemx
    allversions       = lt_allversions.

LOOP AT lt_return TRANSPORTING NO FIELDS WHERE type CA 'AEX'.
  EXIT.
ENDLOOP.

IF sy-subrc <> 0.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'.
ELSE.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.

 

上一篇:从零构建通讯器--5.8 ET、LT深入分析及测试,服务器设计、粘包解决(未完待续)


下一篇:实例开发-NX二次开发手动截图工具