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.
【crm|SAP CRM订单模型CRMD_SHIPPING的单元测试方法】
文章图片
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_guidLIKE lv_order_guid,
lt_link_comTYPE crmt_link_comt,
ls_link_comLIKE 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:
文章图片
推荐阅读
- SAP|【测试】工艺路线展开Function
- SAP|【转载】增强中调用BAPI并COMMIT使用
- SAP|SAP 主生产计划(MPS)
- SAP|MPS(主生产计划)
- 03|以客户为中心 解读SSA Global产品战略
- MPS与MRP的区别
- sap|使用事物码SAT检测SAP CRM中间件的传输性能
- sap|如何使用SAP CRM中间件从ERP往CRM下载Service Master
- crm|SAP CL_CRM_BOL_ENTITY单元测试方法
- crm|显示SAP CRM Product hierarchy的一个小工具