SAP WS_DELIVERY_UPDATE2更细库存地点LGORT及过账

发布时间:2023年12月22日

WS_DELIVERY_UPDATE2正常情况无法更改LGORT,但是有标准的BADI可以进行变更,这样DN变更和过账可以使用一个BAPI来完成。

增强点:LE_SHP_DELIVERY_UPDATE

方法:IF_EX_LE_SHP_DELIVERY_UPDATE~UPDATE_ITEM

  METHOD if_ex_le_shp_delivery_update~update_item.
      IF is_vbpok-lgort IS NOT INITIAL.
        cs_lips-lgort = is_vbpok-lgort.
      ENDIF.
  ENDMETHOD.

测试demo:

REPORT zprtest_dn_post.

DATA:
  ls_vbkok_wa TYPE vbkok,
  lv_delivery TYPE likp-vbeln,
  lt_prot     TYPE STANDARD TABLE OF prott,
  lt_vbpok    TYPE STANDARD TABLE OF vbpok,
  ls_vbpok    TYPE vbpok,
  ls_prot     TYPE prott.

DATA:
  lv_msg  TYPE string.

DATA:
  lv_vbeln TYPE vbeln VALUE '0070005866'.

SELECT vbeln,
       posnr,
       vgbel,
       vgpos,
       matnr,
       lfimg,
       charg,
       vrkme,
       meins,
       umvkz,
       umvkn,
       lgort
  INTO TABLE @DATA(lt_lips)
  FROM lips
 WHERE vbeln = @lv_vbeln.

ls_vbkok_wa-vbeln_vl  = lv_vbeln.
ls_vbkok_wa-wadat_ist = sy-datlo.
ls_vbkok_wa-wabuc     = abap_true.
ls_vbkok_wa-komue     = abap_true.

lv_delivery = lv_vbeln.

LOOP AT lt_lips INTO DATA(ls_lips).
  ls_vbpok-vbeln_vl = ls_lips-vbeln.
  ls_vbpok-posnr_vl = ls_lips-posnr.
  ls_vbpok-vbeln    = ls_lips-vgbel.
  ls_vbpok-posnn    = ls_lips-vgpos.
  ls_vbpok-pikmg    = ls_lips-lfimg.
  ls_vbpok-matnr    = ls_lips-matnr.
  ls_vbpok-charg    = ls_lips-charg.
  ls_vbpok-vrkme    = ls_lips-vrkme.
  ls_vbpok-meins    = ls_lips-meins.
  ls_vbpok-umvkz    = ls_lips-umvkz.
  ls_vbpok-umvkn    = ls_lips-umvkn.
  ls_vbpok-lgort    = '9999'.
  APPEND ls_vbpok TO lt_vbpok.
  CLEAR ls_vbpok.
ENDLOOP.

CALL FUNCTION 'WS_DELIVERY_UPDATE_2'
  EXPORTING
    vbkok_wa       = ls_vbkok_wa
*   SYNCHRON       = ' '
*   NO_MESSAGES_UPDATE_1               = ' '
*   COMMIT         = ' '
    delivery       = lv_delivery
    update_picking = abap_true
  TABLES
    vbpok_tab      = lt_vbpok
    prot           = lt_prot.

IF lt_prot IS NOT INITIAL.
  LOOP AT lt_prot INTO ls_prot WHERE msgty = 'E'.
    MESSAGE ID ls_prot-msgid
       TYPE ls_prot-msgty
     NUMBER ls_prot-msgno
       WITH ls_prot-msgv1
            ls_prot-msgv2
            ls_prot-msgv3
            ls_prot-msgv4
       INTO DATA(lv_message).

    WRITE:/,lv_message.
  ENDLOOP.

  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

*  cl_demo_output=>display( lt_prot ).
ELSE.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'.

  MESSAGE 'Change and Post Successful..' TYPE 'S'.
ENDIF.

文章来源:https://blog.csdn.net/DeveloperMrMeng/article/details/135157159
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。