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.

No comments: