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 a support perspective when something happens.

Applies to: BizTalk 2006 R2 and up

Logistical Setup Of This Orchestration

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 the 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 that 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.

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

image001.png

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

image002.png

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

image003.png

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

image004.png

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;

msg_AnyIdocXML_Out(WCF.Action)=MsgNS;

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.

image005.png

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)

image006.png

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

Deploy

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 dropdown

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

<BtsActionMappingxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Operation Name="
SendToSAP" Action="" />
</BtsActionMapping>

image007.png
  • Pay attention to the text in the second line.

  • The Operation Name should be the same asset 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 a 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 how to simplify receiving data from SAP.