EWM常规开发知识汇总

Posted 想发财的小夏

tags:

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

EWM常规开发知识总结

前言

什么是EWM?

SAP EWM即扩展仓库管理Extended Warehouse Management(简写EWM),此系统为客户处理各种商品移动和管理仓库库存,提供灵活的自动化支持。系统能够对客户所有仓库物流流程进行有计划地高效处理,而仓库中的主要流程是收货和退货,收货和发货。

一、EWM常用tcode/table/function汇总

1.Tcode

EWM直接前台输入的话需要加/n,否则需要在se93执行tcode

function areaDescriptionT-code
Monitor仓库管理监控器/n/scwm/mon
Outbound维护出库交货订单/n/scwm/prdo
Inbound维护入库交货/n/scwm/prdi
Internal创建处理单位的仓库任务/n/scwm/adhu
过账更改/n/scwm/post
确认仓库任务/n/scwm/to_conf
包装 - 常规/n/scwm/pack
维护运输单位/n/scwm/tu
维护波次/n/scwm/wave
Physical inventory创建实际库存凭证/n/scwm/pi_create
输入库存盘点计数/n/scwm/pi_count
处理实际库存凭证/n/scwm/pi_process
RF登录到 RF 环境/n/scwm/rfui
用户维护/n/scwm/user
资源维护/n/scwm/rsrc
资源组维护/n/scwm/rgrp
描述设备维护/n/scwm/prdvc

2.Table

基本都是以/scwm和/scdl为开头

Table AreaDescriptionTable
ReferenceReference/SCDL/DB_REFDOC
Status/SCDL/DB_STATUS
OutboundOutbound Delivery Order Header/SCDL/DB_PROCH_O
Outbound Delivery Order Item/SCDL/DB_PROCI_O
InboundInbound Delivery: Header/SCDL/DB_PROCH_I
Inbound Delivery Item/SCDL/DB_PROCI_I
HUHandling Unit/SCDL/DB_HU
Handling unit header/SCWM/HUHDR
Handling Unit Item/SCWM/GMHUITM
Handling Unit Reference/SCWM/HUREF
Warehouse TaskWarehouse Tasks Log Table/SCWM/ORDIM_L
Warehouse Tasks Confirmed/SCWM/ORDIM_C
Warehouse Tasks Open/SCWM/ORDIM_O
Exception Codes for Warehouse Task/SCWM/ORDIM_E
WaveWave - Header InformationSCWM/WAVEHDR
Wave ItemSCWM/WAVEITM
TUAssignment of Deliveries and HUs to Transportation Units/SCWM/TU_DLV
Status of Transportation Unit Activities/SCWM/TU_STATUS

3.Function

FunctionDescription
/SCWM/SELECT_STOCKSelection of Stock
/SCWM/STOCK_CHANGEStock Transfer Postings
/SCWM/TO_CREATEGenerate Warehouse Task with Multiple Items
/SCWM/TO_CONFIRMConfirm Warehouse Task
/SCWM/TO_CANCELCancel Warehouse Task
/SCWM/TO_POSTUpdate Internal Warehouse Task Tables
/SCWM/TO_CREATE_MOVE_HUGenerate Warehouse Task for Moving HUs
/SCWM/HU_SELECT_GENSelecting HUs
/SCWM/HUHEADER_READRead a HU Header
/SCWM/HUITM_READRead HU Items

4.Class

ClassDescription
/SCDL/CL_SP_PRD_INBService Provider PRD Inbound Delivery
/SCDL/CL_SP_PRD_OUTService Provider PRD Outbound Delivery
/SCWM/CL_WM_PACKINGPacking in WM with Immediately Confirmed Transfer Orders
/SCWM/CL_DLV_PACK_IBDLPacking of Outbound Delivery
/SCWM/CL_RF_BLL_SRVCRF Business Logic Layer

二、开发Demo

1.基于函数

代码如下(EWM库存状态变更/SCWM/STOCK_CHANGE):

FUNCTION zewm_change_stock.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     REFERENCE(IV_LGNUM) TYPE  /SCWM/LGNUM
*"     REFERENCE(IT_INPUT) TYPE  ZEWM_T_001
*"  EXPORTING
*"     REFERENCE(ET_OUTPUT) TYPE  BAPIRET2_TAB
*"----------------------------------------------------------------------

  DATA:
    lr_huident  TYPE rseloption,
    lt_huitm    TYPE /scwm/tt_stock_select,
    lt_huhdr    TYPE /scwm/tt_huhdr,
    ls_header   TYPE /scwm/s_gmheader,
    lt_item     TYPE /scwm/tt_spitem,
    ls_item     TYPE /scwm/s_spitem,
    lt_ltap_vb  TYPE /scwm/tt_ltap_vb,
    lt_bapiret  TYPE bapiret2_tab,
    lt_bapiret2 TYPE bapiret2_tab,
    lv_severity TYPE bapi_mtype,
    lv_id       TYPE /lime/line_item_id.

  CLEAR:lt_bapiret.

  LOOP AT it_input INTO DATA(ls_input).

    CLEAR:lv_severity.

    /scwm/cl_tm=>cleanup( ).
    /scwm/cl_tm=>set_lgnum( iv_lgnum ).

    lr_huident = VALUE #( ( sign = 'I' option = 'EQ' low = ls_input-huident ) ).
    CLEAR: lt_huitm, lt_huhdr.
    CALL FUNCTION '/SCWM/SELECT_STOCK'
      EXPORTING
        iv_lgnum   = iv_lgnum
        ir_huident = lr_huident
      IMPORTING
        et_huitm   = lt_huitm
        et_huhdr   = lt_huhdr
      EXCEPTIONS
        error      = 1.

    IF lt_huitm[] IS INITIAL.
      lv_severity = 'E'.
      APPEND VALUE #( id = '00' type = 'E' number = '398' message = '未查询到HU:' && ls_input-huident ) TO lt_bapiret.
      CONTINUE.
    ENDIF.
    READ TABLE lt_huitm INTO DATA(ls_huitm) INDEX 1.
    CLEAR ls_header.
    ls_header-lgnum = iv_lgnum.
    ls_header-created_by = sy-uname.
    ls_header-post  = abap_false.
    ls_header-compl = abap_true.
    ls_header-code = '/SCWM/POST'.
    CLEAR:lv_id,lt_item,ls_item,ls_item-t_quan.
    ADD 1 TO lv_id.
    ls_item-id                     = lv_id.
    ls_item-id_group               = '2'.
    ls_item-direction              = 'T'.
    ls_item-procty                 = ls_input-procty.
    ls_item-guid_hu                = ls_input-guid_hu.
    ls_item-huident                = ls_input-huident.
*    ls_item-squant_set             = 'X'.
    ls_item-loc-lgnum              = ls_huitm-lgnum.
    ls_item-loc-lgtyp              = ls_huitm-lgtyp.
    ls_item-loc-lgpla              = ls_huitm-lgpla.
    " 源
    ls_item-source_s-idx_stock     = ls_huitm-idx_stock.
    ls_item-source_s-guid_stock    = ls_huitm-guid_stock.
    ls_item-source_s-matid         = ls_huitm-matid.
    ls_item-source_s-batchid       = ls_huitm-batchid.
    ls_item-source_s-cat           = ls_huitm-cat.
    ls_item-source_s-stock_doccat  = ls_huitm-stock_doccat.
    ls_item-source_s-stock_docno   = ls_huitm-stock_docno.
    ls_item-source_s-stock_itmno   = ls_huitm-stock_itmno.
    ls_item-source_s-stock_usage   = ls_huitm-stock_usage.
    ls_item-source_s-owner         = ls_huitm-owner.
    ls_item-source_s-owner_role    = ls_huitm-owner_role.
    ls_item-source_s-entitled      = ls_huitm-entitled.
    ls_item-source_s-entitled_role = ls_huitm-entitled_role.
    ls_item-source_s-stock_cnt     = ls_huitm-stock_cnt.
    ls_item-source_s-qdoccat       = ls_huitm-qdoccat.
    ls_item-source_s-qdocid        = ls_huitm-qdocid.
    ls_item-source_s-qitmid        = ls_huitm-qitmid.
    " 目标
    ls_item-dest_s-matid           = ls_huitm-matid.
    ls_item-dest_s-batchid         = ls_huitm-batchid.
    ls_item-dest_s-cat             = ls_input-to_cat.   " Cat
    ls_item-dest_s-stock_doccat    = ls_huitm-stock_doccat.
    ls_item-dest_s-stock_docno     = ls_huitm-stock_docno.
    ls_item-dest_s-stock_itmno     = ls_huitm-stock_itmno.
    ls_item-dest_s-stock_usage     = ls_huitm-stock_usage.
    ls_item-dest_s-owner           = ls_huitm-owner.
    ls_item-dest_s-owner_role      = ls_huitm-owner_role.
    ls_item-dest_s-entitled        = ls_huitm-entitled.
    ls_item-dest_s-entitled_role   = ls_huitm-entitled_role.
    ls_item-dest_s-stock_cnt       = ls_huitm-stock_cnt.
    ls_item-dest_s-qdoccat         = ls_huitm-qdoccat.
    ls_item-dest_s-qdocid          = ls_huitm-qdocid.
    ls_item-dest_s-qitmid          = ls_huitm-qitmid.
    ls_item-dest_loc-lgnum         = ls_huitm-lgnum.
    ls_item-dest_loc-lgtyp         = ls_input-nltyp. " 目标存储类型
    ls_item-dest_loc-lgpla         = ls_input-nlpla. " 目标仓位

    APPEND VALUE #( quan = ls_huitm-quan unit = ls_huitm-meins ) TO ls_item-t_quan.
    APPEND ls_item TO lt_item.

    IF lt_item IS NOT INITIAL.
      CLEAR: lt_ltap_vb, lt_bapiret2, lv_severity.
      CALL FUNCTION '/SCWM/STOCK_CHANGE'
        EXPORTING
          is_header   = ls_header
          it_item     = lt_item
        IMPORTING
          et_ltap_vb  = lt_ltap_vb
          et_bapiret  = lt_bapiret2
          ev_severity = lv_severity
        EXCEPTIONS
          wrong_input = 1
          OTHERS      = 2.

      IF sy-subrc <> 0.
        lv_severity = 'E'.
      ELSE.
        LOOP AT lt_bapiret2 TRANSPORTING NO FIELDS WHERE type CA 'EAX'.
          lv_severity = 'E'.
          EXIT.
        ENDLOOP.
      ENDIF.

      IF lv_severity <> 'E'.
        CLEAR: lt_bapiret2, lv_severity.
        CALL FUNCTION '/SCWM/GM_POST'
          IMPORTING
            et_bapiret  = lt_bapiret2
            ev_severity = lv_severity.
        LOOP AT lt_bapiret2 TRANSPORTING NO FIELDS WHERE type CA 'EAX'.
          lv_severity = 'E'.
          EXIT.
        ENDLOOP.
      ENDIF.
      IF lv_severity <> 'E'.
        COMMIT WORK AND WAIT.
        APPEND VALUE #( id = '00' type = 'S' number = '398' message = ls_input-huident && '修改成功' ) TO lt_bapiret.
      ELSE.
        APPEND LINES OF lt_bapiret2 TO lt_bapiret.
        APPEND VALUE #( id = '00' type = 'E' number = '398' message = ls_input-huident && '修改失败' ) TO lt_bapiret.
        ROLLBACK WORK.
      ENDIF.

      /scwm/cl_tm=>cleanup( iv_reason = /scmb/if_sp_transaction=>sc_cleanup_commit ).

    ENDIF.

  ENDLOOP.

  IF lt_bapiret IS NOT INITIAL.
    et_output[] = lt_bapiret[].
  ENDIF.

ENDFUNCTION.

2.基于Class

代码如下(/n/scwm/prdo更新交货单数量):

DATA: lo_sp             TYPE REF TO /scdl/cl_sp_prd_out,
      lo_message_box    TYPE REF TO /scdl/cl_sp_message_box,
      ls_sp_action      TYPE /scdl/s_sp_act_action,
      ls_relation_inkey TYPE /scdl/s_sp_k_head,
      lt_sp_k_head      TYPE /scdl/t_sp_k_head,
      lt_sp_k_item      TYPE /scdl/t_sp_k_item,
      lt_a_item2        TYPE /scdl/t_sp_a_item,
      ls_sp_k_item      TYPE /scdl/s_sp_k_item,
      lt_return_codes   TYPE /scdl/t_sp_return_code,
      lt_messages       TYPE /scdl/dm_message_tab,
      lv_rejected       TYPE boole_d,
      lv_error_occured  TYPE boole_d.

FIELD-SYMBOLS: <ls_parameter>  TYPE  any.

DATA: lv_msg TYPE bapi_msg,
      lv_txt TYPE bapi_msg.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.

  PARAMETERS:p_lgnum TYPE /scwm/lgnum,
             p_vbeln TYPE vbeln_vl, " dn
             p_posnr TYPE posnr_vl. " dn item

SELECTION-SCREEN END OF BLOCK b1.

BREAK-POINT.

" 根据ecc 的交货单 查询 ewm交货单key
SELECT SINGLE * FROM /scdl/db_refdoc
  INTO @DATA(ls_db_refdoc)
 WHERE refdocno  = @p_vbeln
   AND refitemno = @p_posnr
   AND refdoccat = 'ERP'.

" 查询ewm交货单行数据
SELECT SINGLE * FROM /scdl/db_proci_o
  INTO @DATA(ls_prdo_i)
 WHERE docid  = @ls_db_refdoc-docid
   AND itemid = @ls_db_refdoc-itemid.

ls_sp_k_item-docid  = ls_prdo_i-docid.
ls_sp_k_item-itemid = ls_prdo_i-itemid.
APPEND ls_sp_k_item TO lt_sp_k_item.

ls_relation_inkey-docid = ls_prdo_i-docid.
APPEND ls_relation_inkey TO lt_sp_k_head.

CREATE OBJECT lo_message_box. " message box

" set class /scdl/cl_sp_prd_out
CREATE OBJECT lo_sp
  EXPORTING
    io_message_box = lo_message_box
    iv_doccat      = /scdl/if_dl_doc_c=>sc_doccat_out_prd
    iv_mode        = /scdl/cl_sp=>sc_mode_classic.

"set warehouse
/scwm/cl_tm=>set_lgnum( p_lgnum ).

" set lock
lo_sp->lock(
  EXPORTING
    inkeys       = lt_sp_k_head
    aspect       = /scdl/if_sp_c=>sc_asp_head
    lockmode     = /scdl/if_sp1_locking=>sc_exclusive_lock
  IMPORTING
    rejected     = lv_rejected
    return_codes = lt_return_codes ).

" get msg
READ TABLE lt_return_codes TRANSPORTING NO FIELDS WITH KEY failed = abap_true.
IF sy-subrc = 0 OR lv_rejected = abap_true.
  lv_error_occured = abap_true.

  MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
     INTO lv_msg.
ENDIF.

" set action
CREATE DATA ls_sp_action-action_control TYPE /scdl/bo_action_adjqty_str.
ASSIGN ls_sp_action-action_control->* TO <ls_parameter>.
ls_sp_action-action_code = '028'.
<ls_parameter> = 'O001'.

IF lv_error_occured = abap_false.

  " execute
  CLEAR:lt_return_codes,lv_rejected.
  lo_sp->execute(
    EXPORTING
      aspect       = /scdl/if_sp_c=>sc_asp_item
      inkeys       = lt_sp_k_item
      inparam      = ls_sp_action
      action       = /scdl/if_sp_c=>sc_act_execute_action
    IMPORTING
      outrecords   = lt_a_item2
      rejected     = lv_rejected
      return_codes = lt_return_codes ).

  " get msg
  READ TABLE lt_return_codes TRANSPORTING NO FIELDS WITH KEY failed = abap_true.
  IF sy-subrc = 0 OR lv_rejected = abap_true.
    lv_error_occured = abap_true.

    MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
       INTO lv_msg.
  ENDIF.

ENDIF.

" 可以通过类 抓取消息
lt_messages = lo_message_box->get_messages( ).

IF lv_error_occured = abap_false.

  CLEAR lv_rejected.
  " before save
  lo_sp->before_save( IMPORTING rejected = lv_rejected ).
  " get msg
  IF lv_rejected = abap_true.
    lv_error_occured = abap_true.

    MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
       INTO lv_msg.
  ENDIF.

ENDIF.

IF lv_error_occured = abap_false.

  CLEAR lv_rejected.
  " save
  lo_sp->save( IMPORTING rejected = lv_rejected ).
  " get msg
  IF lv_rejected = abap_true.
    lv_error_occured = abap_true.

    MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
       INTO lv_msg.
  ENDIF.

ENDIF.

IF lv_error_occured = abap_true.
  MESSAGE lv_msg TYPE 'S' DISPLAY LIKE 'E'.
  ROLLBACK WORK.
ELSE.
  MESSAGE '更改成功' TYPE 'E'.
  COMMIT WORK AND WAIT.
ENDIF.

" clean up
CALL METHOD lo_sp->cleanup
  EXPORTING
    reason = /scmb/if_sp_transaction=>sc_cleanup_commit.

"clear buffers and release loc
/scwm/cl_tm=>cleanup( ).

三、增强

可以通过三种方式查找

1.SE18

SE18->增强点 /SCWM/ES_*

2.SPRO

SPRO->SCM Extended Warehouse Management->扩展仓库管理->
SCM Extended Warehouse Management

3.SE20

SE20->复合增强点/SCWM/ESC_MAIN,显示的所有增强即为EWM可用增强位置

总结

以上就是今天要讲的内容,本文仅仅简单介绍了EWM常用的常规开发知识,也是我在项目上积累所得,具体的开发还需上手实操。

以上是关于EWM常规开发知识汇总的主要内容,如果未能解决你的问题,请参考以下文章

EWM常规开发知识汇总

jQuery入门基础知识点汇总

Pandas 计算 ewm 是不是错误?

Python基础知识汇总(创建字典)

前后端分离项目知识汇总(开发流程,跨域,开发接口)

Spring知识汇总