Assume as part of your business process, you obtain an IDOC from somewhere, in a flat-file format, as below, which you wand to send to SAP using the SAP adapter with the least amount of effort ..
EDI_DC40 8000000000001064985620E2EDK01005 800000000000106498500000100000001E2EDK14 8000000000001064985000002000000020111000E2EDK14 8000000000001064985000003000000020081000E2EDK14 80000000000010649850000040000000200710E2EDK14 80000000000010649850000050000000200600
The SAP Adapter exposes an operation called SendIdoc (while browsing, this operation appears under the Idoc node). The schema for this operation is such, that if you generated a WCF Proxy for it, the operation signature would be:
public void SendIdoc(string idocData, ref Guid guid);
Here, the "idocData" parameter would be set to the idoc data you want to send (i.e., the 6 lines above near the beginning of this post). And what about the guid? Well, IDOCs need to be sent to SAP as part of a TRFC client call. Every TRFC client call requires the client (in this case you+adapter) to generate a TID (which is a 24 character string), make a call to SAP using this TID, and then after the call, "confirm"-ing the TID. The adapter requires you to instead give it a GUID, which the adapter then internally converts to a 24 character TID. If you pass null for this parameter, the adapter will generate a GUID, and in the response message, give you the GUID it generated (that's why the parameter is "ref").
Now suppose you want to send this to SAP from BizTalk (of course, using the WCF-based SAPBinding + WCF Adapter combination). You therefore need to construct a SOAP message containing your 6-line idoc data. Luckily, the WCF Adapter eases some of the tasks involved in creating a SOAP message from raw data like the above.
Firstly, create a send port using the WCF-Custom adapter, and configure it for use with the SAPBinding. Now, for creating the SOAP message, you need to do two things:
(a) Specify an action - this can be done in the "General" tab of the dialog that pops up when you "Configure" the WCF-Custom port. Enter http://Microsoft.LobServices.Sap/2007/03/Idoc/SendIdoc. (this is the action for the Send Idoc operation)
(b) You also need to generate xml tags which wrap your data. If you look at the schema for the SendIdoc operation, you will realize that the body of the message has to look like:
You could write a pipeline component or some custom code to create these enclosing tags. Or instead, you could take the help of the WCF Adapter. In the "Messages" tab of the dialog (that pops up when you "Configure" the WCF-Custom port), for the outbound WCF Message Body, select the "Template" radio button. And in the XML textbox/textarea, enter this:
<SendIdoc xmlns='http://Microsoft.LobServices.Sap/2007/03/Idoc/'><idocData><bts-msg-body xmlns="http://www.microsoft.com/schemas/bts2007" encoding="String"/></idocData></SendIdoc>
The specified template puts the SendIdoc and idocData xml tags around the incoming data (treating it as a string) and sends it to the SAP Adapter.
If you're not interested in knowing the TID which was used to send the idoc, you should create a One-Way Send Port for maximum performance.
P.S. - if you're planning to use this procedure in your environment, you should contact BizTalk 2006 R2 support. There is a QFE you need for BizTalk 2006 R2 (related to the WCF Adapter) which you need for the above to work. The KB number is 942612.