Professional Documents
Culture Documents
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
Applies to:
SAP CRM 5.0 on Web AS 700 (SAP_ABA 700, SAP_BASIS 700, BBPCRM 500)
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 Non-
SAP 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 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
© 2006 SAP AG 1
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
© 2006 SAP AG 2
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
© 2006 SAP AG 3
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
o Ship-To Party
o Payer
o Bill-To Party
• Business Partners in CRM would be linked together by means of Business Partner relationships
• When a new BP relationship is added or an existing BP relationship is deleted from a Business
Partner, the relationships need to be distributed to the external system so the linkage is maintained
there as well
• 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
• CRM Middleware: A messaging BDoc (mBDoc) is generated: -
© 2006 SAP AG 4
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
o BDoc message of type BUPA_MAIN is generated whenever Business Partner Master Data
is created or changed
o BDoc message of type BUPA_REL is generated whenever a Business Partner Relationship
is created or modified
• External Interface (XIF) Adapter: Contains BADI enhancements which can be used for: -
o Manipulate the data in outbound as well as inbound messages
o Populate data in custom structures in outbound and inbound messages
o Reject / Filter out messages that do not match your criteria
o Manipulations made to the outbound message are reflected in the IDoc / SOAP-XML stream
• Delivery of the message: This could happen in one of 2 ways: -
o SOAP/XML - The message is dispatched as a SOAP-XML Message
o ALE/Idoc - The message is mapped to an IDoc and dispatched
In our example we shall dispatch the outbound message using the ALE/IDoc approach
© 2006 SAP AG 5
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Please Note: -
For our requirement, we shall perform all configuration/setup in Client 200 and test in Client 210
Magma
• Listens to incoming HTTP requests from SAP CRM
• Maps the incoming IDoc (in XML format over HTTP protocol) to the target structures in Centrix
• Updates the Centrix database tables through SQL INSERT statements
Centrix
• This is the receiving system in the entire integration
• Receives the Business Partner Master and Relationship data from Magma (which in turn comes from
SAP CRM)
Please Note: -
• From an SAP CRM view point, Magma is the receiving system
• So all XIF and ALE configuration in SAP CRM is done with respect to Magma
© 2006 SAP AG 6
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
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
© 2006 SAP AG 7
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
ZZCENTRIXDATA ZDB1_CENTRIX_INTERFACE_T
© 2006 SAP AG 8
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
© 2006 SAP AG 9
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
METHOD if_ex_crmxif_partner_map~change_mapped_data_out.
************************************************************************
* METHOD: IF_EX_CRMXIF_PARTNER_MAP~CHANGE_MAPPED_DATA_OUT *
* *
* TITLE: CRM Customer Master to Centrix Interface *
* *
* AUTHOR: Aditya Palekar (SAP GDC) DATE: 20.12.2006 *
* *
* DESCRIPTION: This method is called by the CRM XIF adapter framework *
* when an outbound message is generated on Creating *
* or Changing Business Partner main data *
* This method contains a check to ensure that *
* Business Partners of category '2' (Organisation) *
* are sent to external system *
* The method is triggered after the mBDoc of type *
* BUPA_MAIN is created *
* *
************************************************************************
DATA ls_data_mapped LIKE LINE OF cs_data_mapped.
© 2006 SAP AG 10
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
ENDMETHOD.
© 2006 SAP AG 11
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
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. " END OF PROCESSING FOR ALL RELATIONSHIP CATEGORIES
© 2006 SAP AG 12
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
© 2006 SAP AG 13
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.
© 2006 SAP AG 14
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
ls_centrix-zzsapcrm_del_id = lv_ship_to_party.
ls_centrix-zzmethod = cs_bp_rel_data-header-object_task.
APPEND ls_centrix TO cs_bp_rel_data-central_data-zzcentrixdata.
ENDMETHOD.
ALE Setup
• Also ensure that an entry for Logical System CD1CLNT200 exists. This logical system must be
assigned to CRM Client 200 (see Transaction SCC4)
* The path prefix denotes the exact location of the application which is listening to the IDoc from CRM
© 2006 SAP AG 15
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
© 2006 SAP AG 16
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
ALE Port
• Start Transaction WE21
• Create a new ALE Port EX1MAGMA of type XML-HTTP
• Enter the RFC Destination EXT_MAGMA
• Choose the content type as Application/x-idoc
© 2006 SAP AG 17
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
© 2006 SAP AG 18
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
© 2006 SAP AG 19
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
Subscription ZSUB_BUPA_MAIN
Subscription ZSUB_BUPA_REL
© 2006 SAP AG 20
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
© 2006 SAP AG 21
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)
© 2006 SAP AG 22
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
© 2006 SAP AG 23
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
© 2006 SAP AG 24
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
• Start Transaction BP
• Enter the Business Partner details in the respective fields
• 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
© 2006 SAP AG 25
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter
© 2006 SAP AG 26
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
• You might get a confirmation dialog box. Choose ‘Yes’
• 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
© 2006 SAP AG 27
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.
© 2006 SAP AG 28