Some of customers who have migrated for the old Sap Adapter (BizTalk Adapter 2.0 for mySAP Business Suite) to WCF-SAP adapter (comes with BizTalk Adapter Pack), have come back saying that there are some differences in behavior of the old SAP adapter and WCF-SAP adapter, which can break their scenarios.

Following differences are the most talked about -

  1. The old version of the adapter accepted RFC messages with date field empty. In the new version, the same call results in an error. This is because WCF-SAP adapter doesn't allow blank XML nodes.
  2. Unlike the old version, the new version does not accept ',' (comma) as decimal separator for fields of type DECIMAL. It mandates that '.'(Period) should be used as decimal separator.
  3. WCF-SAP adapter doesn't return back tables exposed as CHANGING parameter, if the corresponding request message doesn't contain the table. You can refer to the post - "When I Execute BAPIs, I don't get back any data". Help!" for the details.

All these three behaviors are correct from a design perspective , justification follows -

  1.  Any XML node, if present  should confirm  to the data-type restrictions, or should have xsi:nil="true".
  2.  w3.org XML specification mandates a period(.) should be used as decimal separator.
  3.  This is an optimization in the WCF-SAP adapter to decrease the data transfer over-head.

-----
That said, many customers who are migrating from the Old SAP adapter do face these issues.
 I have written a custom pipeline component that can help resolve these three issues.
 The pipeline has three configuration properties, which can be used to tailor the behavior as per requirements -

Issue

Property Name

Description

Default Value

WCF-SAP adapter doesn't allow blank XML nodes, if the min-length is more than zero.

(fields like DateTime )

RemoveEmptyDataNodesInRequest

 (bool)

When true, all empty leaf level node will be removed from the request message.

false

WCF-SAP adapter doesn't allow ',' as decimal separator

CultureInfoForDecimal

 (string)

Eg: en-US, es-ES

Culture code for the CultureInfo to use for parsing decimal fields.

When a valid culture code is specified, it will use the given  Culture Info for parsing the xs:decimal, xs:float , xs:double  fields  and convert it to culture-invariant string representation(expected by the WCF-SAP adapter ).

Vice-versa for response.

null

WCF-SAP adapter doesn't return back tables exposed as CHANGING parameter, if the corresponding request message doesn't contain the table.

On the other hand, it returns a blank table node even if there is no data in the table, if the table is present in request message.

FetchAllTables

 (bool)

When true, will add empty nodes for all tables which don’t exist in request message.

It will also remove empty table nodes from response message to get a response similar to the old adapter.

false

 

The outcome -

  1.  RemoveEmptyDataNodesInRequest (true) - You don't need to worry about removing empty XML tags from the input message, for fields like DateTime.
  2. CultureInfoForDecimal(es-ES) - If the incoming message is using ','(comma) as decimal separator, the message will be sent to the WCF-SAP adapter successfully. Also, in the response message, you will have ','(comma) as decimal separator.
  3.  FetchAllTables(true) - When this property is set to true, all the tables will be fetched in the response message,  irrespective of  whether a corresponding node is present in the request message.

How to set the properties on the pipeline component - 

  1.  While building the pipeline from this pipeline component (inside the pipeline editor in Visual Studio ), you can specify any valid culture-code  , for CultureInfoForDecimal. This will become the default value for the pipeline.
    Eg-   You can use 'en-US'   if you want '.' as decimal separator.
                               'es-ES'   if you want  ',' as decimal separator.
  2.  Whenever you use the pipeline for any port (send/receive), the value you gave in step 1 will show as the default value. 
  3.  You can customize the value for a specific send port by opening the pipeline properties and specifying the desired value there.

Same applies for the other two properties.

 


Steps for using the pipeline component-

  1. Build the project, or use the pre-built SapBackCompatPipelineComponent.dll.
  2.  Drop it here: <BizTalk Server installation folder>\Pipeline Components
  3. Create a new BizTalk project in Visual Studio.
  4.  Pipeline Designer inside Visual Studio: toolbox -> choose items -> BizTalkPipeline components -> select your component -> ok.
  5.  Drop your pipeline component in encode stage. Set the default values for pipeline properties.
  6.  Build and deploy the BizTalk project.
  7.  On the WCF-SAP send port select your pipeline.
  8.  If you click the ellipses (...) button next to the pipelines selection drop-down, you will see a window where you can edit the properties for the specific instance of the pipeline.

 

Note: 

  1. You don't need to GAC any of the dlls.
  2. It's recommended that you use this pipeline component in conjunction with "XML Disassembler " pipeline component, because of the following reasons -
      a> For this pipeline to behave correctly the instance xml should validate against the schema.
          (It doesn't log any error if validation fails.).
      b> This pipeline component doesn't populate the MessageType context property
          (So, subscription evaluation based on messageType will fail)
    If you use "XML Disassembler " pipeline component along with this pipeline component, then you won't face these issues.
  3. If you are using the pipeline component for making the old adapter installation work with the WCF-SAP adapter and are facing problems (1) and (2) mentioned in this blog, you can drop this pipeline component in a stage after that component in the pipeline designer. 
    However, you will need to generate the schemas for the new adapter, as this pipeline expects the new schemas to be present.

The source-code of the component is atttached, so you can modify the code(if need be) to tailor it to your requirements.

Rohit Singh