Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

New Attribute for Lead Distribution

Hi Everyone,

I would like to distribute the lead based on customer group which has maintained in Customer Master

It is not available when I check the attribute for customer group in Lead Context.

Path to find the available attribute in Rule Distribution:

SPRO > CRM > Transactions > Settings for Leads > Rule-Based Distribution > Define Repository

Can anyone help on this to add new attribute : Customer Group

Please help me in providing values for Customer Group to the respect

XPath Expr

Fact Gathering Srvc

Attrib. Ext. Class

Regards

Raju

Former Member
Former Member replied

Hi Raju,

Please follow below step -

1. Create a copy of CL_CRM_DD_FG_LEAD  as ZCL_CRM_DD_FG_LEAD_CUST

2. Change code in method -> IF_CRM_ERMS_SERVICE~EXECUTE of class- Similar as below

METHOD if_crm_erms_service~execute.

   DATAlv_act_document   TYPE crmt_object_guid,

          xml_chunk         TYPE string,

          lt_header_guid    TYPE crmt_object_guid_tab,

          ls_lead_h         TYPE crmt_lead_h_wrk,

          lt_lead_h         TYPE crmt_lead_h_wrkt,

          ls_partner         TYPE  crmt_partner_external_wrk,

          lv_customer_group   TYPE c LENGTH 2, " Customer Group

          lt_partner         TYPE  crmt_partner_external_wrkt.

   CALL METHOD service_manager->get_context_entry

     EXPORTING

       name  = cl_crm_dd_con=>gc_erms_context_act_document

     IMPORTING

       value = lv_act_document.

   IF lv_act_document IS INITIAL.

     RAISE EXCEPTION TYPE cx_crm_erms_service_failed.

   ENDIF.

   APPEND lv_act_document TO lt_header_guid.

   CALL FUNCTION 'CRM_ORDER_READ'

     EXPORTING

       it_header_guid       = lt_header_guid

       iv_mode              = 'C'   "DISPLAY

     IMPORTING

       et_lead_h            = lt_lead_h

       et_partner           = lt_partner

     EXCEPTIONS

       document_not_found   = 1

       error_occurred       = 2

       document_locked      = 3

       no_change_authority  = 4

       no_display_authority = 5

       no_change_allowed    = 6

       OTHERS               = 7.

   IF sy-subrc <> 0.

     RAISE EXCEPTION TYPE cx_crm_erms_service_failed.

   ENDIF.

   CLEAR ls_partner.

   LOOP AT lt_partner INTO ls_partner WHERE  ref_kind    = 'A'

                                       AND   partner_fct = '00000001'. "Sold-To Party

   ENDLOOP.

   IF ls_lead_h IS INITIAL AND ls_partner-partner_no IS INITIAL.

     RAISE EXCEPTION TYPE cx_crm_erms_service_failed.

   ENDIF.

   CLEAR lv_customer_group.

   "Get Customer Group  from  CRMV_BP_FRG0030

   SELECT SINGLE customer_group  FROM crmv_bp_frg0030 INTO lv_customer_group WHERE partner_guid = ls_partner-partner_no(16).

   CONCATENATE

     '<zcustomergroup><![CDATA[' lv_customer_group   ']]></zcustomergroup>'

       INTO xml_chunk SEPARATED BY space.

   service_manager->factbase->add_snippet( xml_chunk ).

ENDMETHOD.

3. Define Fact service for new attribute refer below -

4. Define Xpath for attribute in Repository under Lead destritbution context DD_LEAD for attribute.


Hope this helps.


Regards,

Arjun


1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question