SAP S/4HANA Customer Management(CRM)模組的Partner模型設計

i042416發表於2020-09-02

In SAP CRM we can maintain multiple business partners with different partner functions to an order header or item level. This from technical point of view means the relationship of root object(header or item) to the records of Partner component is 1:N. As a result we can Partner component as “complex set” in One Order model.

Take the following Service Order for example. Suppose I could like to read all its header partners by CRM_ORDER_READ:


SAP S/4HANA Customer Management(CRM)模組的Partner模型設計


The code is exactly the same as written in SAP CRM:

REPORT zread.DATA: lt_guid       TYPE crmt_object_guid_tab,
      lv_id         TYPE crms4d_btx_h-object_id VALUE '8000000362',
      lt_partner    TYPE crmt_partner_external_wrkt.SELECT SINGLE guid INTO @DATA(guid) FROM crms4d_btx_h WHERE object_id = @lv_id.APPEND guid TO lt_guid.CALL FUNCTION 'CRM_ORDER_READ'
  EXPORTING
    it_header_guid = lt_guid
  IMPORTING
    et_partner     = lt_partner.SELECT * INTO TABLE @DATA(lt_partner_fct) FROM crmc_partner_ft AS a
   FOR ALL ENTRIES IN @lt_partner WHERE a~partner_fct = @lt_partner-partner_fct AND
  spras = @sy-langu.LOOP AT lt_partner ASSIGNING FIELD-SYMBOL(<partner>) WHERE ref_kind = 'A'.
  READ TABLE lt_partner_fct ASSIGNING FIELD-SYMBOL(<fct>) WITH KEY partner_fct =
   <partner>-partner_fct.
  IF sy-subrc = 0.
    WRITE:/ |Partner No: { <partner>-partner_no }, 'Role:' { <fct>-description }| COLOR COL_GROUP.
  ENDIF.ENDLOOP.

The report output just matches what we observe in WebClient UI assignment block “Parties Involved”.


SAP S/4HANA Customer Management(CRM)模組的Partner模型設計


If we check the flat table CRMS4D_SERV_H for Service document header data, we can only find the partner ID of corresponding role.


SAP S/4HANA Customer Management(CRM)模組的Partner模型設計 SAP S/4HANA Customer Management(CRM)模組的Partner模型設計


The detail information of each kind of partners are stored in table CRMS4D_PARTNER instead.

As a result if we directly read from CRMS4D_PARTNER, we can get exactly the same output as reading from function module CRM_ORDER_READ.

REPORT z_crms4d_partner.DATA: lt_guid    TYPE crmt_object_guid_tab,
      lv_id      TYPE crms4d_btx_h-object_id VALUE '8000000362',
      lt_partner TYPE TABLE OF crms4d_partner.SELECT * INTO TABLE lt_partner FROM crms4d_partner WHERE object_id = lv_id AND number_int = 0.SELECT * INTO TABLE @DATA(lt_partner_fct) FROM crmc_partner_ft AS a
   FOR ALL ENTRIES IN @lt_partner WHERE a~partner_fct = @lt_partner-partner_fct AND
  spras = @sy-langu.LOOP AT lt_partner ASSIGNING FIELD-SYMBOL(<partner>).
  READ TABLE lt_partner_fct ASSIGNING FIELD-SYMBOL(<fct>) WITH KEY partner_fct =
   <partner>-partner_fct.
  IF sy-subrc = 0.
    WRITE:/ |Partner No: { <partner>-partner_id }, 'Role:' { <fct>-description }| COLOR COL_GROUP.
  ENDIF.ENDLOOP.

In fact if you set a breakpoint on COM_PARTNER_SELECT_M_DB, you can find out that indeed CRM_ORDER_READ internally reads all partners belonging to a Service document HEADER with the where statement in code below from line 71 to 73. Records in CRMS4D_PARTNER with number_int = 0 represents the partners of header level, and those with number_int > 0 for partners of item level.


SAP S/4HANA Customer Management(CRM)模組的Partner模型設計


So next question is: when, where and how the records in CRMS4D_PARTNER are stored? Execute the report mentioned in my blog  Create Mass Service document in S/4HANA for Customer Management to create a service order with Sold to party specified:


SAP S/4HANA Customer Management(CRM)模組的Partner模型設計


The created partner data are persisted via function call COM_PARTNER_SAVE_OB, which has been adapted to call new function module designed for S/4HANA: CRMS4_PARTNER_UPDATE_DU


SAP S/4HANA Customer Management(CRM)模組的Partner模型設計


You might have observed that although only Sold to party ID is specified by my report, still totally six partners with different party roles are populated. all other five roles are determined by standard partner determination logic which is the same as in SAP CRM.


SAP S/4HANA Customer Management(CRM)模組的Partner模型設計


It is still possible for customers to define their own partner functions in S/4HANA for Customer Management, whose details will be introduced in a separate blog.

Jerry’s other blogs on S/4HANA for Customer Management

要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":

SAP S/4HANA Customer Management(CRM)模組的Partner模型設計


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2716716/,如需轉載,請註明出處,否則將追究法律責任。

相關文章