28
Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 1 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(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

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 1

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(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

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 2

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

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 3

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

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 4

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: -

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 5

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

Technical System Landscape

The systems in the landscape are: -

• SAP CRM 5.0

• Magma

• Centrix

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 6

SAP CRM 5.0

• 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 Master Config Client

210 Sandpit Client

220 Unit Testing Client

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

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 7

Configuration of the Interface Scenario

Extensions to the CRM XIF Complex Structure for Business Partner Relationship Please Note: -

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: -

Set the Enhancement Category to Can be enhanced (Character Type)

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 8

Table Type to hold multiple records of the Structure Create a new Table Type ZDB1_CENTRIX_INTERFACE_T Table Type for CRM to Centrix Interface Structure with line type as ZDB1_CENTRIX_INTERFACE structure

Append Structure for Create a new Append Structure ZDB1_CENTRIX_APPEND Centrix Interface Data Structure for the structure BURS_EI_RELATION_DATA as follows: -

Component Component Type

ZZCENTRIXDATA ZDB1_CENTRIX_INTERFACE_T

Set the Enhancement Category to Can be enhanced (Deep) 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

Generation of Custom Message Type from the ALE Interface • Create a new Function Group ZDB1_BUPARELALE and activate the same

Function Group Description

ZDB1_BUPARELALE BP Relationship - External Interface

• Start Transaction BDFG

• Enter Function Module as CRMXIF_PARTNER_REL_SAVE and press Enter. The corresponding Business Object and relevant Message Types are displayed

• From the menu choose Interface Create

• 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

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 9

• Press the Continue button to proceed

• Once the Interface is generated, choose the menu option Interface Check 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 Object Check. All the non-released segments are highlighted in the check

• Set the Release for all the non-released Segment Types through Transaction WE31

BADI Enhancement Implementation for the Outbound Messages

Filtering the Business Partners per Business Partner Category

• Create a BADI implementation and activate the same as follows: -

BADI Definition CRMXIF_PARTNER_MAP

BADI Implementation ZDB1_CRMXIF_BPMAP

BADI Implementation Description

BP Main Data External Interface Enhancement (BUPA_MAIN)

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 10

• Implement the method IF_EX_CRMXIF_PARTNER_MAP~CHANGE_MAPPED_DATA_OUT. In this method, if we delete a line from internal table CS_DATA_MAPPED which does not meet our criteria, we can prevent the IDoc from being generated subsequently. In this way we can filter the master data that is distributed

• 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 *

* *

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

DATA lv_tabix TYPE sytabix.

*** MAIN PROCESSING *****

LOOP AT cs_data_mapped INTO ls_data_mapped.

* Store the index of this internal table record in a variable

CLEAR lv_tabix.

MOVE sy-tabix TO lv_tabix.

* Proceed only if Business Partner belongs to BP Category '2' (Organisation)

IF ls_data_mapped-central_data-common-data-bp_control-category

<> c_bp_category_org.

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 11

DELETE cs_data_mapped INDEX lv_tabix.

CONTINUE.

ENDIF.

ENDLOOP.

ENDMETHOD.

Check, Save and Activate the Method

Populating Custom Fields for the BP Relationship in the outbound message

• 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 Interface Enhancement (BUPA_REL)

• In the interface method IF_EX_CRMXIF_PARTNER_MAP~CHANGE_MAPPED_DATA_OUT, insert the following code: -

*----------------------------------------------------------------------*

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

DATA ls_data_mapped LIKE LINE OF cs_data_mapped.

*** MAIN PROCESSING *****

LOOP AT cs_data_mapped INTO ls_data_mapped.

* Store the index of this internal table record in a variable

CLEAR lv_tabix.

lv_tabix = sy-tabix.

* Proceed only if any one of the following relations were assigned: -

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 12

* Ship-To Party (Relationship Category --> CRMH02)

* Payer (Relationship Category --> CRMH03)

* Bill-To Party (Relationship Category --> CRMH04)

CLEAR lv_relat_cat.

lv_relat_cat = ls_data_mapped-header-object_instance-relat_category.

IF NOT ( lv_relat_cat = c_relcat_shipto

OR lv_relat_cat = c_relcat_payer

OR lv_relat_cat = c_relcat_billto ).

DELETE cs_data_mapped INDEX lv_tabix.

CONTINUE.

ENDIF.

* Process only those relationships which have been newly created

* or deleted during reassignment of relationships

CHECK ls_data_mapped-header-object_task = c_task_insert

OR 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. " END OF PROCESSING FOR ALL RELATIONSHIP CATEGORIES

* Update the Complex Structure Internal Table with the modified

* Centrix Structure data

MODIFY cs_data_mapped FROM ls_data_mapped INDEX lv_tabix

TRANSPORTING central_data-zzcentrixdata.

ENDLOOP. " END OF PROCESSING ALL RELATIONSHIPS CREATED / DELETED

ENDMETHOD.

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 13

DATA lv_sold_to_party TYPE bu_partner.

DATA lv_bill_to_party TYPE bu_partner.

DATA lv_payer TYPE bu_partner.

DATA lv_ship_to_party TYPE bu_partner.

DATA ls_centrix TYPE LINE OF zdb1_centrix_interface_t.

DATA ls_relationship TYPE bapibus1006_relations.

DATA lt_return TYPE bapiret2_t.

DATA lt_relationships_ship TYPE TABLE OF bapibus1006_relations.

DATA lt_relationships_sold TYPE TABLE OF bapibus1006_relations.

* Initialise all relevant variables

CLEAR lv_sold_to_party.

CLEAR lv_ship_to_party.

CLEAR lv_bill_to_party.

CLEAR lv_payer.

* Refresh the Centrix Data internal table

REFRESH cs_bp_rel_data-central_data-zzcentrixdata.

* Ship-To Party Selected ************

CLEAR lv_ship_to_party.

lv_ship_to_party =

cs_bp_rel_data-header-object_instance-partner2-partner_no.

* Sold-To Party Selected ************

CLEAR lv_sold_to_party.

lv_sold_to_party =

cs_bp_rel_data-header-object_instance-partner1-partner_no.

* Get all Relationships of Sold-To Party

REFRESH lt_relationships_sold.

REFRESH lt_return.

CALL FUNCTION 'BAPI_BUPA_RELATIONSHIPS_GET'

EXPORTING

businesspartner = lv_sold_to_party

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 14

TABLES

relationships = lt_relationships_sold

return = lt_return.

* Finding the Bill-To Party

CLEAR ls_relationship.

READ TABLE lt_relationships_ship WITH KEY

partner1 = lv_ship_to_party

relationshipcategory = c_relcat_billto

INTO ls_relationship.

IF sy-subrc = 0.

* Bill-To Party Selected ************

lv_bill_to_party = ls_relationship-partner2.

ENDIF.

* Finding the Payer

CLEAR ls_relationship.

READ TABLE lt_relationships_ship WITH KEY

partner1 = lv_ship_to_party

relationshipcategory = c_relcat_payer

INTO ls_relationship.

* If the Payer is attached to the Ship-to Party

* ( **** SCENARIO 1: REGIONAL BILL & PAYMENT **** )

IF sy-subrc = 0.

* Payer Selected ************

lv_payer = 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

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 15

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

Logical System setup

• Start Transaction BD54

• Enter a new Logical System as follows: -

Logical System Description

EX1CENTRIX External Interface to CENTRIX

• Also ensure that an entry for Logical System CD1CLNT200 exists. This logical system must be assigned to CRM Client 200 (see Transaction SCC4)

RFC Destination setup

• Start Transaction SM59

• Create a new RFC Destination of Type ‘G’ (HTTP Connections to External Server)

• 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

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 16

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 17

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

ALE Partner Profile

• Start Transaction WE20

• Create a Partner Profile EX1CENTRIX of Type LS (Logical System)

• Enter the message types CRMXIF_PARTNER_SAVE_M, ZCRMXIF_BUPAREL_EXT and SYNCH

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 18

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 19

Please Note:

Message Type SYNCH with IDoc Type SYNCHRON is added to the Partner Profile as well

Customer Distribution Model

• Start Transaction BD64

• Create a Distribution Model as follows: - Sending System CD1CLNT200 Receiving System EX1CENTRIX Message Type(s): - CRMXIF_PARTNER_SAVE_M ZCRMXIF_BUPAREL_EXT

• Perform a Technical Consistency Check for the model in Transaction BDM5. Switch off the cross-system checking when performing this check

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 20

External Interface Adapter (XIF) Setup

Create new Site

• Start Transaction SMOEAC Administration Console

• 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

Create new Subscription(s) In the same transaction SMOEAC you need to create 2 new subscriptions

Subscription ZSUB_BUPA_MAIN

Publication All Business Partners (MESG)

Assign to Site ZSITE01

Subscription ZSUB_BUPA_REL

Publication All Business Partner Relationships (MESG)

Assign to Site ZSITE01

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 21

Assign Site ID to Interface Type

• Start Transaction CRMXIF_C1

• Enter 2 new entries in the table as shown in the diagram

This table links the mBDoc Type to the respective External Interface (XIF) Function Module

Running the Interface The steps mentioned below for running the interface assume that we are using the SAPGUI for user interaction. We can also use the CRM Web GUI for running this interface. Although the menus and navigation paths are different in the Web GUI; we will still get the same results The Business Partner numbers mentioned here are specific to the system in which I have tested

• Start Transaction BP

• Create a Business Partner in the Role Ship-To Party (in our case ZCRM02). Enter the relevant data and press Save

• Business Partner 13665 is created in the role ZCRM02 (Ship-To Party)

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 22

An IDoc of message type CRMXIF_PARTNER_SAVE_M is generated with Status 03 (Data Passed to Port OK)

Similarly, 3 more Business Partners are created as follows: -

BP Number 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

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 23

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 Category Description

13665 CRMH02 Has Ship-To Party/Recipient

13666 CRMH03 Has Payer

13667 CRMH04 Has Bill-To Party

Save the Transaction An IDoc of message type ZCRMXIF_BUPAREL_EXT is generated The custom segment Z101DB1_CENTRIX_INTERFACE is visible in the IDoc with all the relevant Business Partners which are populated by the method CHANGE_MAPPED_DATA_OUT of BADI implementation ZDB1_CRMXIF_BPRELMAP

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 24

Debugging the BADI Enhancement while running the Interface In the method CHANGE_MAPPED_DATA_OUT of the BADI Implementation ZDB1_CRMXIF_BPMAP set a hard coded break point in the source code as follows: -

BREAK APALEKAR

Save and activate the method

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 25

• 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

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 26

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 27

• 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

Distributing Business Partner Master Data from SAP CRM to an external system using the CRM XIF Adapter

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 28

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.