Simplify Sending Data to SAP

This example focuses on sending multiple IDOC messages to SAP, all using one Send Port. Often there is a need to limit the number of LOB ports that can be created as it necessitates giving usernames and passwords to multiple people or when password changes there are multiple places to change which can be cumbersome and also error-prone.

By having one point of entry to a LOB system (SAP), more control and management can be exerted over the entry points. This approach is especially useful when there are planned outages or maintenance on the LOB systems; there is one place to look from support perspective when something happens.

Applies to: BizTalk 2006 R2 and up

Logistical Setup of this Orchestration

1. Create a BizTalk Project and Add New Item…..and select Orchestration. (not getting into the naming conventions etc…maybe another blog idea)

2. Add the following shapes in top-down sequence

a. Receive

b. Expression

c.  Message Assignment

d. Send

3. On the port surface, add two Logical ports

a. Always Receive messages and Specify Later

b. Always Send messages and Specify Later

4. Add 2 Message Type

a. Incoming Message

 i. Name: msg_AnyIdocXML_In

 ii. Type: System.Xml.XmlDocument

b. Outgoing Message

   i. Name: msg_AnyIdocXML_Out

 ii.Typ e: System.Xml.XmlDocument

5. Add one variable

a. Name: MsgNS

b. Type: System.String

6. Add one Correlation Set and Correlation Type

a. Right click Correlation Set and Select New

b. Under properties change name if required

c. From Correlation Type Drop-down select “Create new Correlation Set”

d. The screen jumps to the Correlation Set Property….look for “Correlation Properties”

e. Click the … and it will bring up the following screen.

f. Expand the “WCF” section and Add “Action”  

i. This is the property which is equal to the Namespace of the IDOC Schema  that was generated using the Consume Web Service option (another blog on this)

ii. This property can be different depending on which WCF end-point you need to send these messages to.


After following this procedure, the Orchestration should appear with the following order and similar properties. I have included limited screen shots but you get the idea (naming convention excluded).


Now you should see the Orchestration in the following order and similar properties etc…I am putting certain screen shots but you get the idea (naming convention excluded).



Finalize Orchestration

Now to button up the Orchestration in the following order (not necessary however, it’s a good development practice so nothing is missed).

1.  Receive Shape

a.  Select the message “msg_AnyIdocXML_In” created before from the drop down

2. In the Get Vars Expression Shape put the following one line code

MsgNS = xpath(msg_AnyIdocXML_In, "string(namespace-uri(/*))");

This is assigning the variable “MsgNS”the namespace of the received IDOC XML message as in the example IDOC Namespace is the same as the WCF Action needed by the Send Port to send this message to SAP using WCF SAP Adapter


3. On the Message Assignment Shape set

a. Select  Message Constructed property = “msg_AnyIdocXML_Out” created before from the drop down

b. Double Click the Message Assignment inside the Construct Message and enter the following code

msg_AnyIdocXML_Out = msg_AnyIdocXML_In;

This is passing the incoming message and assigning it to the outgoing message type. Then it is setting the WCF Action and assigning the Namespace value captured before.


4. Send Shape

a. Select the message “msg_AnyIdocXML_Out” created before from the drop down

b. From the drop down for Initializing Correlation Sets, select the Correlation set created before (See step # 6 above in Logical Setup)


5. Drag the Receive Logical Port to the Receive Shape.

6. Then Activate the Receive Shape


7. Drag the Send Shape to the Send Logical Port



Sign and set the deployment for the project and deploy.
Right Click Project – Deploy.


Run Time Setup after deployment

1. Open BizTalk Administration Console and expand to the application where the Orchestration is deployed.

2. Created a Physical Receive Port to pick up any SAP IDOC XML Files.
This is important to note as this will be the generic location that all the other processes (post-mapping etc…) will submit files to

3. Create a Send Port with WCF-Custom Adapter

a. Select WCF-Custom on the Adapter list drop down

b. Click Configure

c. For the Address URI (address for WCF Endpoint) SAP in this case enter the following: (again this is the basic connection string, which you may need to change based on your requirement)

sap://CLIENT=100;LANG=EN;@a/{SAP Server Address/IP}/{Client ID}?&RfcSdkTrace=False&AbapDebug=False

** Note the underline text between curly brackets is the environment specific value.

d. Under Binding Tab Select the Binding Type = “sapBinding”

e. Under Credentials Tab select the appropriate option and enter the details. Usually there is a user assigned by SAP Team with a password.

f. Go back to the General Tab and here is the Fun Part!
Under SOAP Action Header put the following

<Operation Name="SendToSAP" Action="" />
  • Pay attention to the text in the second line.
  • The Operation Name should be the same as set in the Orchestration
  • By Default this name is “Operation_1” like it adds in Orchestration when you first create it. Until you intentionally change it which you should to make it more tuned to what it is.
  • Secondly, the Action is supposed to be blank as this is what the Orchestration is actually setting and promoting as a Context property
  • If this Action element has an value, then it simply overrides the value coming from Orchestration making the orchestration use pretty much useless.

 4. After all the above setup
Go to the Orchestration and bind the orchestration with:

  • Host
  • File based Receive Port created in Step 2 above
  • WCF-Custom based Send Port created in Step 3 above

5. Start the Ports and Orchestration

6. You are ready to test and implement this Generic IDOC loader process


The above design pattern can greatly simplify SAP communications with not just BizTalk but with any other WCF compliant product toolset. This is one of the many enhancements and streamlining of processes that the Aidant Technologies team provides through our DI.Platform and Professional Services. How can we help simply your integrations? Contact us to find out. 


This article covers sending data to SAP. Please subscribe to our newsletter (see signup below) or follow our LinkedIn page to find out for how to simplify receiving data from SAP.