SAP CRM One Order函数CREATE_OW的设计原理
In the previous series of blogs the read and update on Opportunity header fields are discussed. In this blog another scenario will be explained: create scenario on Opportunity header fields. I will again use Closing Date ( and description field ) for example. Execute the following report:
REPORT ZORDER_CREATE.
DATA: lt_input_fields TYPE crmt_input_field_tab,
ls_input_field LIKE LINE OF lt_input_fields,
ls_field_name LIKE LINE OF ls_input_field-field_names,
lv_guid TYPE guid_16,
lt_orderadm_h_com TYPE crmt_orderadm_h_comt,
ls_orderadm_h_com LIKE LINE OF lt_orderadm_h_com,
ls_com_structure TYPE string,
lv_selection_needed TYPE crmt_boolean,
lt_save TYPE crmt_object_guid_tab,
lt_saved TYPE crmt_return_objects,
lt_opp_h TYPE CRMT_OPPORT_H_COMT,
ls_opp_h LIKE LINE OF lt_opp_h,
ls_saved LIKE LINE OF lt_saved.
START-OF-SELECTION.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = lv_guid.
PERFORM call_order_maintain.
PERFORM call_order_save.
FORM call_order_maintain.
CLEAR: ls_orderadm_h_com, ls_input_field, lt_input_fields.
ls_orderadm_h_com-guid = lv_guid.
ls_orderadm_h_com-description = 'created by code on:' && sy-timlo.
ls_orderadm_h_com-process_type = 'OPPT'.
ls_orderadm_h_com-mode = 'A'.
APPEND ls_orderadm_h_com TO lt_orderadm_h_com.
ls_input_field-ref_guid = lv_guid.
ls_input_field-ref_kind = 'A'.
ls_input_field-objectname = 'ORDERADM_H'.
ls_field_name-fieldname = 'DESCRIPTION'.
APPEND ls_field_name TO ls_input_field-field_names.
ls_field_name-fieldname = 'MODE'.
APPEND ls_field_name TO ls_input_field-field_names.
ls_field_name-fieldname = 'PROCESS_TYPE'.
APPEND ls_field_name TO ls_input_field-field_names.
APPEND ls_input_field TO lt_input_fields.
ls_opp_h-ref_guid = lv_guid.
ls_opp_h-expect_end = '20170401'.
APPEND ls_opp_h TO lt_opp_h.
CLEAR: ls_input_field.
ls_input_field-ref_guid = lv_guid.
ls_input_field-ref_kind = 'A'.
ls_input_field-objectname = 'OPPORT_H'.
APPEND 'EXPECT_END' TO ls_input_field-field_names.
APPEND 'STARTDATE' TO ls_input_field-field_names.
INSERT ls_input_field INTO TABLE lt_input_fields.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
IT_OPPORT_H = lt_opp_h
CHANGING
ct_orderadm_h = lt_orderadm_h_com
ct_input_fields = lt_input_fields
EXCEPTIONS
OTHERS = 99.
IF sy-subrc = 0.
WRITE:/ 'Order maintain function is done successfully.'.
ENDIF.
ENDFORM.
FORM call_order_save.
INSERT lv_guid INTO TABLE lt_save.
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = lt_save
iv_update_task_local = abap_true
iv_no_bdoc_send = abap_true
IMPORTING
et_saved_objects = lt_saved
EXCEPTIONS
document_not_saved = 1.
IF sy-subrc <> 0.
WRITE: / 'Opportunity created failed'.
ELSE.
READ TABLE lt_saved INTO ls_saved INDEX 1.
WRITE: / 'Opportunity created successfully, id: ' , ls_saved-object_id.
ENDIF.
COMMIT WORK AND WAIT.
ENDFORM.
Once executed, a new Opportunity will be created.
Just like FILL_OW, CHANGE_OW, MERGE_OW, SAVE_EC and READ_OB which are already discussed below, there are another kinds of function module responsible for creation in One Order, whose naming convention is CRM*CREATE_OW.
Execute the report in this blog via SAT to study how CREATE_OW works. Two CREATE_OW are involved in the create scenario:
(1) CRM_ORDERADM_H_CREATE_OW
(1) The main logic within this header administrative information creation function module is to create status object.
in CRM_STATUS_OBJECT_CREATE, lots of status related internal table are populated as buffer, and they will be persisted to database table by subroutineSTATUS_UPDATE once commit work is called.
Take internal table jest_buf for example, we will check whether we could find the corresponding entry for below record later in table CRM_JEST with objnr = 6C0B84B759DF1EE7848DA711530A4C22.
(2) CRM_ORDERADM_H_PUT_OB is called to put the header administrative data into corresponding object buffer:
This header administrative data does not contain any transaction specific field like Closing Date in Opportunity header, which will be handled by CRM_OPPORT_H_*_OW function module instead.
(2) CRM_OPPORT_H_CREATE_OW
From the gross execution time of this function module ( only 10 microseconds ) we can assume that no heavy logic is written within it. In fact it only inserts the following three fields to OPPORT_H object buffer and that’s all.
The left logic are done in CRM_OPPORT_H_CHANGE_OW which has already been discussed in this blog: Logic of CHANGE_OW function module in One Order.
After report is executed successfully, go to table CRM_JEST and query objnr with guid 6C0B84B759DF1EE7848DA711530A4C22, and there is indeed one entry which are created by CRM_STATUS_OBJECT_CREATE inCRM_ORDERADM_H_CREATE_OW.
You may have doubt that in this test report, Opportunity start date is not specified explicitly, why finally it has value 2017-03-24? It is hard code in CRM_OPPORT_H_MERGE_OW, if no value specified by consumer.
- Android:全面解析熟悉而陌生 的 Application 类使用
- ToggleButton和Switch使用大全
- Android 无需权限显示悬浮窗, 兼谈逆向分析 App
- android数据保存之greendao
- CheckBox和RadioButton使用大全
- 关于 Android 实现滑动返回的几种方法总结
- android 面试之listview
- 放yy直播点赞动画
- TableLayout和Viewpager实现切换
- Android 数据库框架ormlite
- SwipeRefreshLayout实现上拉下拉刷新
- 常见Button使用详解
- android Gradle的几个基本概念
- EditText的属性和使用方法
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- CodeIgniter (CI) 框架学习 -- load_class
- Laravel框架学习 -- php artisan down/up
- Spring中基于注解@AspectJ的AOP实现
- python提高--running-python-code-contained-in-a-strin
- linux shell 监控脚本 及 邮件发送
- Laravel框架学习 -- 安装
- Redis 键管理与小功能
- redis 数据持久化
- 不蒜子 | 给网站、博客文章添加阅读次数统计,我用两行代码 搞定计数
- redis 主从复制
- Spring 当一个接口多个实现时,怎么注入
- redis主从同步,显示master_link_status:down的解决思路
- CentOS自带Python被删 && YUM报错修复
- MySQL主从库--同步异常
- redis 哨兵机制