Distributing Business Partner Master Data From SAP CRM To An External System Using The CRM XIF Adapter
Distributing Business Partner Master Data From SAP CRM To An External System Using The CRM XIF Adapter
Distributing Business Partner Master Data From SAP CRM To An External System Using The CRM XIF Adapter
Summary
This article is based on a customer specific requirement which I have undertaken on a project. It describes a
scenario where CRM Business Partner Master Data and Relationship Data is distributed to an External NonSAP System called Centrix.
The interface setup was done through a combination of CRM XIF adapter setup, BADI enhancement (for
populating custom fields) and IDoc Technology to distribute the data.
This article explains how the interface was configured in SAP CRM step by step.
Author(s): Aditya S Palekar
Company: SAP Global Delivery Centre, India
Created on: 08 January 2007
Author Bio
Aditya Palekar is an SAP Development Consultant working for SAP Global Delivery Centre at
Bangalore, India. He has 5 years of ABAP programming experience which includes
programming on SAP ECC. He has undertaken projects for customers based in India, UK and
USA and has played the role of a developer and development lead
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Table of Contents
Applies to: ........................................................................................................................................ 1
Summary.......................................................................................................................................... 1
Author Bio ........................................................................................................................................ 1
Preface............................................................................................................................................. 3
Project Requirement ........................................................................................................................ 4
The Approach .................................................................................................................................. 4
Technical System Landscape.......................................................................................................... 5
SAP CRM 5.0 ........................................................................................................................... 6
Magma...................................................................................................................................... 6
Centrix ...................................................................................................................................... 6
Configuration of the Interface Scenario ........................................................................................... 7
Extension to the CRM XIF Complex Structure ............................................................................ 7
Generation of Custom Message Type from the ALE Interface .................................................... 8
BADI Enhancement Implementation for the Outbound Messages .............................................. 9
Filtering the Business Partners per Business Partner Category .............................................. 9
Populating Custom Fields for the BP Relationship in the outbound message....................... 11
ALE Setup .................................................................................................................................. 15
Logical System setup ............................................................................................................. 15
RFC Destination setup ........................................................................................................... 15
ALE Port ................................................................................................................................. 17
ALE Partner Profile................................................................................................................. 17
Customer Distribution Model .................................................................................................. 19
External Interface Adapter (XIF) Setup...................................................................................... 20
Create new Site ...................................................................................................................... 20
Create new Subscription(s) .................................................................................................... 20
Assign Site ID to Interface Type ............................................................................................. 21
Running the Interface .................................................................................................................... 21
Debugging the BADI Enhancement while running the Interface ................................................... 24
Related Content............................................................................................................................. 27
Copyright........................................................................................................................................ 28
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Preface
This article is based on a customer specific requirement which I have undertaken on a project. It describes a
scenario where we had to interface CRM Business Partner Master Data and Relationship Data to an external
system called Centrix. Centrix is based on a SQL Server Database platform and required the master data
from CRM to perform subsequent processes such as Billing to the customer.
The challenge here was to interface SAP CRM and Centrix without a powerful middleware such as SAP XI.
The customer eventually decided to implement XI but that was several months later in the Project.
For the interfacing between SAP CRM and Centrix we used a system called Magma from Cindercone
Solutions Ltd, UK. After thoroughly evaluating the technical capabilities we found that we can use Magma to
listen to incoming IDocs from SAP CRM via HTTP, map them to the structures in Centrix and update the
tables through SQL Insert commands. Magma contained ODBC drivers to connect to the Centrix database
and perform SQL Insert operations.
For transferring the Relationship data from SAP CRM, we had to introduce custom structures with additional
fields as the standard IDoc in CRM did not contain all the data we needed. So BADI enhancements had to
be implemented to populate these custom structures.
Separate setup was required on Magma to listen to the incoming requests from SAP CRM. Separate
database tables were setup on Centrix system to store the records coming from SAP CRM via Magma. This
document does not discuss the details about the technical setup of Magma and Centrix. It focuses mainly on
delivering the master data from SAP CRM to Magma and setup required from SAP specific to the
requirement
Now I am aware that there is standard documentation on CRM XIF function modules, but this specific case
uses a combination of XIF, BADI enhancement, ALE/IDoc all working together. I found this mix of technology
to be quite interesting and I am writing this article which would benefit other developers on similar
requirements in the future as they would know more about the capabilities of the CRM XIF interface through
this example
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Project Requirement
Business Partners created or changed in CRM should be distributed to an external system Centrix
Business Partners in specific BP roles would be created / changed in SAP CRM and must be
distributed to the external system. These roles are: o
Sold-To Party
Ship-To Party
Payer
Bill-To Party
Business Partners in CRM would be linked together by means of Business Partner relationships
For each relationship that is created / deleted, the other logically linked business partners should be
sent out in the same message
The interface between SAP CRM and the external system should be in Real-Time
The Approach
Refer to the diagram below: -
SAP CRM contains a component called the External Interface Adapter (XIF) which allows you to interface
between SAP CRM and external systems
The interaction between the different layers is as follows:
CRM Server: Business Partner master data / relationship data is created or changed
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
BDoc message of type BUPA_MAIN is generated whenever Business Partner Master Data
is created or changed
External Interface (XIF) Adapter: Contains BADI enhancements which can be used for: o
Manipulations made to the outbound message are reflected in the IDoc / SOAP-XML stream
SOAP/XML
ALE/Idoc
In our example we shall dispatch the outbound message using the ALE/IDoc approach
Magma
Centrix
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
This is the source of all Business Partner Master Data and Business Partner Relationship data
Business Partner Master and Relationship Data is sent to Magma as an IDoc in XML format over
HTTP protocol
Three clients were provided in our SAP CRM development system as follows: 200
210
Sandpit Client
220
Please Note: For our requirement, we shall perform all configuration/setup in Client 200 and test in Client 210
Magma
Maps the incoming IDoc (in XML format over HTTP protocol) to the target structures in Centrix
Centrix
Receives the Business Partner Master and Relationship data from Magma (which in turn comes from
SAP CRM)
Please Note:
So all XIF and ALE configuration in SAP CRM is done with respect to Magma
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Although the master and relationship data is distributed using IDoc, the extension is not at the ALE
Layer which means we are not using IDoc extension
We are extending the structure centrally at the XIF layer and controlling the custom fields there so
they will be reflected in the subsequent outbound message (whether we choose IDoc or SOAP
method for distribution)
In this section, we will add an Append Structure to the structure CRMXIF_PARTNER_REL_COMPLEX (for
Business Partner Relationships)
We will then create a custom IDoc message type for the Business Partner Relationship Interface which will
contain the fields from the standard structure and the custom fields from the append structure
Later in this article, we will see how to populate the custom structure fields through a BADI enhancement
which is called within the XIF framework before it passes to the ALE Layer
Structure for Custom Fields in the interface
Create a Structure ZDB1_CENTRIX_INTERFACE CRM to Centrix Interface Structure as follows: -
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Component Type
ZZCENTRIXDATA
ZDB1_CENTRIX_INTERFACE_T
Structure BURS_EI_RELATION_DATA is the data type for the component CENTRAL_DATA of the
CRM Relationship complex structure CRMXIF_PARTNER_REL_COMPLEX
It is under this level that we are attaching the append structure with the custom fields
These fields will be reflected in the Hierarchical structure of IDoc Type as we will create a custom
message type from this extended Complex Structure
Description
ZDB1_BUPARELALE
Enter the parameters as shown below for Outbound Processing. Leave the Inbound Processing
parameters unpopulated
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Once the Interface is generated, choose the menu option InterfaceCheck to see if all components
have been created and activated successfully
Go to Transaction WE30, enter IDoc Type ZCRMXIF_BUPAREL_EXT01 and choose the menu
option Development ObjectCheck. All the non-released segments are highlighted in the check
Set the Release for all the non-released Segment Types through Transaction WE31
Create a BADI implementation and activate the same as follows: BADI Definition
CRMXIF_PARTNER_MAP
BADI Implementation
ZDB1_CRMXIF_BPMAP
BADI
Implementation
Description
Interface
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
The code below shows how we can validate and filter out the Business Partner data per Business
Partner Category
METHOD if_ex_crmxif_partner_map~change_mapped_data_out.
************************************************************************
* METHOD: IF_EX_CRMXIF_PARTNER_MAP~CHANGE_MAPPED_DATA_OUT
DATE: 20.12.2006
BUPA_MAIN is created
************************************************************************
DATA ls_data_mapped LIKE LINE OF cs_data_mapped.
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
ENDMETHOD.
Check, Save and Activate the Method
Create a BADI implementation and activate the same as follows: BADI Definition
CRMXIF_PARTNER_R_MAP
BADI Implementation
ZDB1_CRMXIF_BPRELMAP
BADI
Implementation
Description
BP Relationship External
Enhancement (BUPA_REL)
Interface
*----------------------------------------------------------------------*
* This method is used to populate the additional custom fields of the
* Relationship Complex Structure while sending the data outbound from
* SAP CRM.
* The fields populated here are passed on to the outbound IDoc which is
* sent to Centrix.
*----------------------------------------------------------------------*
DATA lv_tabix TYPE sytabix.
DATA lv_relat_cat TYPE bu_reltyp.
* Proceed only if any one of the following relations were assigned: SAP DEVELOPER NETWORK | sdn.sap.com
2006 SAP AG
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
lv_relat_cat = c_relcat_payer
OR
lv_relat_cat = c_relcat_billto ).
ls_data_mapped-header-object_task = c_task_delete.
CASE lv_relat_cat.
*----------------------------------------------------------------------*
* RELATIONSHIP CATEGORY 'CRMH02' (HAS A SHIP-TO PARTY/RECIPIENT)
* EXISTS BETWEEN THE BUSINESS PARTNERS
*----------------------------------------------------------------------*
WHEN c_relcat_shipto.
CALL METHOD zcl_im_db1_crmxif_bprelmap=>process_ship_to
CHANGING
cs_bp_rel_data = ls_data_mapped.
ENDCASE.
ENDLOOP.
ENDMETHOD.
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
TABLES
relationships
= lt_relationships_sold
return
= lt_return.
IF sy-subrc = 0.
* Bill-To Party Selected ************
lv_bill_to_party = ls_relationship-partner2.
ENDIF.
* At this point, all the relevant Business Partners have been determined
* Include all the relevant BP Numbers into the Centrix
* Interface Structure
CLEAR ls_centrix.
ls_centrix-zzsapcrm_pay_id
= lv_payer.
ls_centrix-zzsapcrm_bill_id
= lv_bill_to_party.
ls_centrix-zzsapcrm_soldto_id
= lv_sold_to_party.
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
ls_centrix-zzsapcrm_del_id
ls_centrix-zzmethod
= lv_ship_to_party.
= cs_bp_rel_data-header-object_task.
Logical System
Description
EX1CENTRIX
Also ensure that an entry for Logical System CD1CLNT200 exists. This logical system must be
assigned to CRM Client 200 (see Transaction SCC4)
In our case, the external system Magma has an application listening on a specified port. The details
to be entered for our RFC destination are: -
Target Host
128.1.8.29
Service Number
650002
Path Prefix*
/Centrix-CRM-Customers
* The path prefix denotes the exact location of the application which is listening to the IDoc from CRM
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
ALE Port
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Please Note:
Message Type SYNCH with IDoc Type SYNCHRON is added to the Partner Profile as well
CD1CLNT200
Receiving System
EX1CENTRIX
Perform a Technical Consistency Check for the model in Transaction BDM5. Switch off the crosssystem checking when performing this check
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Create a new site ZSITE01 of type External Interface for IDOCs as shown in the diagram below
In the Site Attributes enter the ALE Partner profile EX1CENTRIX created earlier
Hence we have linked the XIF site with the ALE partner profile
ZSUB_BUPA_MAIN
Publication
Assign to Site
ZSITE01
Subscription
ZSUB_BUPA_REL
Publication
Assign to Site
ZSITE01
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
This table links the mBDoc Type to the respective External Interface (XIF) Function Module
Start Transaction BP
Create a Business Partner in the Role Ship-To Party (in our case ZCRM02). Enter the relevant data
and press Save
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
An IDoc of message type CRMXIF_PARTNER_SAVE_M is generated with Status 03 (Data Passed to Port
OK)
BP Role
BP Role Description
13666
ZCRM03
Payer
13667
ZCRM04
Bill-To Party
13668
ZBUP02
Sold-To Party
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Now select the Business Partner 13668 (sold-To Party) and create the following Business Partner
relationships as shown in the diagram
BP Number
BP
Relationship
Category
BP
Relationship
Description
Category
13665
CRMH02
13666
CRMH03
Has Payer
13667
CRMH04
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Start Transaction BP
Before you save the transaction, activate the debug mode by typing /h in the command field on the
top left and then press Save to save the Business Partner record
In the debug mode, set a breakpoint on the method PROCESS_OUTBOUND of global class
CL_SMW_MFLOW
Once the debugger breaks inside the method PROCESS_OUTBOUND, continue to debug until you
reach the point shown in the image below. Change the value of the parameter __DBGMODE to 'X'
and then press the F8 (Continue) button to proceed
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Go to Transaction SMW01 and select all BDocs of type BUPA_MAIN. You will notice that the mBDoc
message has status; To be processed (Debug).
Select the BDoc and choose the option Reprocess mBDoc message
The program pauses in debug mode inside the method CHANGE_MAPPED_DATA_OUT of the
BADI implementation ZDB1_CRMXIF_BPMAP containing your code. From here you can debug the
enhancement code
Related Content
For more details on CRM XIF Interface for Business Partners, see documentation of function
modules CRMXIF_PARTNER_COMPLEX and CRMXIF_PARTNER_REL_COMPLEX
Refer
to
SAP
Note
448742
for
General
Notes
on
CRM
XIF
Interfaces
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Copyright
Copyright 2006 SAP AG. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.
The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries,
zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, OpenPower and PowerPC are
trademarks or registered trademarks of IBM Corporation.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems
Incorporated in the United States and/or other countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of
Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts
Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by
Netscape.
MaxDB is a trademark of MySQL AB, Sweden.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their
respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All
other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves
informational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP
Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or
omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the
express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an
additional warranty.
These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the implied
warranties of merchantability, fitness for a particular purpose, or non-infringement.
SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may
result from the use of these materials.
SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these
materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and
does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages.
Any software coding and/or code lines/strings (Code) included in this documentation are only examples and are not intended to be
used in a productive system environment. The Code is only intended better explain and visualize the syntax and phrasing rules of
certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors
or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.