Order management integration with third-party providers is a common scenario, as is the need to send an order confirmation output to them. SAP CRM provides standard external interfaces known as external interface (XIF) adapters for data exchange with non-SAP components in an SAP CRM solution landscape. Business data such as transactions, customers, and products can then be exchanged in inbound and outbound directions. See how to use the XIF adapter with SAP CRM actions functionality to convert orders to IDoc or XML format and then send order confirmations automatically.
Key Concept
SAP CRM middleware provides standard external interfaces known as external interface (XIF) adapters for data exchange with external systems. XIF adapter CRMXIF_ORDER_SAVE provides both IDoc processing and processing for XML or SOAP calls for business transactions. The corresponding IDoc message type is CRMXIF_ORDER_SAVE_M. This XIF adapter can be called through actions that trigger the conversion and data transfer to the external system. Because actions are freely customizable and integrated in the transactions, the data exchange process can be triggered from within the transaction automatically.
When a sales order is created in SAP CRM, it generates a business document (BDoc) that it transfers to SAP CRM middleware. In SAP CRM middleware, external interface adapters (XIF adapters) convert the data to an IDoc or XML format and select the data to be transferred. A receiving system such as webMethods can process the IDocs or XML documents to convert them to the format that third-party software can understand. Alternatively, data can be exchanged using SAP NetWeaver Process Integration (SAP NetWeaver PI) where further mapping is possible if required.
Note
The content of BDocs is based on BDoc types, which are broadly classified into two types: Synchronization BDoc types (sBDoc types), which are used for data exchange between the SAP CRM server and mobile clients, and messaging BDoc types (mBDoc types), which are used by server applications. In the context of this article only mBDoc types are applicable.
Let’s take a simple business scenario in which the order confirmation needs to be sent to a distributor (who uses a third-party software) automatically as soon as the order is released. Follow these three steps to enable this process:
Step 1. Set up a Receiving System to Process IDocs or XML
You need to create a Remote Function Call (RFC) destination, receiver port, and partner profile. The receiving system could be SAP NetWeaver PI or an external middleware system such as webMethods, depending on the landscape.
First, create an RFC destination for the receiving system using transaction SM59. This establishes the connection between SAP CRM and the receiving system. In transaction SM59, click the create icon and the system opens a dialog to create a new RFC destination. In this screen, enter a destination name, connection type, and a short description. The connection type is chosen depending on the receiving system. In my example for IDoc outbound processing using SAP NetWeaver PI, use connection type 3. In the Technical Settings tab, enter the target host and system number. In the Logon and security tab, enter log-in information and click the save icon to save the RFC destination.
For XML outbound processing, use the connection type G or H (HTTP connection to external server). In the Technical Settings tab, enter the path prefix and service number of the target system. In the Logon and security tab, enter log-in information and click the save icon to save the RFC destination.
Note
The Basis team can help set up RFC destinations.
Next, to create a receiver port, navigate to transaction WE21. Choose the port type Transactional RFC in the left tree structure (Figure 1) and click the create icon . This pops up a window in which you can create a transactional RFC (tRFC) port. Click the Continue button on this window with the Generate port name option selected. The system then opens a dialog on the right side to create a new port with a port name and the version IDoc record types 4.x selected by default. Enter a Description and the RFC destination (created above) for the port and click the save icon.

Figure 1
Set up the receiver port
Next, to create a partner profile, navigate to transaction WE20 and choose the partner type Customer on the left tree structure. Click the create icon
(Figure 2), which opens a dialog on the right to create a new partner profile. In this screen, enter a partner number (an existing customer in SAP CRM) in the field Partner No. The field Ty. specifies the agent type for a recipient to be notified about any errors in the IDoc interface. If the recipient is a user, fill the Ty. field as US and fill the Agent field with a user name. If the recipient is an organizational unit, enter the Ty. field as O and enter the Agent field with the organizational unit that has personnel to be notified. Save the partner profile by clicking the save icon.

Figure 2
Partner profile setup
Note
You can also create a partner profile of the type Logical system if a logical system is defined (in transaction BD54) and assigned to a client server (in transaction SCC4).
The partner profile can have outbound and inbound parameters to facilitate outbound and inbound processing. For my example, since the order output is passed outbound to an external system via an XIF adapter, I define an outbound parameter of message type CRMXIF_ORDER_SAVE_M. Click the insert rows icon
on the Outbound parmtrs. table (Figure 2), which opens a dialog to create the outbound parameter (Figure 3).

Figure 3
Parameters for outbound message type
In the Outbound parameters screen, enter the Message Type as CRMXIF_ORDER_SAVE_M, the Receiver port as A000000002 (created above), and the IDoc Basic type as CRMXIF_ORDER_SAVE_M01. In addition, fill the parameters, such as packet size and output mode, as appropriate and save the profile by clicking the save icon.
Step 2. Determine the External Recipient and Distribute the Order Output
Navigate to transaction SMOEAC (Admin Console) (Figure 4). Click the create object icon after choosing the Object Type as Site in the left navigation bar. This opens a dialog on the right side to create a new site. Enter a name and description for the site and choose the site Type as External Interface for IDocs from the drop-down menu.

Figure 4
Middleware site for IDoc processing with the attributes
Then click the Site Attributes button, which pops up a window in which you enter the attributes for the site. For IDoc Outbound Processing, enter the partner number created in step 1 as EDI Partner number and KU, which represents customer, as the EDI partner type, Click the Continue button and save the site by clicking the save icon.
For XML outbound processing, select the site Type as External Interface for XML (Figure 5). In the Site Attributes window, enter the RFC Destination for the receiving system created in step 1 as the Site Attributes (e.g., XI System).

Figure 5
Middleware site for XML processing with the attributes
Then assign the subscriptions for business transactions for this site. Subscriptions determine the distribution of data to sites based on publications. In my example, since I want to distribute the order information to the site, I assign the subscription for business transactions. To do this, click the create icon on the Subscriptions tab (Figure 4 or Figure 5). In the window that pops up, enter All Business Transactions (MESG) in the Publication field and click the Continue button. This brings up a window with the subscription All Business Transactions (MESG) Subscription linked to the publication.. Click the copy icon, which assigns the subscription to the site (Figure 6).

Figure 6
Site with subscription for business transactions
The next step involves XIF customizing to assign the Site and BDoc Type to the XIF adapter interface. Navigate to transaction CRMXIF_C1 (Figure 7) and in change mode, click the New Entries button on the toolbar. In the New Entries screen, maintain an entry with the following details:
- Site Name: EDI_TEST (created above)
- BDoc Type: BUS_TRANS_MSG (standard BDoc type for business transactions)
- Interface Name: CRMXIF_ORDER_SAVE (standard XIF adapter for orders)
- Complete check box: Selected

Figure 7
XIF customizing
Note
Once you complete step 1 and step 2, you can test the generation of IDocs for orders using test program CRMXIF_ORDER_TEST.
Step 3. Configure Actions to Trigger the XIF Adapter
You can call the XIF adapter from actions using the Business Add-In (BAdI) EXEC_METHODCALL_PPF. Create an implementation of the BAdI by copying the standard implementation CRM_ORDER_SEND_BY_ID. In this implementation, in the method Execute replace the value of the constant lc_site_name with the middleware site name created in step 2. Click the save icon and then click the activate icon to activate the implementation.
Figure 8 shows the code for method Execute where the constant value is replaced with the middleware site name EDI_TEST created in step 2.

Figure 8
BAdI implementation to call the XIF adapter
Next create an action profile with an action that:
- Calls this BAdI automatically once the order is released
- Is dependent on the distributor partner function
Follow IMG menu path CRM > Basic Functions > Actions > Actions in Transactions > Change Actions and Conditions > Define Action profiles and Actions. Click the New Entries button on the toolbar, which opens a dialog to create a new action profile on the right side. Enter a suitable name and description for the Action Profile, BUS2000115 as the Object Type name, and CL_DOC_CONTEXT_CRM_ORDER as the Context Class (Figure 9). Click the save icon to save the action profile.

Figure 9
Action profile definition
Next you create actions under the action profile. You can create actions for the IDoc and for XML processing. To do this, double-click the Action Definition node in the tree structure on the left side of the screen in Figure 9. Then click the New Entries button, which opens a dialog to create a new action definition on the right side. Enter a suitable name and description for the action and enter the following details in this dialog (Figure 10):
- Processing Time: Processing when saving the document. This means the action would be triggered automatically when the order is saved.
- Schedule Automatically check box: Selected
- Executable in Dialog and Changeable in Dialog check boxes: Selected. This means the action can be executed and changed from within the order, if required.
- Partner-Dependent check box: Selected, with the Partner Function listed as Distributor. This means that the action is executed only when Distributor is present on the order.

Figure 10
Action definition
Then assign the processing method Method Call to the action. To do this choose the Processing Types node in the tree structure on the left side of the screen in Figure 10, which opens a dialog to add processing types on the right side. Click the New Entries button on this dialog. Using F4 help in the Permitted Processing Types of Action table, choose the processing type as Method Call. Select this processing type and click the Set Processing button, which opens the settings for the Method Call. In the Method field add the BAdI implementation created above as the processing method, using F4 help (Figure 11). Click the save icon to save the action definition.

Figure 11
Processing type settings for the action definition
Further, you can set conditions on actions by following IMG menu path CRM > Basic Functions > Actions > Actions in Transactions > Change Actions and Conditions > Define Conditions. Figure 12 shows the start condition on an order status. The action executes only when the order is released.

Figure 12
Action condition based on order status
Finally, assign the action profile to the transaction type of order by following IMG menu path CRM > Basic Functions > Actions > Actions in Transactions > Assign Action Profile to Business Transaction type (Figure 13).

Figure 13
Assign an action profile to the transaction type
Now, when the order is released, the action executes automatically on save, and this in turn triggers the XIF adapter, which generates IDocs or XML for the order (Figure 14).

Figure 14
Action processed successfully after the order is released
Figure 15 shows an IDoc of message type CRMXIF_ORDER_SAVE_M generated for the order with status 03 (data passed to port).

Figure 15
Outbound IDoc generated with status 03
Note
For XML outbound processing, no trace of the XML message is left behind on the SAP CRM server. It is generated in memory from the BDoc and sent directly to its destination.
Shaik Shavali
Shaik Shavali has worked on SAP for seven-plus years focusing on SAP CRM and its integration points. He has been involved with multiple SAP CRM implementations worldwide. He is working with Rockwell Automation as an SAP CRM analyst involved in the global process transformation team for SAP deployment.
You may contact the author at sshaik@ra.rockwell.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.