Writing Customer data from BizTalk 2006 R2 to SAP
Writing data to SAP consists of 2 difficult steps. The first step is to get all the prerequisites from SAP installed on your BizTalk development machine. And the second is to understand the SAP data structures. You absolutely need a local SAP expert for this. For our proof of concept we were lucky. We were allowed to ignore SAP errors about missing underlying data structures. It was enough proof that we could receive the SAP customer ID and client ID, even though SAP did not accept our customer record.
You can choose to install the WCF LOB adapter for SAP before you install the actual prerequisites from SAP. When you do, it installs without problems. But when you start Visual Studio and start “Add Generated Items – Consume Adapter Service” you won’t see the sapBinding. You will only see the siebelBinding and the oracleBinding. You may also get a different error: if you see the sapBinding and fill in the required data, you press ‘Connect’ and poof: Visual Studio is gone. In order to get the sapBinding working you need to obtain the RFC SDK Unicode libraries from SAP and put them in your windows\system32 directory. For a detailed description refer to the installation manual “InstallationGuide.htm” included in the AdapterPack.
Once we got everything correctly installed, we could finally begin with the real interface to SAP.
1. First create a new BizTalk project in Visual Studio. Then right click on the project and select “Add Generated Items” -> “Consume Adapter Service”.
2. Then the LOB Adapter configuration dialog shows up.
- Select “sapBinding”from the “Select a binding”
- Bring up the SAP Adapter configuration by pressing the button “Configure”. At first the username and password for SAP are set.
Then at the URI properties the SAP connection properties are set.
In our case the following were set:
Application Server
System number
Client
Language
Then at the Binding properties ensure that the EnableBusinessObjects for Bapi is set to “True”. After clicking “Connect” on the “Consume Adapter Service” the adapter connects to SAP and gets all its metadata which is available. This includes BAPIs, IDOCs and RFCs.
3. Select BAPI and search in category using “Customer”, select the search result “http://Microsoft.LobServices.Sap/2007/03/BAPIOBJ/KNA1”.
After pressing the OK button BizTalk extracts some metadata from SAP and creates a schema for the BAPI and a BizTalk binding file for creating the messaging port for the BizTalk solution.
4. Create a simple BizTalk Orchestration which gets the xml message of the new Account to be created. The received message is sent to SAP and the response from SAP is used in updating CRM (MS Customer Dynamics). Note that the message context properties (OPEN, REUSE, CLOSE, and ABORT) should be used to enable transaction on a SAP system. For detail explanation see reference “Performing BAPI transactions by using BizTalk server”.
Example:
The following example shows that the “BAPICommitMessage” corresponding to BAPI_TRANSACTION_COMMIT for committing the transaction on the SAP system uses the context property “CLOSE”
BAPICommitMessage(Microsoft.Adapters.SAP.BiztalkPropertySchema.ConnectionState) = "CLOSE";
5. Ensure that the assembly is strong-named, in the solution explorer right-click the solution and then click Build Solution, after the solution successfully builds right-click the solution and then click “Deploy Solution”.
6. In the BizTalk Server Administration console, right-click the deployed application and then select Import àBindings. In the dialog box that opens navigate to the folder that contains the binding file created (Refer to step 3) and then click “Open”. This creates a preconfigured WCF Solicit-Response Send port with a WCF custom binding (sapBinding).
7. Modify some of the settings by right-clicking the WCF-Custom send port and selecting “Properties”. In the port properties dialog box do the following:
a. Click configure
b. Specify the connection URI (client number, language, server name, system number)
c. Click the “Credentials” tab and specify a user name and password to connect to the SAP system. Click “Ok”
d. Click the “General” tab; modify the action mapping of the SOAP action header to map an operation in the BizTalk Orchestration to an action in the LOB adapter (the selected BAPI call in the SAP adapter)
<BtsActionMapping> <Operation Name="BAPIMessage" Action="http://Microsoft.LobServices.Sap/2007/03/Rfc/BAPI_CUSTOMER_CREATEFROMDAT1" /> <Operation Name="BAPICommitMessage" Action="http://Microsoft.LobServices.Sap/2007/03/Rfc/BAPI_TRANSACTION_COMMIT" /></BtsActionMapping>
The above is an example of how operations “BAPIMessage” and “BAPICommitMessage” are mapped to actions “http://Microsoft.LobServices.Sap/2007/03/Rfc/BAPI_CUSTOMER_CREATEFROMDAT1” and "http://Microsoft.LobServices.Sap/2007/03/Rfc/BAPI_TRANSACTION_COMMIT" in the LOB adapter.
The name of the operations “BAPIMessage” and “BAPICommitMessage” should correspond with the names of operations in the BizTalk Orchestration.
For detail explanation see reference “Specifying SOAP action”.
e. Create the remaining Receive and send-Ports and bind the Orchestration.
Authors
Marcel Fernee: marcel.fernee@microsoft.com
Henry Osagiede: henry.osagiede@atosorigin.com
Mark Wijngaarden: mark.wijngaarden@atosorigin.com
Mariёtte Mak: mariette.mak@atosorigin.com
Resources
BizTalk WCF LOB adapters
Obtaining the RFC SDK Unicode Libraries from SAP Service Marketplace
http://blogs.msdn.com/adapters/archive/2007/10/07/obtaining-the-rfc-sdk-unicode-libraries-from-sap-service-marketplace.aspx
Performing BAPI Transactions by Using BizTalk Server
http://msdn2.microsoft.com/en-us/library/cc185462.aspx
Specifying SOAP action
http://msdn2.microsoft.com/en-us/library/cc185151.aspx
Using the new BizTalk 2006 R2 SAP LOB Adapter
http://www.cubido.at/Blog/tabid/176/EntryID/128/Default.aspx
SAP Transaction
http://msdn2.microsoft.com/en-us/cc196386.aspx#sap