Synchronize CRM Mapping Tables in SAP S/4 HANA and SAP CRM from SAP MDG
In most of the implementations, there are Business Scenarios where SAP MDG needs to be implemented as a Standalone system (Acting as a Hub) to perform Master Data Creations, Change and Replications.
This blog is to all those who needs assistance into a smooth journey to perform Synchronization of Mapping Tables (CRM Tables) between SAP MDG, SAP S/4 HANA and SAP CRM Systems for Business Partners.
Business Scenario/Use Case
CRM Prospect are send to MDG to convert to Sold-To. MDG create the Business Partners through Change Request followed by compliance approval process (Organization & Contact) and replicate to SAP S/4 HANA/CRM system using DRF Framework.
To enable the exchange of transactional data as quotations and price lists between CRM and S/4, four tables need be in synchronization:
- SAP S/4 HANA Side: CRMKUNNR & CRMPARNR
- CRM Side: CRMM_BUT_CONTNO & CRMM_BUT_CUSTNO
Business Partners (Customer & Contacts) replicated from MDG to CRM and SAP S/4 HANA are utilized in CRM and SAP S/4 HANA to enable Procurement activities (Order creation, Sales Quote generation, Price information, etc). The replication involves sending Customer & Contact BP details created in MDG to CRM and SAP S/4 HANA system.
SAP S/4 HANA and CRM generates separate BP Numbers based on the defined Number ranges.
In such scenarios the SAP S/4 HANA Partner Number (Contact Person/User) is different than the MDG Contact Person number and this information is required in CRM to process any Orders sent from SAP S/4HANA through Order interfaces.
Similarly, when CRM sends Sales Quotes to SAP S/4 HANA, CRM sends CRM GUID ID as a Primary key to uniquely identify the Quote information. A typical SAP S/4 HANA system does not receive a CRM GUID ID during BP replication from MDG
(GUID ID is a uniquely generated 32 digit alpha numberic number used to identify the Source and receiver systems. This is also part of the concept used in SOA based Web Services where each message has a unique identity while processing in the system.)
CRMKUNNR & CRMM_BUT_CONTNO – These tables store the Client #, CRM GUID ID and BP ID
CRMPARNR & CRMM_BUT_CUSTNO – These tables store the CRM GUID ID, SAP S/4 HANA Partner GUID ID and SAP S/4 HANA Partner ID
CRM and SAP S/4 HANA uses the above tables to validate or verify Customer information during transactional data interfacing.
There are 2 different approaches to implement the solution:
- Using Standard BADI Activation and additional configurations
- Build a Custom Web Service/RFC Program using Mapping API’s
This blog covers all steps to enable Approach-1.
Following are the pre-requisites to enable the scenario:
- SAP MDG on S/4 HANA
- SAP CRM 7.02 SP12 & above
- SAP S/4 HANA
- No use of CRM middleware for BP replication.
- All Service based configurations/derivations/validations to trigger a BP SOA service should be in place in MDG. SAP S/4 HANA and SAP CRM should also have the required Value Mappings to consume the service and create BP/Customers successfully. If message fails in target systems the CRM Tables will not be updated.
- A CRM System is connected in the Landscape with SAP S/4 HANA and SAP MDG for Master Data (BP) replications.
Service Flow Diagram
A typical Business Partner flow looks like below with all the SOA based services in place.Detailed view of Service Flow and Service call between SAP MDG, SAP S/4 HANA and SAP CRM
(ID Matching API is called internally from the BADI Code)
BADI Execution Flow Diagram
Standard BADI Availability in SAP S/4 HANA and SAP CRM
- In the S/4 HANA client system, check whether there is an (active) BAdI implementation called MDG_BS_KEY_MAP_HANDLER_CUSTOM for the enhancement implementation MDG_BS_CUSTOM_SI_ERP of the enhancement spot MDG_BS_SUPPLIER_SI.
- If no active BAdI implementation exists, create one with an implementing customer class (for example, ZCL_MDG-BS_CUST_KEYMAP_HANDLER).
- Copy the code from the attachment ZSAVE_SUPPLIER_DATA_IN.DOCX of SAP Note 1929736 into the interface method IF_EX_MDG_BS_SUPPLIER_SI~SAVE_SUPPLIER_DATA_IN of your class.
- Activate the implementation.
- In the S/4 HANA client system, check whether there is an (active) BAdI implementation called MDG_BS_KEYMAP_CUST_CP_HANDLER for the enhancement implementation
MDG_BS_CUSTOM_RELSHIP_SI_IN of the enhancement spot MDG_BS_BP_RELSHIP_SI.
- If no active BAdI implementation exists, create one with an implementation customer class (for example, ZCL_MDG_KEYMAP_CUST_CP_HANDLER).
- Copy the code from the attachment ZSAVE_RELATIONSHIP_DATA_IN.DOCX of Note 1929736 into the interface method IF_MDG_BS_BP_RELSHIP_SI~SAVE_RELATIONSHIP_DATA_IN of your class.
- Activate the implementation
Following are the Step-By-Step procedure to enable the configuration:
In MDG System
- In SAP MDG, Create Logical and Business Systems for SAP S/4 HANA and SAP CRM
BD54 – Create Logical SystemDRFIMG – Define Business System
2. Define Business Object and Communication Channel3. Update the Replication Model with New Business System Name
Configure replication model for systems that require the Business Partner information.
4. Perform SOAMANAGER configurations (Provider System, Logon Data)5. WebService Configuration for Business Partner Service Creations6. Allow the RFC Program to be called from external System (S4HANA/CRM) in the UCON SettingsProgram Name – MDG_ID_QUERY_MATCHING
7. Configure Table MDGV_BP_SYS_PAR
In SAP S/4 HANA System
- Configure Logical and Business System for MDG and CRM systems. (Similar to Step 1 & 2 mentioned above)
- Configure Central Registry
The Consumer setup is read from the BADI Code and is the first step for SAP S/4 HANA to identify if a CRM system is connected in the landscape or not. If not system is available then the scenario is not required.
Similar Setup is done in SAP CRM system as given in SAP S/4HANA (except the CONSUMER setup). Apart from this RFC destination is required and need to be configured along with Business System Configuration.
2. Click Manual Replication Filter Criteria
3. Put the BP# and click Save. Then Click Execute (If a specific filter is not mentioned, the replication will run for all the BP’s)
4. Once replication is successful in SAP MDG, SAP CRM and SAP S4 HANA system,
5. Goto SE16 and
For S4 Check tables CRMKUNNR & CRMPARNR
For CRM Check tables CRMM_BUT_CUSTNO & CRMM_BUT_CONTNO
If the BP with GUID entries are available in both system then the CRM tables are updated
Here are some of the issues & fixes during the initial setup
- Consumer is hard coded in BADI Code – As mentioned above, the BADI execution in SAP S/4 HANA checks for a CRM system availability in the first step. During the debugging it was found the BADI has a hard-coded Consumer mentioned. To solve this raise a OSS Ticket to SAP and a fix will be implemented via a SAP Note.
- Unavailability of Logical, Business Systems – The BADI code required Logical & Business System to identify the target systems. This needs to be in place without which the code will exit.
- RFC destination is not configured – While configuring the Business System it is also required to mention the RFC destination.
- Central Registry not available – Central Registry is a concept in which a particular system is defined as a Hub and all other systems request/query data from the Hub System. Here MDG system is the Hub, so S4 and CRM should request data from MDG. Hence Central registry configuration is required. Please note if Central Registry is configured all the other configurations like logical, business systems and RFC needs to be correctly configured. If this is not in place the BADI execution will go in a loop and consume all the dialog instances leading to performance issues.
- RFC Program access restriction – SAP has introduced a concept call UCON (Unified Connectivity) where an RFC program cannot be accessed by another SAP system if the UCON setup is not with CA allowed for that program. This is done easily using the UCONCOCKPIT subject to authorizations.
- Key Mapping Update Delay (Double Replication) – There can be instances where SAP S/4 HANA processed the Business Partner earlier than SAP CRM. In such cases the CRM tables in S4 HANA will not be updated with the CRM GUID information. Likewise, CRM table in CRM system will not be updated with the ERP Partner ID. To resolve this issue a double/re-replication of BP would be required.
- Testing the BADI Execution – There is no way to test the BADI except DRFOUT/external trigger. The BADI is only called when a BP Service Message hits the SAP system.
Below are some references to get more information. These were useful while implementing the above solution:
Thanks Ashish Ghate in helping and supporting the requirement