SAP CRM索引数据库表CRMD_ORDER_INDEX的更新原理-阿里云开发者社区

开发者社区> 开发者小助手-bz4> 正文

SAP CRM索引数据库表CRMD_ORDER_INDEX的更新原理

简介: SAP CRM索引数据库表CRMD_ORDER_INDEX的更新原理
+关注继续查看

For project reason I need to figure out the logic how fields in index table CRM_ORDER_INDEX are updated.

For example, I have an opportunity with ID 21 and closing date 2017.03.25.


image.pngMost of the fields in these two records have the same value except fields like PARTNER_NO, which represent the two involved parties as found in WebUI:


image.pngWhat I am curious about is: the field DATE_2 seems to store the timestamp of Closing Date 2017.03.25 as observed in WebUI. My doubt is, since WebUI only displays the date information, where does this time 22:59:59 come from?



image.pngI wrote the following simple report to change Closing Date by code:PARAMETERS: end TYPE CRMT_OPPORT_H_COM-expect_end DEFAULT '20170319'.

CONSTANTS: gv_guid TYPE crmt_object_guid VALUE '6C0B84B759DF1ED6BDF05763B3DC8841'.

DATA: lt_opport_h    TYPE crmt_opport_h_comt,

     ls_opport_h    LIKE LINE OF lt_opport_h,

     lt_change      TYPE crmt_input_field_tab,

     ls_change      LIKE LINE OF lt_change,

     lt_saved       TYPE crmt_return_objects,

     lt_exception   TYPE crmt_exception_t,

     lt_to_save     TYPE crmt_object_guid_tab,

     lt_not_to_save TYPE crmt_object_guid_tab.

ls_opport_h-ref_guid = gv_guid.

ls_opport_h-expect_end = end.

ls_change = VALUE #( ref_guid = gv_guid ref_kind = 'A' objectname = 'OPPORT_H' ).

APPEND 'EXPECT_END' TO ls_change-field_names.

APPEND ls_change TO lt_change.

APPEND ls_opport_h TO lt_opport_h.

CALL FUNCTION 'CRM_ORDER_MAINTAIN'

 EXPORTING

   it_opport_h       = lt_opport_h

 CHANGING

   ct_input_fields   = lt_change

 EXCEPTIONS

   error_occurred    = 1

   document_locked   = 2

   no_change_allowed = 3

   no_authority      = 4.

APPEND gv_guid TO lt_to_save.

CALL FUNCTION 'CRM_ORDER_SAVE'

 EXPORTING

   it_objects_to_save   = lt_to_save

   iv_update_task_local = abap_true

 IMPORTING

   et_saved_objects     = lt_saved

   et_exception         = lt_exception

   et_objects_not_saved = lt_not_to_save

 EXCEPTIONS

   document_not_saved   = 1.

WRITE: / sy-subrc.

COMMIT WORK AND WAIT.The SAT trace shows clearly that the index table will also be updated during order save:image.pngThe main logic of CRM_ORDER_INDEX_SAVE

(1) call order header from object buffer and DB buffer separately via CRM_ORDERADM_H_READ_OB and CRM_ORDERADM_H_READ_DB to check whether there is really header change.

(2) get old index data from DB via CRM_ORDER_INDEX_SELECT_DB.

(3) transfer the latest order data from object buffer to index buffer.

This is done in subroutine fill_data.

Before subroutine is executed, date_1 is initial:


image.pngAfter execution, date_1 is filled with data now. So I can find answer how date_1 is populated later by debugging into fill_data subroutine.image.png(4) The change mode ( insert, update or delete ) is evaluated in subroutine fill_update_tables by comparing the latest change stored in lt_index_ob ( object buffer ) and original data from DB, lt_index_db.


In this example the determined result is that two records ( stored in table lt_index_update ) must be updated. The comparison logic is described in blog Logic of SAVE_EC function module in One Order.

The real database update is done in update function module CRM_ORDER_INDEX_UPDATE_DU.


image.pngClosing Date update logic in CRMD_ORDER_INDEX-DATE_2

It is easy to find the logic by debugging into subroutine fill_data.


The Closing Date in WebUI is stored in CRMD_OPPORT_H-EXPECT_END.


image.pngThe time of Closing Date is hard coded as 235959 and converted to timestamp based on time zone configured in the backend.image.pngimage.pngFurther reading

I have written a series of blogs to explain how One Order API works. The blogs are written based on a simple scenario: read, change and save field “Closing Date” in Opportunity header level.


Buffer logic in One Order header extension Read


Change Scenario


CRM_ORDER_MAINTAIN


|- CRM_ORDER_MAINTAIN_MULTI_OW


|- CRM_ORDER_MAINTAIN_SINGLE_OW


|- CRM_ORDER_H_MAINTAIN_OW


|- CRM_OPPORT_H_MAINTAIN_OW


|- CRM_OPPORT_H_CHANGE_OW


|- CRM_OPPORT_H_READ_OB


|- CRM_OPPORT_H_FILL_OW


|- CRM_OPPORT_H_CHECK_OW


|- CRM_OPPORT_H_PUT_OB


|- CRM_OPPORT_H_PUBLISH_OW


Save Scenario


CRM_ORDER_SAVE


|- CRM_ORDER_SAVE_OW


|- CRM_EVENT_SET_EXETIME_MULTI_OW


|- CRM_OPPORT_H_SAVE_EC


|- CRM_ORDER_TABLE_SAVE


|- CRM_OBJECT_NAMES_DETERMINE


|- CRM_ORDER_UPDATE_TABLES_DETERM


|- CRM_ORDER_SET_OBJECTS_TO_SAVE


CRM_OPPORT_H_UPDATE_DU


Create Scenario


CRM_ORDER_MAINTAIN


|- CRM_ORDER_MAINTAIN_MULTI_OW


|- CRM_ORDER_MAINTAIN_SINGLE_OW


|- CRM_ORDER_H_MAINTAIN_OW


|- CRM_ORDERADM_H_MAINTAIN_OW


|- CRM_ORDERADM_H_CREATE_OW


|- CRM_OPPORT_H_MAINTAIN_OW


|- CRM_OPPORT_H_READ_OB


|- CRM_OPPORT_H_CREATE_OW


|- CRM_OPPORT_H_CHANGE_OW


Index table CRMD_ORDER_INDEX and its update logic


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
阿里云服务器怎么设置密码?怎么停机?怎么重启服务器?
如果在创建实例时没有设置密码,或者密码丢失,您可以在控制台上重新设置实例的登录密码。本文仅描述如何在 ECS 管理控制台上修改实例登录密码。
10018 0
日志服务(SLS)支持历史数据索引重建(Index Rebuild)
日志服务提供索引重建功能,针对历史数据索引未配置、配置错误或遗漏等问题,一步完成对历史数据的索引重构
1357 0
Oracle sql 调优:使用虚拟索引在生产环境测试创建索引对数据库性能的影响
虚拟索引是一种“假”索引,其定义存在于数据字典中,但不具有相应的索引段,也就是不会分配任何存储空间。
557 0
阿里云服务器如何登录?阿里云服务器的三种登录方法
购买阿里云ECS云服务器后如何登录?场景不同,阿里云优惠总结大概有三种登录方式: 登录到ECS云服务器控制台 在ECS云服务器控制台用户可以更改密码、更换系.
13819 0
通过DBCC整理Sqlserver数据库表索引碎片
昨天检查了一张效率极慢的表,两年多没有维护,逻辑扫描碎片高达99.81%,于是开始对这个表进行重点跟踪和记录日志。今天用DBCC SHOWCONTIG WITH TABLERESULTS 命令检查了一下所有表的概况,然后参照着MSDN对字段的说明,发现问题比较严重。
948 0
数据库查询索引(sql单个索引和复合索引)
数据库查询索引(sql单个索引和复合索引) 当一条sql语句的查询涉及到多个字段,这个时候给每个字段加索引,数据库也只能够使用其中的一个索引,这个时候使用复合索引就比较好了。这是为什么呢? 这是因为:全表扫描/只使用一个索引的速度比起来,去分析两个索引二叉树更加耗费时间,所以绝大多数情况下数据库都是是用一个索引。
1808 0
数据库索引,到底是什么做的?
近期写数据库,不少朋友留言问MySQL索引底层的实现,今天简单聊一聊,少讲“是怎么样”,更多说说“为什么设计成这样”。
400 0
2315
文章
0
问答
来源圈子
更多
+ 订阅
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载