[Developer's community]

BizTalk Server 2010 and SAP integration

Instead of introduction
There has always been a demand for data integration between different systems. It doesn't matter was its integration between the legacy systems or with the trading partners, but it seems obvious that projects complexity may vary, depending on used technologies. MS BizTalk has a long story, but to my mind, it is the most promising proprietary integration tool these days. The ease of use developed the knowledge base and large community distinguishes BizTalk from similar tools. Another BizTalk's strengths are its ability to integrate well with Microsoft and non-Microsoft platforms. In this topic, we'll consider BizTalk adapter pack which may simplify your integration process dramatically, especially, when we're talking about integration between SAP and other systems. Let's move on and see how we can use LOB adapter pack for BizTalk in order to build a reliable and transparent integrated solution.
Unfortunately, when I was integrating SAP and BizTalk Server, I was unable to find one consistent topic or guide on this subject, so now, I'm going to fill a gap and share my own experience. I presume you already have BizTalk Server 2010 and SAP instances, so we can proceed with configuration. If you don't know how to install BizTalk Server as a standalone instance, please follow this step-by-step guide.
I. Environment preparation
Let's start with BizTalk machine. First of all, we need to install Visual C++ 2008 (x64) run time dlls. Note: If you have MS Visual Studio 2008 installed on this machine, you can skip this step, otherwise, follow this link to download and install it.
In order to utilize BizTalk integration features, you have to download and install co-called LOB (Line Of Business) adapter pack v.2.0. There is evaluation available for both x32 and x64 versions. Just follow this link and download them. Also, download LOB adapter SDK (both x32 and x64 versions) from here.
Installing LOB adapter pack is not enough and you need to obtain some more mandatory components from SAP support portal. Make sure you have appropriate authorization for downloading from SAP Marketplace and get SAP RFC SDK. To identify exact download location of this package, please follow SAP note 27517 (please download both x32 and x64 versions). The second package is R3DLLINST.zip (despite the fact this are native Microsoft DLL's, they could be found on the SAP Marketplace as well). To download this package, please follow instructions from the SAP note 684106.
Note: Install the appropriate version of RFCSDK. Even if your SAP system is non-Unicode, you have always chosen Unicode version of RFCSDK.
Note: Downloaded RFCSDK is in SAP archive (*.SAR), so, in order to decompress it, you have to download 'swap car' tool from SAP Marketplace ("SWDC -> Support packages and patches -> Entry by application group"). A shorter way to get this executable - is to copy it from SAP instance (of course, if you have it installed on the Windows Server): "\usr\sap\<sid>\sys\exe", look for 'sapcar.exe'.
It doesn't matter on what platform you have SAP installed on the majority of configuration steps will be performed on BizTalk side.
I presume, you have already downloaded all the necessary packages and we can move further.
We can start with RFCSDK archive decompression. Move 'sapcar.exe' and RFCSDK archive(s) to a separate folder and perform decompression in cmd:
sapcar -xvf NWRFC*.SAR

The files will be extracted to nwrfcsdk folder as shown in the picture above.
Similarly, you have to decompress an archive with x32 version of RFCSDK.
To explain this situation with package versions, I have to refer official Microsoft's install instructions which say:
"On a 64-bit operating system, the 32-bit version of the DLL's must be added to the 'C:\Windows\SysWow64' folder. The 64-bit version of the DLL's must be added to the 'C:\Windows\System32' folder (actually, this is a well-known approach for 64-bit windows OS)". You can also read about this step in the SAP Adapter's FAQ page.
Now, according to the Microsoft's instructions, copy extracted RFCSDK's files from the 'lib' folder (9 files in total) into the 'C:\Windows\System32' folder and similarly, copy previously extracted RFCSDK files for x32 version (also 9 files from 'lib' folder) to the corresponding windows folder ('C:\Windows\SysWow64'). That's it! You've done the first step :)
Ok, we can now move on and decompress previously downloaded r3dllinst.zip archive. As it was mentioned, you can download it from the attachment of the SAP note 684106. After archive extraction you will see 'ntpatch' folder. Look there for 'R3DLLINS.EXE' and execute it (as Administrator). This program will automatically replace 4 outdated files in 'C:\Windows\System32' with the DLL's from archive (as shown on the picture below):

Once you've done it, we can consider the first stage of LOB  adapter deployment as completed.
Let's move further and install the LOB SDK and LOB adapters...
For the LOB adapter SDK installation:
1. Extract x64 LOB adapter SDK pack from the self-extracting archive ('WCF-LOB-Adapter-SDK-2010-x64.exe').
2. Find and execute 'AdapterFramework64.msi':

3. Follow the installation master and you will see the list of components... (the 'Runtime' component is mandatory):
4. Finish the installation.
For the LOB adapter pack installation:
1. Extract x64 LOB adapter pack from the self-extracting archive ('Microsoft BizTalk Adapter Pack 2_0 Evaluation x64.exe').
2. Find and execute 'AdaptersSetup64.msi':

3. Follow the installation master and you will see the list of adapters... (do not forget to mark SAP adapter for a mySAP business suite ):
4. Finish the installation.
BizTalk Adapter pack 2.0 Post installation steps
After BT adapter pack installation you might need to perform the next additional steps (depends on what operation you are going to perform using this adapter pack):
- Invoking transactional RFC's (tRFCs) in the SAP system. If you want to invoke tRFCs, then, you have to execute t-SQL script ('SapAdapter-DbScript-install.sql'), which can be found in the BT adapter pack installation folder: 'C:\Program Files\Microsoft BizTalk Adapter Pack(x64)'.
- Manually registering the bindings. It is sad, but you may need to put some more efforts and manually bind.NET Framework Data Providers if, by some reason, the installation wizard failed to do so.
- Using the Data adapter for SAP. This step will be considered separately below, in the chapter related to SAP configuration.
OK, let's move to the last step in this chapter, which is 'Manual registering of the.NET Framework Data Providers'. TBH, I don't really know what's wrong with the installation wizard, but usually, this step is done automatically. In any case, we have to check the 'machine.config' file to make sure that everything is fine and we can proceed with BizTalk configuration. For more information, please refer BT Adapter pack troubleshooting installation guide, published on MSDN. It actually suggests you look for 'sapAdapter' binding in the machine.config file, which is available under <system drive>:\WINDOWS\Microsoft.NET\Framework\<version>\CONFIG. This is right approach... at some extent, but, let us not forget about the version of your OS. We have installed all the adapters and SDK's for the x64 version, aren't we? In your system you have to see the following folders structure:

...where 'Framework64' is for x64 and 'Framework' is for x32. Hence, you'll never find correct 'machine.config' file under 'Framework' directory, because we have installed everything for x64! Moreover, there is a little trick... 'BizTalk Server Administrator Console' performs as an x32 tool, so, to make you adapters visible for BizTalk, you have to install x32 version too. It is fun, isn't it? :)
Right, I hope you have successfully installed x32 version of LOB Adapters pack and now you can see 'cherished lines' in the 'machine.config' file:

p.s. The LOB adapter installer will automatically add bindings to the 'machine.config' file of.NET Framework 2.0. So, if you use.NET Framework 4 in development, you have to add bindings to the corresponding 'machine.config' file anyway. Make a backup of this file and duplicate information about adapter bindings from the file which belongs to version 2.0 of.NET Framework. Make sure you have corrected all the parts of the 'machine.config' file, i.e. '<system.data><DbProviderFactoris>', '<system.serviceModel><extensions>' and '<system.serviceModel><client>'. Finally, if you need to check a public key token of an assembly, you can use a build-in tool in the Visual Studio, follow this nice topic on MSDN.
p.p.s. haste makes waste... as always.
Important! You have only installed a 64-bit version of WCF Adapter SDK. Side-by-side installation of x32 and x64 versions of this SDK on a single machine is not supported!
II. BizTalk Configuration
So, now we are set and ready to proceed with BizTalk configuration (finally!). There is nothing special actually and all you need to do is to register LOB adapters in the BizTalk Administrative Console. Go to BT console -> BT Group -> Platform settings -> Adapters, right click -> New -> Adapter...
After that, you will see the adapter properties dialogue window and in the drop-down list all the just-installed adapters will be visible:
Select adapters one-by-one from the list, give them the descriptive name and save. Ignore the message about instance restart, until you add all of them. As soon as you done it, restart the host instance of BizTalk Server.