Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to apply Observer pattern in One Order callback function

Shulou Source: shulou.com Published: 2022-05-31 15:43:27 09月21日 Update

This article introduces the knowledge of "how to apply the Observer pattern in the One Order callback function". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The requirement, for example, is to figure out in what scenarios function module CRM_PRODUCT_I_A_CHANGE_ORGM_EC will be called. Of course, the most time-consuming thing to do is to set a breakpoint, and then run the corresponding scene to see when the breakpoint is triggered. There is another method of analysis that does not pass debugging:

Using the transaction code CRMV_EVENT, enter the function name CRM_PRODUCT_I_A_CHANGE_ORGM_EC:

The results are obtained:

The business implication of the above result is that whenever the Sales area is created or updated, the function module we query will be automatically called by the One Order framework.

Observe the call stack as follows:

So why do you need to call this callback function whenever the Organization Model organizational structure data for an order changes? Open the source code of this function and see one of the settype of CRM Product, CRMM_PR_SALESG (Set type allowing you to group products for various purposes. As this set type is dependent on distribution chains, a distribution chain has to be selected before data can be maintained) data is read.

For more information about this settype, please refer to SAP Help.

This settype is a Distribution Chain-related settype, and it makes no sense to leave a specific Sales area.

Therefore, whenever the Organization model data of the order changes, the CRMM_PR_SALESG data must be re-read according to the latest Organization model data after the change. With the One Order framework, this Organization model change and CRMM_PR_SALESG reading dependency is actually accomplished through the "observer pattern" in the design pattern. CRM_PRODUCT_I_A_CHANGE_ORGM_EC is one of the many observers of Organization model data changes, subscribing to the event of Organization model data changes through the transaction code CRMV_EVENT. Whenever there is a change in Organization model data, the change is posted through the CRM_EVENT_PUBLISH_OW in the figure below, and other observers can deal with it based on the events published by this publisher. In this example of my article, CRM_PRODUCT_I_A_CHANGE_ORGM_EC is called to read settype CRMM_PR_SALESG data according to the latest Organization model.

This is the end of the content of "how to apply the Observer pattern in the One Order callback function". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Data change observation function observer pattern more application business event transaction content scenario actual article breakpoint framework knowledge result order Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Docker Linux Shulou Technology Apple