首页 > SAP EWM 代码实现Transportation Unit(TU)的创建

SAP EWM 代码实现Transportation Unit(TU)的创建

在EWM中很少有创建或者修改业务对象的BAPI存在,更多的是通过很多面向对象的类方法来实现。

以下这个简单的创建TU应该能很好的体现SCM平台中的OO特性。

REPORT yewm_tu_creation NO STANDARD PAGE HEADING.

TYPES:

  BEGIN OF lty_key_wrk,

    tu_num                 TYPE /scwm/de_tu_num,

    tu_sr_act_num  TYPE /scwm/de_tu_sr_act_num,

  END OF lty_key_wrk.

DATA:

  lo_tu_sp                    TYPE REF TO                 /scwm/cl_ui_tu_sp,

  lt_aspect                   TYPE                                /scwm/tt_asp_tu,

  ls_aspect                   TYPE                                /scwm/s_asp_tu,

  lt_aspect_o              TYPE                                /scwm/tt_asp_tu,

  lt_return_codes     TYPE                                /scmb/t_sp_return_code,

  lv_rejected                             TYPE                                char01,

  lo_attr_hndl             TYPE REF TO                 /scmb/cl_attribute_handler,

  lo_msg_hndl            TYPE REF TO                 /scmb/cl_message_handler,

  ls_key_wrk      TYPE                               lty_key_wrk,

  lt_key_wrk      TYPE TABLE OF           lty_key_wrk.

 

START-OF-SELECTION.

  "创建TU对象

  CREATE OBJECT:

    lo_attr_hndl,

    lo_msg_hndl,

    lo_tu_sp               EXPORTING     io_attribute_handler = lo_attr_hndl

                                    io_message_handler = lo_msg_hndl.

 

  ls_aspect-act_dir                 = "1" inbound / "2" outbound —Direction of Shipping and Receiving Activity

  ls_aspect-start_act_d        = sy-datum.

  ls_aspect-start_act_t         = sy-uzeit.

  ls_aspect-end_act_d          = sy-datum.

  ls_aspect-end_act_t           = '235959'.

  ls_aspect-mtr                        = Means of Transport

  ls_aspect-pmat                     = TU Packaging Material

  APPEND ls_aspect TO lt_aspect.

  CLEAR ls_aspect.

             

  "通过INSERT方法来创建TU

  lo_tu_sp->insert(   EXPORTING     inrecords         = lt_aspect

                                     aspect               = '/SCWM/S_ASP_TU'

IMPORTING    outrecords      = lt_aspect_o

                                     rejected            = lv_rejected

                                     return_codes = lt_return_codes ).

  READ TABLE lt_return_codes TRANSPORTING NO FIELDS WITH KEY failed = abap_true.

  IF sy-subrc = 0 OR lv_rejected = abap_true.

    "ERROR

  ELSE.

    READ TABLE lt_aspect_o INTO ls_aspect INDEX 1.

    IF sy-subrc = 0.

      ls_key_wrk-tu_num                             = ls_aspect-tu_num.

      ls_key_wrk-tu_sr_act_num              = ls_aspect-tu_sr_act_num.

      APPEND ls_key_wrk TO lt_key_wrk.

      CLEAR: ls_key_wrk, ls_aspect.

ENDIF.

"保存并提交

    lo_tu_sp->save( ).

    COMMIT WORK AND WAIT.

  ENDIF.

 

  "激活TU对象

  /scwm/cl_sr_bom=>cleanup( ).

  TRY.

      /scwm/cl_sr_my_service=>switch_tu_active(

        EXPORTING

          iv_lgnum             = 仓库号

          it_aspk_tu          = lt_key_wrk

        IMPORTING

          ev_rejected       = lv_rejected ).

      IF lv_rejected = abap_true.

        "ERROR

      ELSE.

        lo_tu_sp->save( ).

        COMMIT WORK AND WAIT.

      ENDIF.

    CATCH /scwm/cx_sr_error.

  ENDTRY.

转载于:https://www.cnblogs.com/d0mi/archive/2013/05/07/3064892.html

更多相关:

  • 001.删除不以特定字符串结尾的文件 1.) rm -f `ls | grep -v '.c$'`(删除所有的非c源文件: ls前面" ' "为反向引号, 键盘1前面的键; "." 需要转义) 转载于:https://www.cnblogs.com/itpoorman/p/3858611.html...

  •   测试用prototxt   name: "CIFAR10_quick"layer {name: "data" type: "MemoryData" top: "data" top: "label" memory_data_param {batch_size: 1     #样本个数 channels: 3 height: 32 w...

  •    话说每到吃完的时间就发愁,真的不知道该吃什么,然后就想到做一个生成吃什么的小软件,既然这个软件如此的简单,就打算用wpf开发吧,也不用数据库了,直接保存在xml中就可以了  程序整体结构如下图  首先我写了一个xml的帮助类,主要是写了个常用的增加方法 主程序界面也很简单,一共就两个页面 对应的两处代码也粘上 pr...