删除PO

Posted 学习笔记

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了删除PO相关的知识,希望对你有一定的参考价值。

FUNCTION zrfc_mm002.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(CALLNO) TYPE  ZCALLNO
*"     VALUE(PO_NUMBER) LIKE  BAPIMEPOHEADER-PO_NUMBER
*"  EXPORTING
*"     VALUE(FLAG) LIKE  BAPIRET2-TYPE
*"     VALUE(MESSAGE) LIKE  BAPIRET2-MESSAGE
*"  TABLES
*"      ZPOITEM STRUCTURE  ZPOITEM01
*"----------------------------------------------------------------------
DATA: ls_zpoitem TYPE zpoitem01,
      lv_message TYPE bapiret2-message,
      lv_datano  TYPE zdatano.

DATA:
      gv_po_number         LIKE  bapimepoheader-po_number,              "PO号
      gt_return            LIKE  TABLE OF bapiret2,                     "返回消息
      gs_return            LIKE  LINE  OF gt_return,
      gt_poitem            LIKE  TABLE OF bapimepoitem,                 "行项目
      gs_poitem            LIKE  LINE  OF gt_poitem,
      gt_poitemx           LIKE  TABLE OF bapimepoitemx,
      gs_poitemx           LIKE  LINE  OF gt_poitemx.


CLEAR:gv_po_number,gs_poitemx,gs_poitem,gs_return,gt_poitemx,gt_poitem,gt_return.

gv_po_number = po_number.

LOOP AT zpoitem INTO ls_zpoitem.
gs_poitem-po_item    = ls_zpoitem-po_item.
gs_poitem-delete_ind = ls_zpoitem-delete_ind.
APPEND gs_poitem TO gt_poitem.

gs_poitemx-po_item    = ls_zpoitem-po_item.
gs_poitemx-po_itemx    = g_flag.
gs_poitemx-delete_ind = g_flag.
APPEND gs_poitemx TO gt_poitemx.

CLEAR:gs_poitemx,gs_poitem.
ENDLOOP.


CALL FUNCTION BAPI_PO_CHANGE
  EXPORTING
    purchaseorder               = gv_po_number
 TABLES
   return                       = gt_return
   poitem                       = gt_poitem
   poitemx                      = gt_poitemx.

  READ TABLE gt_return INTO gs_return WITH KEY type = E.
  IF sy-subrc NE 0.
    flag = S.
    CALL FUNCTION BAPI_TRANSACTION_COMMIT
      EXPORTING
        wait = X.
    CONCATENATE PO:gv_po_number 处理完成 INTO message .
  ELSE.
    CALL FUNCTION BAPI_TRANSACTION_ROLLBACK.

    LOOP AT gt_return INTO gs_return WHERE type CA AEX.
        MESSAGE ID     gs_return-id
                TYPE   gs_return-type
                NUMBER gs_return-number
                WITH   gs_return-message_v1 gs_return-message_v2
                       gs_return-message_v3 gs_return-message_v4
                       INTO lv_message.
        CONCATENATE message lv_message INTO message SEPARATED BY .
    ENDLOOP.
    SHIFT message LEFT DELETING LEADING  .
    flag = E.
  ENDIF.


*记录日志
  CLEAR:gt_log,gs_log,ls_zpoitem.
  LOOP AT zpoitem INTO ls_zpoitem.
    lv_datano     = lv_datano + 1.
    gs_log-datano = lv_datano.
    gs_log-name   = ZRFC_MM002.
    gs_log-cdate  = sy-datum.
    GET TIME.
    gs_log-ctime  = sy-uzeit.
    gs_log-callno = callno.
    gs_log-flag   = flag.
    gs_log-log    = message.

    CONCATENATE  po_number  ls_zpoitem-po_item   ls_zpoitem-delete_ind
    INTO gs_log-content SEPARATED BY |.

    CONDENSE gs_log-content NO-GAPS.
    gs_log-length = STRLEN( gs_log-content ).
    APPEND gs_log TO gt_log.
    CLEAR ls_zpoitem.
  ENDLOOP.

IF gt_log IS NOT INITIAL.
INSERT zrfc_mm01in_log FROM TABLE gt_log.
IF sy-subrc = 0.
COMMIT WORK.
ENDIF.
ENDIF.
ENDFUNCTION.

 

以上是关于删除PO的主要内容,如果未能解决你的问题,请参考以下文章

删除PO

SAP MM已经转成PO的采购申请Item依旧可以被删除?

php 在Yoast SEO中更改或删除OpenGraph输出的代码片段。此代码中有多个代码段。

Realm保留一个已删除的对象

selenium(12)-web UI自动化项目实战(PO模式,代码封装)

Docker删除报错:Error response from daemon: conflict: unable to delete 08b152afcfae (must be forced)(代码片段