Sunday, April 18, 2010

BizTalk Adapter Pack 2.0 – Part 4 Sending XML IDocs to SAP

When I started this series, I was more focused on the challenges that are involved with receiving XML IDocs and the schema versions that are  tightly coupled to the version of SAP that you generated them on.  In Post 1 we discussed how the SAP Adapter will use the DOCREL version that is provided by SAP and line this up with your schema forcing you to be in sync with SAP Upgrades.  I wanted to better understand the implications on the Send side so you will find some of my notes below. The story is a little better on the Send side when sending XML IDocs.

 

  • When generating your XML IDoc schemas ensure that the RecieveIdoc Format = Typed.

image

  • Since BizTalk will be sending IDocs to SAP, you want to select “Client (Outbound operations)” and ensure that your schema has a name of “Send”.

image

  • You still want to be aware of the version of SAP that you will be connecting to but it is not as important as when you are choosing to Receive an XML IDoc.  You are best off asking your BASIS admin what version you are on.

image

  • My initial test scenario was generating a ZCONF32 – 700 version of my IDoc.  The version of SAP that I am connecting to is 700 so everything should work correctly.
  • As expected when I wired up my Receive Port to my Send Port, I am able to submit an IDoc to SAP successfully.  Something that I was interested in knowing was the namespace that was included in the context properties.

image

Something also to note is that when you import the Binding file, that was generated when you created your IDoc Schemas,  is the SOAP Action header configured in your send port.  You will notice that the Action includes the namespace for the Schema that was generated.

<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Operation Name="Send" Action="http://Microsoft.LobServices.Sap/2007/03/Idoc/3/CONF32/ZCONF32/700/Send" />
</BtsActionMapping>

  • My next scenario included downloading schemas for version 710 of the IDoc(knowing that I am connecting to an SAP version that is set to version 700).  I updated my map to include this version of the schema. All of the “connection lines” in the mapper updated successfully which makes me think that there are no structural differences between these two versions – at least not with the data elements that I was trying to map. I redeployed the application and left the existing send port in tact.  I was prompted with a warning/error in the event viewer:

Event Type:    Warning
Event Source:    BizTalk Server 2009
Event Category:    (1)
Event ID:    5743
Date:        4/18/2010
Time:        8:50:45 AM
User:        N/A
Computer:    BizTalkServer
Description:
The adapter failed to transmit message going to send port "SendSAPIDoc" with URL "sap://CLIENT=XXX;LANG=EN;@a/SAPSERVER/XX?RfcSdkTrace=False&AbapDebug=False". It will be retransmitted after the retry interval specified for this Send Port. Details:"System.Xml.XmlException: Start element 'Send' from namespace 'http://Microsoft.LobServices.Sap/2007/03/Idoc/3/CONF32/ZCONF32/700/Send' expected. Found element 'ns0:Send' from namespace 'http://Microsoft.LobServices.Sap/2007/03/Idoc/3/CONF32/ZCONF32/710/Send'.

Server stack trace:
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at System.ServiceModel.Channels.IRequestChannel.EndRequest(IAsyncResult result)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)".

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

  • This error leads me to believe that the “magic” when sending XML IDocs is in the SOAP Action Header in the Send Port.  Upon updating the SOAP Action Header to reference the 710 version of the IDoc, I had success.

<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Operation Name="Send" Action="http://Microsoft.LobServices.Sap/2007/03/Idoc/3/CONF32/ZCONF32/710/Send" />
</BtsActionMapping>

 

  • I checked the WE02 SAP Transaction and found that my IDoc was processed successfully as indicated by the green light.

image

 

Conclusion

What I am able to conclude from this exercise is that you are not bound by the version of DOCREL like you are when Receiving IDocs but rather by the structure of the IDoc itself.  I am pretty confident that you can update your SAP version without having to regenerate your schemas as long as the structure of the IDoc itself does not change.  This puts you in a similar risk category as using flat file schemas which I will discuss in the next post of this series.  Something that became evident is that the SOAP action header must match the version of the schema that you have generated.

1 comment:

Unknown said...

Thanks for posting this Kent.
Note that when you changed the namespace from default, it will error on send even when you put in the correct custom namespace in the SOAP header.