Showing posts with label WCF SAP adapter. Show all posts
Showing posts with label WCF SAP adapter. Show all posts

Friday, June 13, 2014

SAP WCF MetadataException "RFC IDOC_INBOUND_ASYNCHRONOUSM could not be resolved against SAP"

If you run into this error
The adapter "WCF-Custom" raised an error message. Details "Microsoft.ServiceModel.Channels.Common.MetadataException: RFC IDOC_INBOUND_ASYNCHRONOUSM could not be resolved against SAP system because its metadata could not be obtained. ---> Microsoft.Adapters.SAP.RFCException: Details: ErrorCode=RFC_EXCEPTION. ErrorGroup=RFC_ERROR_APPLICATION_EXCEPTION. SapErrorMessage=FU_NOT_FOUND.  AdapterErrorMessage=An error occurred while determining the function interface of the RFC IDOC_INBOUND_ASYNCHRONOUSM.
then you might use a the new WCF SAP adapter with a Non-Unicode RFC Destination. The BizTalk Adapter Pack 2013 does not seem to be compatible with Non-Unicode RFC as it was before. The only solution seems to be to create a new RFC Destination in SAP.

Thursday, May 22, 2014

SAP-Adapter Error "The segment or group definition E2IDKU5 was not found in the IDoc metadata."

During runtime, we received the following error from the WCF SAP adapter:

Microsoft.ServiceModel.Channels.Common.XmlReaderGenerationException ist aufgetreten.
  HResult=-2146233087
  Message=The segment or group definition E2IDKU5 was not found in the IDoc metadata. The UniqueId of the IDoc type is: IDOCTYP/3/PEXR2002//701. For Receive operations, the SAP adapter does not support unreleased segments.
  Source=Microsoft.Adapters.SAP
  StackTrace:
       bei Microsoft.Adapters.SAP.TypedIdocBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)

The reason was that the IDoc contained the element name E2IDKU5 although its segment definition was E2IDKU5001.

So, whenever you run into a similar message, it's worth to check the SAP transaction WE60 to check the segment definition of the element.
 

Monday, May 12, 2014

Typical Problems Making SAP BAPI Calls

This is an uncomplete list of typical problems when you run BAPI calls.

1. If you get an empty result from SAP, you have to pass a stub of the result that you expect (read http://blogs.msdn.com/b/adapters/archive/2008/01/10/when-i-execute-bapis-i-don-t-get-back-any-data-help.aspx for more information).

2. If you get this exception
Microsoft.ServiceModel.Channels.Common.XmlReaderGenerationException: An error occurred when trying to convert the byte array [30-00-30-00-30-00-30-00-30-00-30-00-30-00-30-00] of RFCTYPE RFCTYPE_DATE with length 8 and decimals 0 to XML format. Parameter/field name: CLEAR_DATE   Error message: Die Parameter "Year", "Month", und "Day" beschreiben eine nicht darstellbare DateTime.
 you might want to create the Biztalk BAPI schema with enableSafeTyping=true. Also use this option during run-time. You can then use dates in the form of YYYYMMDD.

If you are aware of (1) and (2), a working BAPI Call would be:
<ns0:GETSTATEMENT xmlns:ns0="http://Microsoft.LobServices.Sap/2007/03/Bapi/BUS3007/">
 <ns0:COMPANYCODE>xxx</ns0:COMPANYCODE>
 <ns0:CUSTOMER>xxx</ns0:CUSTOMER>
 <ns0:DATE_FROM>20140101</ns0:DATE_FROM>
 <ns0:DATE_TO>20140505</ns0:DATE_TO>
 <ns0:NOTEDITEMS>X</ns0:NOTEDITEMS>
 <ns0:LINEITEMS />
</ns0:GETSTATEMENT>
Thanks, Mirko!

Wednesday, April 9, 2014

Read IDocs with WCF-SAP-Adapter that contain Elements that are not attached to a SAP Release

There are basis types that contain elements that are not attached to any release; by design, you cannot retrieve their schema with the Consume Adapter Wizard like it is explained here neither could you get the IDocs on run-time. In both cases, you receive an error like this:
Error while retrieving or generating the WSDL. Adapter message: Details: ErrorCode=RFC_EXCEPTION. ErrorGroup=RFC_ERROR_APPLICATION_EXCEPTION. SapErrorMessage=SEGMENT_UNKNOWN.  AdapterErrorMessage=Error returned by RfcCallReceiveEx while calling RFC: IDOCTYPE_READ_COMPLETE..

When you anyway have to get the IDocs and your SAP colleagues cannot change the basis type's setting, you still can read the IDocs "weakly-typed", i.e. with the setting ReceiveIdocFormat=String.

First, you have to get the general ReceiveIdoc schema:

Second, you have to change the setting in the WCF-Adapter and set ReceiveIDocFormat to from "Types" to "String". A good explanation of how to receive idocs in this "raw format" is written by Mustansir and Gordie, as well as on MSDN.

The drawback of this solution is that you now receive the IDocs in a flat file format and no longer in good-readable and handable XML - until you add a flatfile pipeline.

Tipp: Use WE60 in SAP to find the element that is not set to a release! Maybe your SAP administrator can set this element to a release, and then you can retrieve the schema.