ABAP EWM模拟 /SCWM/ADGI过账更改HU数量

Posted 想发财的小夏

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ABAP EWM模拟 /SCWM/ADGI过账更改HU数量相关的知识,希望对你有一定的参考价值。

需求: /SCWM/ADGI -> 库存更正 -> 过账发货部分数量 进行修改数量,产生WT。

比较简单哈,封装了一个函数,话不多说,直接上代码!奥里给~~~

FUNCTION zewm_chanre_qty_adgi.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     VALUE(IV_LGNUM) TYPE  /SCWM/LGNUM DEFAULT 'BL01'
*"     VALUE(IV_HUIDENT) TYPE  /SCWM/DE_HUIDENT
*"     VALUE(IV_MATNR) TYPE  MATNR
*"     VALUE(IV_QTY) TYPE  /SCWM/DE_UI_QUAN
*"  EXPORTING
*"     REFERENCE(EV_MSG) TYPE  BAPI_MSG
*"     REFERENCE(EV_TYPE) TYPE  BAPI_MTYPE
*"----------------------------------------------------------------------
" 2022.3.24 模拟/scwm/adgi更改库存数量

  DATA: et_huitm     TYPE /scwm/tt_stock_select,
        lv_nwmloc    TYPE /scwm/s_adgi_sel-nwmloc,
        lv_reason    TYPE /scwm/s_adgi_sel-gi_process,
        lv_reason_wm TYPE /scwm/s_adgi_sel-reason,
        lt_stock_sel TYPE /scwm/tt_scrap_stock,
        lt_sernr_sel TYPE /scwm/tt_scrap_serid,
        ls_gmheader  TYPE /scwm/s_gmheader.

  DEFINE set_msg.

    ev_type = &1.
    ev_msg  = &2.

  END-OF-DEFINITION.

  CLEAR:ev_type,ev_msg,et_huitm.

  CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    EXPORTING
      input        = iv_matnr
    IMPORTING
      output       = iv_matnr
    EXCEPTIONS
      length_error = 1
      OTHERS       = 2.

  CALL FUNCTION '/SCWM/SELECT_STOCK'
    EXPORTING
      iv_lgnum   = iv_lgnum
      ir_huident = VALUE rseloption( ( sign = 'I' option = 'EQ' low = iv_huident ) )
      ir_matnr   = VALUE rseloption( ( sign = 'I' option = 'EQ' low = iv_matnr ) )
    IMPORTING
      et_huitm   = et_huitm
    EXCEPTIONS
      error      = 1
      OTHERS     = 2.

  IF et_huitm IS INITIAL.
    set_msg 'E' '未查询到HU数据'.
    EXIT.
  ENDIF.

  READ TABLE et_huitm INTO DATA(ls_huitm) INDEX 1.
  APPEND INITIAL LINE TO lt_stock_sel ASSIGNING FIELD-SYMBOL(<fs_stock_sel>).
  MOVE-CORRESPONDING ls_huitm TO <fs_stock_sel>.

  " 调整数量
  <fs_stock_sel>-quan_int = <fs_stock_sel>-quan = iv_qty.

  NEW /scwm/cl_rgi_scrap_srvc( iv_lgnum = iv_lgnum )->scrap_handle(
       EXPORTING
         it_stock_sel = lt_stock_sel
         it_serid_sel = lt_sernr_sel
         iv_nwmloc    = lv_nwmloc
         iv_reason    = 'CORR'
         iv_reason_wm = lv_reason_wm
       CHANGING
         cs_gmheader  = ls_gmheader ).

  ls_gmheader-log->get_severity(
    RECEIVING
      e_rc_severity = DATA(lv_severity) ).

  IF lv_severity CA 'EAX'.
    lv_severity = 'E'.
  ELSE.
    lv_severity = 'S'.
  ENDIF.

  ls_gmheader-log->get_prot( RECEIVING et_protocol = DATA(et_return) ).
  READ TABLE et_return INTO DATA(ls_return) WITH KEY type = lv_severity.
  IF sy-subrc EQ 0.
    DATA(lv_msg) = ls_return-message.
  ENDIF.

  set_msg lv_severity lv_msg.

ENDFUNCTION.

以上是关于ABAP EWM模拟 /SCWM/ADGI过账更改HU数量的主要内容,如果未能解决你的问题,请参考以下文章

ABAP EWM PRDI交货单过账

ABAP EWM PRDO交货单过账

ABAP EWM PRDO交货单过账

ABAP EWM PRDI交货单过账

ABAP EWM PRDI交货单过账

ABAP EWM 库存状态变更