POC of settype read harmonization - using description settype as example

167 阅读2分钟

Background introduction

In CRM WebUI, Genil layer will call CRM PRODUCT API CRM_PRODUCT_GETDETAIL_API to retrieve data from database table.

For example, in order to display the description data in WebUI assignment block, settype ID “COMM_PR_SHTEXT” must be passed to parameter IT_REQ_SETTYPES of CRM_PRODUCT_GETDETAIL_API, which will delegate the call to COM_PRODUCT_GETDETAIL_INTERNAL .

In Codeployment scenario, customer will create material in tcode MM01, as a result there will be NO entry for created material in table COMM_PRODUCT. So, verification is needed to check whether the existing logic described above can still work. On the other hand, now the S4 material text read API should finally be called instead.

In summary, a POC is built to check the scenario which should fulfill the following two requirements:

  1. The material description read should still work although no corresponding entry exists in table COMM_PRODUCT
  2. The S4 Material text read API should be used instead

POC Introduction

POC detail: Q3R/111, execute the following method directly. It will use CRM API to trigger description read, and finally the read will be dispatched to S4 text read API instead.

The dispatch works because a new function module is configured in settype administrative table COMC_SETTYPE as read operation for settype COMM_PR_SHTEXT in Q3R/111.

According to Carsten’s slide, we should ensure the description read against other product type ( Financing, Service and IP product ) still works in codeployment scenario. As a result we should have a switch logic based on product type.

Inside this method ( class ZCL_ERP_MARA_TOOL, method GET_DESCRIPTION ) , the switch is done below:

Test Result

Before you test POC, please execute this method first:

Test is ok. The description maintained in tcode MM02 could successfully be retrieved by CRM_PRODUCT_GETDETAIL_API:

Jerry’s concern

In COM_PRODUCT_GETDETAIL_INTERNAL, before dedicated read function module for each settype is called, there is a product anchor check against product guid. If check fails, the following settype read via dedicated read function module will never be executed.

In codeployment scenario, this anchor read will fail, since now there is no entry for given product guid in table comm_product, and thus these two internal buffers are empty.

In order to deal with this issue, my solution is to manually fill these two buffers using COM API COM_PRODUCT_CREATEM and COM_PRODUCT_MAINTAIN_SET_CC . The source code could be found from ZCL_ERP_MARA_TOOL~CREATE_ANCHOR_CACHE in Q3R/111. The source code is also listed here:

method CREATE_ANCHOR_CACHE.
rs_cache-PRODUCT_GUID = iv_prod_guid.
rs_cache-PRODUCT_ID = 'I042416'.
rs_cache-product_type = '01'.
CALL FUNCTION 'COM_PRODUCT_CREATEM'
CHANGING
CS_PRODUCT = rs_cache.
CALL FUNCTION 'COM_PRODUCT_MAINTAIN_SET_CC'
EXPORTING
IV_ACTIVE_PRODUCT_GUID = rs_cache-PRODUCT_GUID
IV_INACTIVE_PRODUCT_GUID = rs_cache-PRODUCT_GUID
IV_ACTIVE_EXISTS = abap_true
IV_INACTIVE_EXISTS = abap_false
EXCEPTIONS
DOUBLE_ENTRIES = 1
OTHERS = 2.
assert SY-SUBRC = 0.
endmethod.

This solution works however I have one concern: will this manual buffer manipulation lead to any side effect ? Since I do not have expertise on AP-MD-PRO, I need to ask related expert for confirmation.

Problematic scenario

Suppose we open Material A whose header data is stored in MARA now. Using the approach described in this wiki, in WebUI when customer opens the description assignment block, one entry with ID A is inserted into buffer.
Later, customer opens another product B with type “02” for example, and makes some changes and clicks save button. At this time, how will the buffer for Material A be handled?
要获取更多Jerry的原创文章,请关注公众号"汪子熙":