Routing Messages Through Adapter for SAP
Introduction
This chapter describes how to route messages through Adapter for SAP.
When Adapter for SAP receives the IDoc or RFC, it matches the sender, receiver, and message type associated with the IDoc or RFC to its routing notifications. When it locates a matching routing notification, this is invoked to route the IDoc or RFC.
This chapter includes information about how to:
- Create and maintain routing notifications
- Update services that process routing notifications
- Map IDocs to other formats
- Use content based routing for IDocs and arbitrary XML documents as well as outbound mapping for IDocs
For specific information about how to:
Overview
Normally, the RFCs and IDocs sent to Adapter for SAP from an SAP system are assigned to a specific service by an adapter notification. However, in some cases, you might want to route an RFC or IDoc through the routing listener.
Adapter for SAP includes a default routing listener that manages the routing of messages. It determines how and where to route a message based on routing notifications that you define. Each routing notification is associated with a transport that will be chosen and invoked when the routing notification is called.
When the routing listener receives a message, it performs a routing notification lookup. After locating the routing notification for the incoming message, the specified outbound transport gets invoked.
Routing notifications indicate how a message is to be processed. Each routing notification is uniquely identified by its sender, receiver, and message type. When Adapter for SAP receives a message, it performs a routing notification lookup to match the sender, receiver, and message type of the incoming message with the sender, receiver, and message type of the existing routing notifications.
If a matching routing notification is found, Adapter for SAP processes the message as the routing notification indicates. If a routing notification is not defined for the message, processing of the message will be aborted with an exception thrown.
The routing notification identifies a transport, which indicates how and where a message is to be routed. The transports you can specify allow you to route a message to a service, route an IDoc to an SAP system via tRFC, route an RFC/BAPI to an SAP system via RFC/tRFC, or post an IDoc-XML, RFC-XML, or bXML message to a URL.
Components of a Routing Notification
- Sender, receiver, and message type.
- A flag that indicates whether the
Confirmevent should be forwarded to the receiver. - A flag that indicates if incoming IDocs should be tracked to later ALE monitoring from the calling system (Takes effect only if the request was received via a RFC listener).
- How to route the message; that is, the transport.
- Additional parameters based on the selected transport.
Sender, Receiver, and Message Type
This information uniquely identifies a routing notification. The routing listener matches incoming messages to these fields to locate the routing notification to process the incoming message.
When a message is submitted, it must provide the routing listener with sender, receiver, and message type values. The sender, receiver, and message type values contain the following information:
| Value | Description |
|---|---|
| sender | An arbitrary string that indicates who sent the message. |
| receiver | An arbitrary string that indicates the message's destination. |
| message type | Identifies the type of information the message contains (for example: a purchase order, a credit memo, an invoice, and so forth). |
This replaces the sender/receiver information from the IDoc control record (SNDPRN and RCVPRN) by partner information from the E1EDKA1 segment. If this is not desired, disable this Content Based Routing from Adapters \> IBM webMethods Adapter for SAP \> Routing/Mapping.
You can write your own service for routing based on the fields which are used in your environment. You can use Content Based Routing for this purpose.
Refer to Constructing an IDoc with the SAP Java IDoc Class Library and Built-in Services for the APIs to parse the IDoc.
Forward Confirm Event Flag
Routing notifications support the forward Confirm event feature as described at Forward Confirm Event Flag.
A call sequence in this case could be as follows:
- The client creates a 24 alphanumeric GUID (or calls pub.sap.client:createTID to obtain one from the SAP ECC (or R/3) system).
- The client sends the document to
one of the InboundProcesses (for example an IDoc-XML to the pub.sap.transport.ALE:InboundProcess) and passes the
TID along in the header field "
X-TID: <tid>". The routing notification which processes this message should have theForward ConfirmTID Eventflag set to "true". - If and only if the client receives
a return code 200 from Adapter for SAP in step, it calls the same InboundProcess again with
$actionset to 4 (Confirm) like this:This achieves two things: The state in Adapter for SAP's transaction store is set to
Confirmed, and the entry in the receiving SAP system's tRFC check table (ARFCRSTATE) is cleaned up. This may be important for tRFC performance, if the SAP system receives large numbers of documents. - If the client
receives an error return code in step 2 or no response at all, it may later resubmit the same
document (using the same TID) without needing to fear duplicate processing. Then, after one of the
subsequent tries has finally succeeded, the TID can be
confirmedas described in step 3.
Confirm event has already been executed, this will lead to
a duplicate document. The Confirm event should only
be called if the client knows that the document has been processed without error and will therefore
never resubmit this document again. Routing Notification Order
A routing notification is executed when its Sender, Receiver, and Message Type values match an incoming document's values. When one or more of those values is a wildcard (*), then the routing notification is matched and executed based on its value precedence.
You can change this precedence order by modifying the notification order defined for the routing listener.
Considerations for Routing Notifications
For the routing listener, configure a default notification that processes all messages that are not associated with any other type of Adapter for SAP notification. From the Integration Server Administrator, edit the routing listener's notification order list and place the default notification last. For instructions on how to configure a notification, see Routing Notifications. For instructions on how to edit the notification order list, see Routing Notification Order.
Using Wildcards as Routing Criteria
You can use a single asterisk character (*), known as a wildcard, for the Sender, Receiver, and Message Type values in a routing notification. A wildcard matches any value that may be submitted with an incoming document. You can:
- Use a wildcard for the Sender parameter to serve as a “catch all” routing notification for a specific company. For example, suppose that you want to execute a particular routing notification for all documents from XYZ Company. You do not necessarily want to define routing rules for each message type that might be sent from XYZ Company, so you use the wildcard character (*) for the Message Type.
- Use a wildcard for all parameters (Sender, Receiver, and Message Type) to serve as a “last resort” routing rule. This routing rule will be executed when no other routing rules match the incoming document.
Example
Suppose that you have routing notifications set up with the following values and notification order:
| Sender | Receiver | msgType | |
|---|---|---|---|
| 1. | CERCLNT800 | partner1 | ORDERS |
| 2. | * | partner1 | ORDERS |
| 3. | CERCLNT750 | * | ORDERS |
- Sender = CERCLNT800
- Receiver = partner1
- msgType = ORDERS
it will be routed according to the first routing notification as it has a higher ranking compared to the second routing notification.
- Sender = CERCLNT750
- Receiver = partner1
- msgType = ORDERS
would be routed according to the second notification, not the third.
Editing the Notification Order of a Listener
About this task
To edit the notification order of a listener
Procedure
- In the Adapters menu in the navigation area of the administrator, click IBM webMethods Adapter for SAP.
- In IBM webMethods Adapter for SAP menu, click Listeners.
- Select the routing listener (wm.sap.internal.ls:routingListener) and change the State to Disabled.
-
Click the
icon for the routing listener.
- On the Edit Listener screen, click Edit Notification Order.
- On the Edit Notification Order screen, use the Up and Downbuttons to determine the processing order in which Adapter for SAP invokes the notifications.
- Click Save Changes to save the notification order of the listener.
- ClickReturn to Edit Listeners to return to the Edit Listeners screen.
- Click Return to IBM webMethods Adapter for SAP Listeners to return to the Listeners screen.
- Change the State of the routing listener to Enabled.
Routing the Message (Transport)
The transport indicates how Adapter for SAP will route the message (for example, route it to a service on the local or a remote host). The transport can be one of the following:
| Transport | Description |
|---|---|
| IS | Routes the message to a service on the local Integration Server. |
| ALE | Routes an IDoc to an SAP system via tRFC. |
| RFC | Routes an RFC to an SAP system via RFC or tRFC. |
| XML | Posts a bXML, IDoc- or RFC-XML to a URL. |
| BAPI | Routes a BAPI to an SAP system via RFC or tRFC. |
Based on the transport you select, the Notification Editor displays additional fields required by the selected transport.
Routing Notifications
Configuring a Routing Notification
About this task
Use the following procedure to create and configure a routing notification.
To create a routing notification
Procedure
IS Transport
Use this transport to route messages to another service that executes on the
local machine or on a remote Integration Server. The entire pipeline is submitted to the specified routing notification
service. If you connect to a remote Integration Server, you should edit
the assigned service of this routing notification and add a MAP step before the invoke step pub.remote:invoke, where you drop all unnecessary
parameters from the pipeline so that the amount of data sent over the network is as small as
possible. The IS Transport supports the Forward Confirm event feature. In case of $action set to 4 (Confirm event), the assigned service is called a second
time. You can add pre- and post-processing steps to the pipeline if you wrap the service you want
invoke and assign the wrapper service to the routing notification.
IDOC_CONTROL_REC_40andIDOC_DATA_REC_40. ALE Transport
Use this transport to route an IDoc to an SAP system via tRFC. Before you can route an IDoc to an SAP system, you must define the RFC connection to that SAP system. For instructions, refer to Configuring Adapter Connections.
Set the Configure ALE Transport parameters as follows:
| Key | Value |
|---|---|
| serverName | Name of the SAP system to which you want to route the
IDoc. Select an RFC connection alias from the drop down list. The drop down list contains the RFC connection aliases as defined on Adapter for SAP. For instructions on how to define an RFC connection to an SAP system, refer to Configuring Adapter Connections. |
RFC Transport
Use this transport to route the execution of an RFC function module to an SAP system by using RFC or tRFC.
Set the transport parameters as follows:
| Key | Value |
|---|---|
| serverName | Name of the SAP system to which you want to route the RFC.
Select an RFC connection alias from the drop down list. The drop down list contains the RFC connection aliases as defined on Adapter for SAP. For instructions on how to define an RFC connection to an SAP system, refer to Configuring Adapter Connections. |
BAPI Transport
Use this transport to route an BAPI to an SAP system via RFC or tRFC.
Set the transport parameters as follows:
| Key | Value | |
|---|---|---|
| serverName | Name of the SAP system to which you want to
route the BAPI. Select an RFC connection alias from the drop down list. The drop down list contains the RFC connection aliases as defined on Adapter for SAP. For instructions on how to define an RFC connection to an SAP system, refer to Configuring Adapter Connections. |
|
| Processing restrictions | Processing restrictions: Some BAPIs can be called both synchronously and asynchronously. Callers can choose how they want to execute a call by specifying a transaction id in the XML header (see Using BizTalk Envelopes with Adapter for SAP). If you only want to allow one specific type of call (for example for performance reasons only asynchronous calls, or for administration reasons only synchronous calls). You can define restrictions using the drop down list: | |
| no restrictions | Caller may decide to send both synchronous and asynchronous calls. | |
| synchronous only | Caller may only send calls without a transaction ID. Messages with a transaction ID (asynchronous messages) are rejected and an XML error message is returned. | |
| asynchronous only | Caller may only send calls with a transaction ID. Messages without a transaction ID (synchronous messages) are rejected and an XML error message is returned. | |
XML Transport
Use this transport to post an SAP IDoc- or RFC-XML to a URL.
Set the transport parameters as follows:
| Key | Value |
|---|---|
| url | URL to which you want to post the XML message. |
| xmlType | Select between the XML dialects SAP-XML, bXML, Values-XML,
Arbitrary XML or SOAP XRFC (XRFC with SOAP envelope). If you select SAP-XML the content type is set to If Arbitrary XML is selected, the transport expects the XML document as string in the variable xmlData. |
| useTextXml | Flag that allows you to overwrite the content type of bXML, SAP-XML to text/xml, if set to true. The checkbox is disabled for other dialects. |
| useUTF8 | Flag that allows you to force the renderers of bXML, SAP-XML to use the encoding utf-8, if set to true. The checkbox is disabled for other dialects. |
| useBAPI | Set this flag if you want to use the BAPI XML format. (This field is only active when using the bXML dialect.) |
| objectName | The name of the business object to which the call should be mapped. This value is case-sensitive. (Available only when using the bXML dialect and the BAPI format.) |
| bapiName | The name of the BAPI method, to which the call should be mapped. This value is case-sensitive. (Available only when using the bXML dialect and the BAPI format.) |
| httpUser | An optional parameter that allows you to specify a username for authentication on the remote Web system. |
| httoPassword | An optional parameter that allows you to specify a password for authentication on the remote Web system. |
http://<hostname>:<port>/invoke/pub.sap.transport.ALE/InboundProcess as URL.
When sending an RFC to a second Adapter for SAP over HTTP, use
http://<hostname>:<port>/invoke/pub.sap.transport.RFC/InboundProcess as URL.
When the routing listener receives a message for which it cannot locate a routing notification, it logs the message in its transaction store and throws an Exception.
Disabling Routing Notifications
About this task
Use the following procedure to disable a routing notification. When you disable a routing notification, all routing service and rule information is preserved until you re-enable it. But incoming messages for this sender/receiver/msgType combination will not be routed by Adapter for SAP as long as the routing notification is disabled.
To disable a routing notification
Procedure
- In the Adapters menu in the Integration Server Administrator navigation area, click IBM webMethods Adapter for SAP.
- In IBM webMethods Adapter for SAP menu, click Listener Notifications.
- Locate the routing notification that you want to disable. Under Enabled, click Yes until it turns to No.
Deleting Routing Notifications
About this task
When you no longer need a routing notification, you can delete it. Perform the following procedure to delete a routing notification.
To delete a routing notification
Procedure
- In the Adapters menu in the Integration Server Administrator navigation area, click IBM webMethods Adapter for SAP.
- In IBM webMethods Adapter for SAP menu, click Listener Notifications.
-
Select the routing notification you want to delete and click
in Delete column.
Editing a Routing Service
When necessary, you can wrap the transport service into a customized service before assigning it to a routing notification. You can edit your wrapper service to incorporate additional operations before or after the transport delivers the message. For example, you can insert a post-processing or pre-processing service, or you can include some error handling operations after the transport service.
You can update the flow service to digitally sign a message before it is routed. Or, if you want to FTP an IDoc in EDI flat file format, you would insert the step pub.sap.idoc:encodeString. If the outbound data should be an XML document, you would use pub.sap.idoc:encode instead, or your own mapping service that creates the format of your choice.
Sending an RFC from an SAP System to Adapter for SAP
You can only route an RFC if you provide a valid SBCHEADER with your function call. To route RFCs through the routing listener, you must include a header table that contains information that the routing listener uses to route the RFC.
To send an RFC to the routing listener, you must configure the SAP system to register the RFC listener as an RFC destination. For instructions on how to create an RFC Destination, refer to Creating an RFC Destination on an SAP System.
The SBCHEADER Table
You can write an ABAP wrapper that calls a function module with an RFC destination and add an additional table to the call statement.
The name of the table must be SBCHEADER and it must have the following structure.
| Component | Component type | DTyp | Length | Dec. places | Short text |
|---|---|---|---|---|---|
| NAME | SBCNAME | CHAR | 32 | 0 | SBC routing table, Keyfield |
| VALUE | SBCVALUE | CHAR | 255 | 0 | SBC routing table, value of Keyfield |
This structure is defined in the SAP system starting with release 4.6A under the name SBCCALLENV. If you do not have this structure in your system, define a similar one as above.
The header table can contain an arbitrary number of key/value pairs. If you want to pass additional keys to Adapter for SAP, you can define your own name/value pairs and insert them into the SBCHEADER table.
You would read out these fields inside a java module in Adapter for SAP with the following statements (case-sensitive):
IDataCursor idc = pipeline.getCursor();
IData sbcHeader = IDataUtil.getIData( idc, "sbcHeader");
if (sbcHeader != null)
{
IDataCursor headerCursor = sbcHeader.getCursor();
String property = IDataUtil.getString( headerCursor, "myProperty");
headerCursor.destroy();
System.out.println("Property was "+property);
}
idc.destroy();
If you want Adapter for SAP to invoke a routing notification to route the RFC, the header table must contain the sender and receiver for the RFC. When determining the routing notification to invoke, the routing listener uses the sender and receiver you specify in the header table and matches message types against the RFC name in place of a message type.
To have Adapter for SAP use a routing notification, include the following information in the header table:
| Keys | Value |
|---|---|
sender
|
Name of the sender. This name should match the name of a sender in the routing notification you want the routing listener to use to route the RFC. |
receiver
|
Name of the receiving partner. This name should match the name of the receiver in the routing notification you want the routing listener to use to route the RFC. |
If you want to control the routing of an RFC from the SAP system directly
(without requiring a routing notification on Adapter for SAP), you can
include transport information in the header table.
The transport indicates where Adapter for SAP is to route the incoming RFC. When Adapter for SAP receives an RFC
that specifies the transport, it does not invoke a routing notification but directly passes the RFC
to the specified transport. The transports that you can identify in a header table to dynamically
route an RFC through Adapter for SAP are:
- Route the RFC to an Integration Server service
- Route the RFC to an SAP system
- Post the RFC-XML to a URL
The following describes the key/value pairs you must specify for each transport you can specify.
- To route the RFC to an Integration Server service, use Integration Server service
transport.
Key Value transportISThis value identifies the transport. Specify the value exactly as specified above.
serverAliasName of the Integration Server on which the service to invoke resides. If the service resides on the server that routes the message, specify (local). Otherwise, specify an alias for a remote server. For the routing to be successful, the server routing the RFC must have the defined alias for the remote server. folderNameName of the folder in which the service resides. The folder name is case sensitive; use the exact combination of upper and lower case letters. serviceNameName of the service to which to pass the RFC. The service name is case sensitive; use the exact combination of upper and lower case letters. valueScopeWhere you want Adapter for SAP to store the connection to the remote server. To save the connection in your own session, specify
SESSION. UseSESSIONwhen the work being performed requires state be maintained.To save the connection in a shared area, specify
GLOBAL. UseGLOBALwhen the work being performed is stateless.
- To route the RFC to an SAP system,
use the RFC transport.
Key Value transportRFCThis value identifies the transport. Specify the value exactly as specified above.
serverNameRFC Connection alias to which you want the RFC routed.
- To post the RFC-XML to a URL, use
the XML transport.
Key Value transportXMLThis value identifies the transport. Specify the value exactly as specified above.
urlURL to which you want to post the RFC. xmlTypeThe XML format you want the routing listener to use for the RFC. Specify SAP-XML if you want the RFC in an XML format that is compliant with the SAP XML specification. Specify Values-XMLif you want the RFC in webMethods native XML format.httpUserUser name to supply for a user name/password authentication challenge (optionally). httpPasswordPassword to supply for a user name/password authentication challenge (optionally).
For sending RFCs as bXML, please refer to RFC Based XML Messages Using IFR Format.
Example of Using an SBCHEADER Table
To test a function module with the function builder, write a wrapper module. The wrapper module calls your RFC function module.
For example, you want to invoke a function module called Z_DEMO_COPY. It echoes the input of type CHAR255 received in the INPUT parameter to the OUTPUT parameter. In the wrapper module Z_WRAPPER_DEMO_COPY, you would define an additional input parameter named DESTINATION and a table named SBCHEADER.
A wrapper for Z_DEMO_COPY could look like this:
FUNCTION Z_WRAPPER_DEMO_COPY.
*"------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(INPUT) TYPE CHAR255 OPTIONAL
*" VALUE(DESTINATION) TYPE CHAR32
*" EXPORTING
*" VALUE(OUTPUT) TYPE CHAR255
*" TABLES
*" SBCHEADER STRUCTURE SBCCALLENV
*"------------------------------------------------------------------
data:
msg TYPE CHAR1024.
CALL FUNCTION 'Z_DEMO_COPY' DESTINATION destination
EXPORTING
input = input
IMPORTING
output = output
TABLES
sbcheader = sbcheader
EXCEPTIONS
no_input_given = 1
communication_failure = 2 message msg
system_failure = 3 message msg
OTHERS = 4.
CASE sy-subrc.
WHEN 1.
output = 'Exception received: NO_INPUT_GIVEN' .
WHEN 2.
concatenate 'COMMUNICATION_FAILURE received:' msg into output separated
by space.
WHEN 3.
concatenate 'SYSTEM_FAILURE received:' msg into output separated
by space.
WHEN 4.
output = 'Exception received: OTHERS'.
ENDCASE.
IF sy-subrc <> 0.
WRITE output.
ENDIF.
ENDFUNCTION.
The following example illustrates how to route the Z_DEMO_COPY function module to Adapter for SAP and invoke a routing notification to route the message. When testing the function module from the SAP Gui, provide the following input values:
| INPUT | Hello ...! |
| DESTINATION | ISCER |
| SBCHEADER |
sender CERCLNT800 receiver DELL |
The SAP system routes the RFC to the specified RFC-Destination ISCER (which corresponds to the name of the RFC listener). In Adapter for SAP, the routing listener invokes the routing notification that corresponds to the sender CERCLNT800, receiver DELL, and message type Z_DEMO_COPY. To determine how Adapter for SAP routes Z_DEMO_COPY function module, you would need to inspect the corresponding routing notification that the routing listener invokes.
The following example illustrates how to route the Z_DEMO_COPY function module to Adapter for SAP and directly invoking an outbound transport. When testing the function module from the SAP GUI, provide the following input values:
| INPUT | Hello ...! |
| DESTINATION | ISCER |
| SBCHEADER |
transport RFC serverName CERCLNT750 |
In this case, the SAP system routes the RFC to the specified RFC-Destination ISCER. In Adapter for SAP, the header table gets interpreted directly to determine how to route the RFC. Adapter for SAP routes the message to the SAP system known as CERCLNT750 on Adapter for SAP using transport RFC. Note that CERCLNT750 must correspond to the connection alias of an RFC connection that is configured in Adapter for SAP.
Sending a BAPI from an SAP System to Adapter for SAP
SAP systems communicate with Adapter for SAP on an implementation-level when calling BAPIs. This means, they try to call the implementing function module directly via RFC or, if asynchronous processing is used, they send an IDoc.
Adapter for SAP has a built-in converter to automatically rebuild the original object-based BAPI method call and represent it as an XML message. Therefore, the XML transport can handle these messages using the XML dialect bXML, to build a BAPI-style XML message.
To activate this function, you have to specify a routing notification that maps the BAPI call to the XML transport. The message types used in the routing notification for routing are based on the BAPI implementation. For messages received from an SAP system, this means:
- The RFC name of the BAPI implementation is used for synchronous calls
- The corresponding ALE message type is used for asynchronous calls
These message types can be found using the built-in BAPI browser. At the routing notification setup, you have to specify the name of the business object and BAPI to which the call should be mapped.
Setting Up a Routing Notification for the XML Transport
About this task
To enable this function, you will first have to setup an RFC Listener for the relevant SAP systems as explained in Configuring an RFC Listener.
To create a routing notification
Procedure
Results
- Use text/xml as content type: Flag that allows to overwrite the content-type of bXML, SAP-XML to text/xml, if set to true.The checkbox is disabled for other dialects.
- Use utf-8 as encoding: Flag that allows to force the renderers of bXML, SAP-XML to use the encoding utf-8, if set to true.The checkbox is disabled for other dialects.
- SOAP XRFC can be selected as additional XML dialect. This is equivalent to XRFC (RFC-XML) with a SOAP envelope (higher than SOAP 1.1).
Dynamic Routing Using the XML Transport
It is not always necessary to specify routing notifications. If you want to call a BAPI from an ABAP report in your SAP system, you can also add the SBCHEADER parameter to your function module call. This parameter can be filled with key-value pairs that describe in detail how the message should be routed. At the moment, it is only possible to route BAPI-calls to the XML transport. To do this, use the following key pairs in the SBCHEADER table:
| Name | Value |
|---|---|
| Transport | XML |
| url | The destination URL for the HTTP post operation |
| xmlType | bXML |
| httpUser (optional) | An optional parameter that allows you to specify a username for authentication on the remote web system |
| httpPassword (optional) | An optional parameter which allows you to specify a password for authentication on the remote web system |
| useBAPI | Set this value to YES if you want to use the BAPI XML format. If you omit this value or set it to something
different than YES, the message will be sent as RFC
based XML in a BizTalk XML envelope. |
| objectName | The name of the business object, to which the call should be mapped. This value has to be case-sensitive. |
| bapiName | The name of the BAPI method, to which the call should be mapped. This value is case-sensitive. |
| xsender | A value that should be put in the header element <from> <address>. See senderType for
further details. |
| senderType (optional) | An optional format descriptor, defining the sender address
type. Default is LogSys for logical systems.
Logical system names are automatically converted to an URN by an SAP defined schema. Alternatively,
you can set senderType. |
| xreceiver | A value that should be put in the header element <to> <address>. See receiverType for further
details. |
| receiverType (optional) | An optional format descriptor, defining the receiver
address type. Default is LogSys for logical
systems. Logical system names are automatically converted to an URN by an SAP defined schema.
Alternatively, you can set receiverType. |
| useTextXml | Flag that allows to overwrite the content-type to
text/xml, if set to Yes (for SAPXML and bXML).
|
| useUTF8 | Flag that allows to force the renderers to use the
encoding utf-8, if set to Yes (for SAP-XML and
bXML). |
For sending RFC based XML messages, only the first five parameters are supported. You can specify this parameter to your ABAP RFC as follows:
DATA header like SBCCALLENV occurs 1 with header line.
*... some code lines omitted
CALL FUNCTION 'BAPI_COMPANYCODE_GETLIST'
DESTINATION 'ISCER'
IMPORTING
RETURN = returnCode
TABLES
COMPANYCODE_LIST = companyCodes
SBCHEADER = header
.
For a synchronous example, see Calling a BAPI Synchronously from SAP System. For an asynchronous example, see Calling a BAPI Asynchronously from an SAP System.
Sending IDocs with ALE from an SAP System to Adapter for SAP
The routing listener receives IDocs from an SAP system if the function module (INBOUND_IDOC_PROCESS or IDOC_INBOUND_ASYNCHRONOUS) has no RFC adapter service associated with it. When the routing listener receives the IDoc, the sender, receiver and message type are extracted from the IDoc itself. The routing listener uses this information when determining where to route the IDoc.
Routing RFCs Through Adapter for SAP
Posting RFC Based IFR-compatible XML Messages
Adapter for SAP supports the
XML format for use with arbitrary RFC function modules. By using the new content-typeapplication/x-sap.busdoc, which is also used for BAPIs, you
can easily post RFC function calls to Adapter for SAP.
These XML messages must provide a BizTalk XML envelope (for further information, see Using BizTalk Envelopes with Adapter for SAP). The call of the corresponding business document for the RFC function can be put in the body of the BizTalk message.
By using the BizTalk XML envelope and this content-type, you also enable the support for the new application-specific XML error documents, which are defined in the SAP Interface Repository.
You can post to the generated proxy services URL for the RFC function modules, or to the RFC routing gateway
http://<server>:<port>/invoke/pub.sap.transport.RFC/InboundProcess
RFC Based XML Messages Using IFR Format
You can also generate XML calls for RFC function modules that are based on the IFR XML format. To do this, select bXML as the XMLType at the routing notification for RFC messages, and ensure that useBAPI is set to No.
Posting RFCs via FTP
Perform the following steps to FTP an RFC-XML document to the routing listener:
open <Integration Server host> <port of ftp listener>
username: Administrator
password: manage
cd ns/pub/sap/transport/RFC/InboundProcess
bin
put example.xrfc
The FTP client should check the return code to find out whether the document processed properly.
.xrfc. Posting RFCs in an E-mail Message
To send an RFC-XML document to the routing listener in an e-mail message, put
the document into an attachment whose name ends with .xrfc. In the subject line of the e-mail specify pub.sap.transport.RFC:InboundProcess.
Routing BAPIs Through Adapter for SAP
Setting Up a Routing Notification and the BAPI Transport
Inbound messages in the BAPI-based XML format can be easily dispatched using routing notifications.
For each BAPI sent via XML to Adapter for SAP, a corresponding routing notification should exist. If no entry exists, the message will not be executed and Adapter for SAP will throw an exception.
The message type used in the routing notification for BAPIs is constructed from the concatenation of the business object name and the BAPI name, which are separated by a dot. (the syntax is <Business Object>.<BAPI method name>).
The only transport applicable to inbound BAPI calls is the BAPI transport.
Posting BAPI-based XML IFR-Compatible XML Messages
To apply the routing notification, the XML message should be posted to Adapter for SAP. The receiving service should be pub.sap.transport.BAPI:InboundProcess.
Execute an HTTP post operation to:
http://<host>:<port>/invoke/pub.sap.transport.BAPI/InboundProcess
In the HTTP body, an XML message specifying the BAPI-call as described above
must be sent. You have to use the HTTP content type application/x-sap.busdoc when posting to Adapter for SAP.
POST /invoke/pub.sap.transport.BAPI/InboundProcess HTTP/1.0
Content-Type: application/x-sap.busdoc
User-Agent: Java1.1.8
Host: localhost:5555
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*;
q=.2
Connection: keep-alive
Content-length: 817
<?xml version="1.0"
encoding="iso-8859-1"?>
<biztalk_1 xmlns="urn:biztalk-org:biztalk:biztalk_1">
<header>
<delivery>
<message>
<messageID>0A125F1315B3D24B0000001E</messageID>
<sent>2000-06-20T09:58:00</sent>
</message>
<to>
<address>urn:sap-com:logical-system:SAPSYS0001</address>
</to>
<from>
<address>urn:sap-com:logical-system:SAPADA0001</address>
</from>
</delivery>
</header>
<body>
<doc:CompanyCode.GetList xmlns:doc="urn:sapcom:
document:sap:business" xmlns="">
<CompanyCodeList>
<item>
<COMP_CODE></COMP_CODE>
<COMP_NAME></COMP_NAME>
</item>
</CompanyCodeList>
</doc:CompanyCode.GetList>
</body>
</biztalk_1>
Transaction Control
You can control whether the BAPI should be called synchronously via RFC or
asynchronously via ALE by the<referenceID>
element in the BizTalk header.
If the <referenceID>
element is specified and contains a valid SAP transaction ID (TID), the BAPI outbound process
automatically chooses the ALE format, otherwise, if the element is omitted, the message will be
processed synchronously.
For both synchronous and asynchronous calls, technical processing errors are reported by an XML response document containing a fault descriptor.
BAPI XML Transaction Commit
About this task
When running a BAPI call with Adapter for SAP in some cases the SAP system expects a commit command to execute the call.
To commit the transaction directly over HTTP
Procedure
Synchronous Calls
Application-level responses to synchronous XML requests are reported using a response business document in the HTTP response. The response business documents for synchronous calls are documented in the SAP Interface Repository and contain a serialization of all exporting and changing parameters of the BAPI or function module.
Example
- Sending a synchronous call to an
SAP system

- It returns a response business
document.

Asynchronous Calls
An asynchronous call can be executed by specifying a transaction ID in the
BizTalk header of the XML document. The XML element used is the <referenceID>-element (see description of the BizTalk
XML envelope) in the <receiver>-section of
the BizTalk header.
A transaction ID should be a global unique ID expressed in hexadecimal letters and 24 letters long, for example 0A11449F652C394A34DE042F. If an asynchronous request can be transmitted without errors inside the SAP system, Adapter for SAP will return a BizTalk envelope with an empty body as confirmation document. If there were any processing errors, the body will contain a fault descriptor element. The result of an asynchronous call can be checked inside the target system by using the ALE monitoring services (BD87) in a 4.6 SAP system. Please refer to your SAP system documentation for further information on ALE services.
Example
- Sending an asynchronous request to
an SAP system by specifying a transaction ID

- Receiving an XML confirmation
document

- Checking the correct
application-level processing inside the target SAP system (BD87 in a 4.6 system or use the IDoc list
WE05):

Routing IDocs Through Adapter for SAP
If you submit an IDoc-XML document in one of the following ways, it will automatically be passed to the routing listener.
Posting an IDoc-XML Document from an HTTP Client
About this task
Use the following guidelines to submit an IDoc-XML document via any HTTP client:
POST /invoke/pub.sap.transport.ALE/InboundProcess HTTP/1.1\r\n
Host: <hostname of client>\r\n
Content-Type: application/x-sap.idoc\r\n
Authorization: Basic <base64-encoded user:password>\r\n
Content-Length: <number of bytes in XML document>\r\n
\r\n
<?>xml version="1.0"?>
<MATMAS02>
...
</MATMAS02>
To simulate an HTTP client for testing purposes, you can use the service pub.client:http
Procedure
Posting an IDoc via FTP
Perform the following steps to FTP an IDoc document to the routing listener:
open <Integration Server host> <port of ftp listener>
username: Administrator
password: manage
cd ns/pub/sap/transport/ALE/InboundProcess
bin
put example.idocxml
The FTP client should check the return code to find out wether processing of the document was ok.
.idocxml. Posting an IDoc in an E-mail Message
To send an IDoc document to the routing listener in an e-mail message, put the
document into an attachment whose name ends with .idocxml. In the subject line of the e-mail specify pub.sap.transport.ALE:InboundProcess.
Posting an IDoc from a Web Browser
You can submit an IDoc-XML for any IDoc type to the routing listener from a Web browser using the following page:
http://<host>:<port>/WmSAP/submitIDocXML.html
This sample page can be used as a test tool. If you plan to submit IDocs from an HTML form, you can use this page as sample code.
Transmitting IDocs between Two Integration Servers
About this task
To send IDocs over the Internet, use the following procedure to establish the connection between two Integration Servers (for example: your own and one belonging to your Business Partner).
To transmit IDocs between to Integration Servers
Procedure
Results
Mapping IDocs to Other Formats
If you need to use the information contained in an IDoc in documents of another format, you build a service that "maps" the information from fields in the IDoc to the variables used by the other application. For example, to transfer a purchase order from an ORDERS02 IDoc to an EDI system, you create a flow service that maps information from the IDoc fields to fields within the EDI system's purchase-order document. Then, you define a routing notification that triggers this flow service.
The following instructions will show you how to do this in detail:
Creating an Empty Flow Service
About this task
Use the following procedure to create a flow service named app.idocs:mapOrders02 with Designer (this is the service that the routing listener will invoke based on the routing rule created in the next stage).
To create an empty flow service
On the File menu, click New and create an empty flow service. You will select this service when creating a routing notification.
Creating the Routing Notification
The first step in building an application that maps information from an IDoc is to create a routing notification that invokes the flow service that will perform the mapping.
When you create the routing notification, select the service you have previously created for mapping the IDoc, and as the transport, select "IS Service".
The following example shows the routing notification you would create to pass the IDoc to a service called app.idocs:mapOrders02.
Creating a Document Type for Your IDoc
Regardless of the way in which you pass the IDoc to the flow, you need to create a document describing the content and structure of the IDoc. There are three ways to create this document:
- You can generate it directly by receiving the IDoc metadata information form an SAP system you have an RFC connection to. See Create an IDoc Document Type Using the DDIC for more information.
- You can generate it from the DTD for the IDoc. See Generating an IDoc Document Type from a DTD for more information.
- You can generate it from a "sample" IDoc that you capture with Designer at design time. See Generating a Document Type from a Sample IDoc for more information.
The first two options produce the most complete document because they are based on the IDoc's metadata defined at the SAP system or a DTD, which describes all possible fields in the IDoc. Use one of the first two options whenever possible.
Use the third option only if a DTD is not available for the IDoc with which you are working. Because this option derives a document from a sample document, there is no assurance that the document will include all possible fields. Fields that are not used in the sample document will not appear in the document type.
Transforming the IDoc to a Hierarchical Format
About this task
To extract information from an IDoc, your flow service must transform the IDoc
into a hierarchical structure and generate a document type whose elements correspond to the fields
in the IDoc. To do this, either use the iDocToDocument service (if the IDoc will be received by Adapter for SAP through tRFC or
through http POST with Content-Type: application/x-sap.idoc) or the xmlNodeToDocument service (if the IDoc will be received via http POST with
Content-Type:text/xml).
To transform the IDoc to hierarchical format
Procedure
-
Click the
icon on the Flow Pane toolbar and select the pub.sap.idoc:iDocToDocumentservice or the pub.web:xmlNodeToDocument service. (If this service
does not appear in the list, select Browse...to locate it.) Either service transforms the IDoc into a document variable, which contains the contents of
the IDoc in a format that you can map to other pipeline variables.
-
Click the
icon to save this flow service.
Mapping IDoc Information to Pipeline Variables
About this task
After transforming the IDoc into a document, you can map the fields of the IDoc to other variables in the pipeline (for example, to variables in a cXML or OAG document). To do this, you must add a MAP operation to the flow, insert document types for the IDoc and the target document, and then map fields in the IDoc to the appropriate variables in the other document.
The following procedure describes how to add the MAP operation to the service and configure the MAP operation to copy values from the IDoc to other variables in the pipeline.
To map the IDoc to variables in the pipeline
Perform the following steps to add a Document Type describing the content and structure of the IDoc.
Procedure
Defining Variables to which to Map Information from the IDoc
About this task
Perform the steps in the procedure below to define the variable(s) to which you want to map information from the IDoc.
To define the variable(s) to which you want to map information from the IDoc
Procedure
Results
Testing the Mapping Service
About this task
To test the flow service you created, use the SAPGui or the /WmSAP/submitIDocXML.html utility to submit your sample IDoc to Adapter for SAP. Make sure to specify the sender, receiver, and message type that you used for the routing rule that you created in Configuring a Routing Notification.
Check the results of the service to ensure that the IDoc is being mapped correctly.
If you want to debug your service in Designer, you can use the savePipelineToFile and restorePipelineFromFile services to capture a submitted IDoc.
To test the mapping service
Procedure
- Use the SAPGui or the /WmSAP/submitIDocXML.html utility to submit an IDoc to your flow service. When the service executes, the savePipelineToFile operation will make a copy of the pipeline (which will include your IDoc) and save it to file.
- Delete the savePipelineToFile service and insert the restorePipelineFromFile service.
- Select the Test > Run command to execute the flow service. When it executes, the restorePipelineFromFile service will retrieve the copy of the pipeline containing your IDoc, which the remainder of the flow will operate on.
- When you are finished testing, delete the restorePipelineFromFile service and save the finished flow.
Content-Based Routing and Mapping for IDocs
About this task
Occasionally, you must do some manipulation on IDocs before processing them in Adapter for SAP or before sending them to an SAP system. This will happen with customized IDocs that need specific processing. The two most common manipulations are content based routing and mapping. Both mechanisms can be performed on IDocs routed through Adapter for SAP. For IDocs going to an SAP system, only mapping manipulation applies.
- Content based routing enables you to specify routing parameters (sender, receiver and msgType) that override parameters in the header of the incoming IDocs. You determine such routing parameters from the content of the IDoc itself. For example, you want to provide routing parameters like 'vendor' or 'sales organization' in a PO as information for the receiving system (instead of just the logical system's name).
- Mapping is the mechanism that adds (or removes) data segments to (from) a document. Use this if you want to include the parameter 'sales organization' in the ORDERS IDoc.
A practical example for using the pre-routing mechanisms features is if you have a special Orders IDoc that contains its receiver and sender information in specific fields in the IDoc itself. It also contains extra fields that you want removed, or added, before you process the IDoc as an ORDER02 IDoc. You register special pre-routing services based on message types. You also can create a standard processing service to be executed for all message types and provides default routing information.
You can register both inbound and outbound manipulation services. The inbound services are executed for inbound IDocs received by Adapter for SAP via a RFC Listener or by invoking the pub.sap.transport.ALE:InboundProcess service (for example: over HTTP). The outbound services are executed before an IDoc is sent to an SAP system by pub.sap.transport.ALE:OutboundProcess.
To register an inbound or outbound mapping service
Procedure
- For the inbound case, create one or more services that implement the pub.sap.transport.ALE:aleRoutingInfo and/or pub.sap.transport.ALE:aleRoutingInfo_Default specification. For the outbound case, the services need to implement either the pub.sap.transport.ALE:aleMappingInfo and/or pub.sap.transport.ALE:aleMappingInfo_Default specification.
- After having implemented a service, you still have to make it known to the IDoc transport. Go to Adapters > IBM webMethods Adapter for SAP > Routing/Mapping.
- Follow the link Register New User Exit Service and then select one ALE Routing/Mapping Info * type.
- Provide the full service name and the message type in the input field, and then click Register.
Results
A routing/mapping service has to use the following specifications for proper behavior:
| Specification | Description |
|---|---|
| pub.sap.transport.ALE: aleRoutingInfo | Specification that should be used for services which provide an inbound content based routing/mapping. |
| pub.sap.transport.ALE: aleRoutingInfo_Default | Specification that should be used for services which provide a default inbound routing/mapping |
| pub.sap.transport.ALE: aleMappingInfo | Specification that should be used for services which provide an outbound content based mapping. |
| pub.sap.transport.ALE: aleMappingInfo_Default | Specification that should be used for services which provide a default outbound mapping. |
After you registered your routing services you can associate them with message types via the Integration Server Administrator (Adapters \> IBM webMethods Adapter for SAP \> Routing/Mapping).
A default handling service (inbound or outbound) is executed for all message types. If there are services selected in the message type dependentsection, they will be executed for the corresponding message type in addition to the default service. If the special value $noneis selected, all registered services are set to inactive.
For all incoming IDocs with an ORDERS message type, the sample.sap.idoc.Mappings:orders service will be executed. The service may alter the IDoc as well as the routing parameters for the IDoc. For IDocs going to the SAP system with ORDRSP message type, the sample.sap.idoc.Mappings:ordrsp service will be executed. This service can alter the IDoc by adding or removing fields.
Routing Arbitrary XML Documents Through the > Routing/Mapping
It is possible to use XML Inbound Process to forward arbitrary XML documents to the routing listener by using the Inbound Process mechanism of the XML transport.
For this purpose you can configure a so called inbound routing info service for your XML transport. This service should implement the specification pub.sap.transport.XML:xmlRoutingInfo, using the following parameters:
Input Parameters
| This key | Must specify... |
|---|---|
| document | This field contains the XML document as it would look like after having been processed by pub.xml:xmlNodeToDocument. Your service should extract the routing data from your specific documents. |
| node | Alternatively, you can provide your document as a node as used in the pub.xml:xmlNodeToDocument service as an input field. |
Return Values
| This key | Must specify... |
|---|---|
| sender | Sender used for finding the matching routing notification. |
| receiver | Receiver used for finding the matching routing notification. |
| msgType | Message type used for finding the matching routing notification. |
| $tid (optional) | Transaction ID found in the document, if client wants to execute a transaction once and only once. |
| $action (optional) | One of the following transaction codes:
|
Configuring the Inbound Process Mechanism of the XML Transport
About this task
To configure the Inbound Process mechanism of the XML transport
Procedure
- Create an inbound routing info service for your XML transport. It extracts all required parameters so that the routing listener can handle the request.
- After having implemented a service, you must make it known to the XML transport. Go to the Adapters > IBM webMethods Adapter for SAP > Routing/Mapping page.
- Follow the link Register New User Exit Service and then select XML Routing Info.
- Provide the full service name in the input field, and click Register:
- Now you are ready to do routing using XML Inbound Process for arbitrary XML documents.