zoukankan      html  css  js  c++  java
  • SAP CRM订单模型CRMD_SHIPPING的单元测试方法

    For example the following shipping fields of One order document are stored in Database table CRMD_SHIPPING.

    The data could be read out via function module CRM_SHIPPING_READ_OB.

    This blog introduces the step how to generate fake data which will be returned by function module CRM_SHIPPING_READ_OB for unit test purpose.

    Step1. Create fake data in Shipping object buffer

    DATA: ls_shipping TYPE crmt_shipping_wrk.
    DATA: lv_order_guid TYPE crmt_object_guid,
          lv_ship_guid  LIKE lv_order_guid,
          lt_link_com   TYPE crmt_link_comt,
          ls_link_com   LIKE LINE OF lt_link_com.
    
    CALL FUNCTION 'GUID_CREATE'
      IMPORTING
        ev_guid_16 = lv_order_guid.
    CALL FUNCTION 'GUID_CREATE'
      IMPORTING
        ev_guid_16 = lv_ship_guid.
    ls_shipping-incoterms1 = 'FOB'.
    ls_shipping-incoterms2 = 'Jerry Fake incoterms'.
    ls_shipping-guid = lv_ship_guid.
    
    CALL FUNCTION 'CRM_SHIPPING_PUT_OB'
      EXPORTING
        is_shipping_wrk = ls_shipping.
    

    Step2. Create a link between Order and shipping data via function module CRM_LINK_CREATE_OW

    ls_link_com-guid_hi     = lv_order_guid.
    ls_link_com-guid_set    = lv_ship_guid.
    ls_link_com-objname_set = 'SHIPPING'.
    ls_link_com-objtype_set = '12'.
    ls_link_com-objname_hi  = 'ORDERADM_H'.
    ls_link_com-objtype_hi  = '05'.
    
    INSERT ls_link_com INTO TABLE lt_link_com.
    CALL FUNCTION 'CRM_LINK_CREATE_OW'
      EXPORTING
        iv_guid_hi = lv_order_guid
        it_link    = lt_link_com
      EXCEPTIONS
        OTHERS     = 0.
    

    Step3. perform read via Object buffer function call

    CLEAR: ls_shipping.
    
    CALL FUNCTION 'CRM_SHIPPING_READ_OB'
      EXPORTING
        iv_ref_guid         = lv_order_guid
        iv_ref_kind         = 'A'
      IMPORTING
        es_shipping_wrk = ls_shipping.
    
    WRITE:/ 'Incoterms1:', ls_shipping-incoterms1.
    WRITE:/ 'Incoterms2:', ls_shipping-incoterms2.
    

    Callstack of link manipulation and object buffer insert and read for Shipping.

    execution result:


    rry的原创文章,请关注公众号"汪子熙":

  • 相关阅读:
    c# 测试篇之Linq性能测试
    F# 笔记
    c# DataSource和BindingSource
    .net中配置的保存格式笔记
    泛型约束(转)
    c# 调用showDialog后需要Dispose
    c# 实现ComboBox自动模糊匹配
    c# 二进制或算法实现枚举的HasFlag函数
    C# WinForm自定义控件整理
    微软中文MSDN上的一些文章链接
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/13549092.html
Copyright © 2011-2022 走看看