zoukankan      html  css  js  c++  java
  • SAP S/4HANA Customer Management(CRM)模块的Partner模型设计

    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:

    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”.

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


    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.

    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:

    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

    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.

    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的原创文章,请关注公众号"汪子熙":

  • 相关阅读:
    代码外的软技能——吉他自学过程
    利用栈实现括号匹配(python语言)
    django框架--登录注册功能(ajax)
    ajax的get请求
    docker 制作自己的镜像
    Mysql group by之 Error 1055
    ssh 远程连接
    python实现--九九乘法表
    mysql5.7安装和卸载过程
    javascript随机变色--案例
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/13598824.html
Copyright © 2011-2022 走看看