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.

Tuesday, April 1, 2014

Visual Studio's Consume Adapter Wizard does not show the SAP IDoc you search

There are several reasons, if you can't see an SAP IDoc in the "Consume Adapter Wizard"-List.

First, their might be a resitriction in SAP: You could analyse this in se37 calling IDOCTYPE_READ_COMPLETE. Thanks for the help, Patrick!

Second, you might search for a basic type but the wizard only list message types (and one level deeper, its basis type). Thanks, Christian!

Third, the IDoc search in the wizard does not search for basic types, so you really have to find out what message type uses this basic type.

You can find a good explanation on IDoc opertions on MSDN.