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


相关文章
|
2月前
|
监控 NoSQL MongoDB
MongoDB数据库的索引管理技巧
【8月更文挑战第20天】MongoDB数据库的索引管理技巧
48 1
|
2月前
|
数据库 索引
如何优化数据库索引?
【8月更文挑战第14天】如何优化数据库索引?
52 4
|
2月前
|
存储 安全 数据库
数据库的索引都有哪些类型?如何选择?
【8月更文挑战第17天】数据库的索引都有哪些类型?如何选择?
57 0
|
4天前
|
监控 关系型数据库 MySQL
如何优化MySQL数据库的索引以提升性能?
如何优化MySQL数据库的索引以提升性能?
13 0
|
4天前
|
监控 关系型数据库 MySQL
深入理解MySQL数据库索引优化
深入理解MySQL数据库索引优化
11 0
|
2月前
|
存储 缓存 负载均衡
【PolarDB-X 技术揭秘】Lizard B+tree:揭秘分布式数据库索引优化的终极奥秘!
【8月更文挑战第25天】PolarDB-X是阿里云的一款分布式数据库产品,其核心组件Lizard B+tree针对分布式环境优化,解决了传统B+tree面临的数据分片与跨节点查询等问题。Lizard B+tree通过一致性哈希实现数据分片,确保分布式一致性;智能分区实现了负载均衡;高效的搜索算法与缓存机制降低了查询延迟;副本机制确保了系统的高可用性。此外,PolarDB-X通过自适应分支因子、缓存优化、异步写入、数据压缩和智能分片等策略进一步提升了Lizard B+tree的性能,使其能够在分布式环境下提供高性能的索引服务。这些优化不仅提高了查询速度,还确保了系统的稳定性和可靠性。
61 5
|
2月前
|
消息中间件 Kafka 数据库
深入理解Kafka的数据一致性原理及其与传统数据库的对比
【8月更文挑战第24天】在分布式系统中,确保数据一致性至关重要。传统数据库利用ACID原则保障事务完整性;相比之下,Kafka作为高性能消息队列,采用副本机制与日志结构确保数据一致性。通过同步所有副本上的数据、维护消息顺序以及支持生产者的幂等性操作,Kafka在不牺牲性能的前提下实现了高可用性和数据可靠性。这些特性使Kafka成为处理大规模数据流的理想工具。
47 6
|
2月前
|
数据库 索引
数据库索引的作用和优点缺点
【8月更文挑战第27天】创建索引能显著提升系统性能,确保数据唯一性,加快检索速度,加速表间连接及优化分组排序过程。然而,过度使用索引会导致创建与维护成本增加、占用更多物理空间并降低数据维护效率。因此,在创建索引时需谨慎评估需求及影响。
33 2
|
2月前
|
数据库 索引
数据库索引的作用和优点缺点
创建索引能显著提升系统性能,确保数据唯一性,加快检索速度,加速表间连接及优化分组排序过程。然而,过度使用索引会导致创建与维护成本增加、占用更多物理空间并降低数据维护效率。因此,在创建索引时需谨慎评估需求及影响。
31 2
|
2月前
|
监控 数据库 索引
如何优化数据库索引?
【8月更文挑战第23天】如何优化数据库索引?
39 4
下一篇
无影云桌面