Sunday, April 11, 2010

BizTalk Adapter Pack 2.0 – Part 3 Receiving multiple Flat File IDocs using SAP Adapter

In Part 2 of this series we discussed how you can receive IDocs from SAP in flat file format in order to avoid tight coupling with the version of SAP you are running as discussed in Post 1.

As I alluded to in the end of the Part 2 post, there is an issue when you include more than 1 IDoc schema in a Receive Pipeline that will be use the same Program ID and Receive location.

The behavior that I experienced when working through this scenario is the first message in my pipeline would be processed successfully but the second type(Vacations) would not.

 

 image

 

When I tried to process my 2nd type of IDoc (Employee Vacations) I would get the following error:

 

Event Type:    Error
Event Source:    BizTalk Server 2009
Event Category:    (1)
Event ID:    5719
Date:        4/11/2010
Time:        10:10:49 AM
User:        N/A
Computer:    *BizTalk Server*

Description:
There was a failure executing the receive pipeline: "SAPVersions.ReceiveSAPIDocs, SAPVersions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=147585b889447deb" Source: "Flat file disassembler" Receive Port: "ReceiveIDocsFromSAP" URI: "sap://CLIENT=XX;LANG=EN;@a/SAPSERVER/XX?ListenerGwServ=sapgwXX&ListenerGwHost=SAPSERVERci&ListenerProgramId=*ProgramID*&RfcSdkTrace=False&AbapDebug=False" Reason: Unexpected data found while looking for:
'Z2HR_WS_SEG000'
The current definition being parsed is idocData. The stream offset where the error occured is 520. The line number where the error occurred is 2. The column where the error occured is 0.

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

 

In the rest of the post I will discuss how you can fix this problem manually and then discuss the Hot Fix from Microsoft that addresses this situation.  I recommend proceeding with the Hot Fix route as it is a more sustainable solution.  The manual steps include modifying a schema that was generated by the Consume Adapter Service Wizard.  The risk is you can manually modify one of these schemas only to have a colleague regenerate the schema and overwrite your manual change.  If you do proceed with the Hot Fix route you will want to ensure any other developers that will be generating IDoc schemas are also using this Hot Fix.  I also want to highlight that this Hot Fix should be applied to developer’s workstations as this fix addresses a design time issue.

 

Fixing issue manually

  • Open up your schema that contains the “meat” of your IDoc information in an XML Editor view.  Whenever you generate  SAP IDoc schemas you are bound to have multiple XSD schemas created.  You can expect 1 IDoc that includes the various complex types, another that acts as the “Request” container IDoc, a Response xsd and the “meat” xsd which will include most of the “core” details of the schema.
  • Scroll down until you find a section that includes tag_name=”EDI_DC40” tag_offset="0" and replace it with tag_name="ZHR_VAC" tag_offset="39" where “ZHR_WS” is the name of your IDoc type.

image

 

image

 

  • What you will find as you open your schemas is that all of them will have this tag_name="EDI_DC40" tag_offset="0" string included in the IDoc which prevents BizTalk from distinguishing one IDoc from another.
  • Once you have modified all IDocs in this fashion, redeploy and you should find that both(in my case) IDocs were processed successfully.

image

Fixing issue with HotFix

  • In KB977528 Microsoft describes the issue as “This problem occurs because the first Flat file disassembler pipeline component in the custom pipeline tries to disassemble all the IDOCs that are received. However, the IDOCs should be processed by different Flat file disassembler components that have different schemas”.

  • When using the HotFix, you download schemas the same way as you previously did

image

  • Note when you open up the schema, you will now notice that the same change that we applied manually has now been incorporated into the schema definition automatically.

image

  • If you have changed the name of you XSD files, make sure you update your receive pipeline, deploy and restart your host instance(s).  You should now be able to receive both types of flat file IDocs without issue

image

 

Note:

My developer workstation is a 64 bit machine so when I navigated to the Hot Fix Web site it detected that my system was a 64 bit system and provided me with a 64 bit patch.  The problem is that Visual Studio runs in 32 bit mode and since this fix is a design time issue my issue was not resolved until I downloaded the 32 bit version of this KB.  I logged onto a 32 bit machine and navigate to the same site in order to get the 32 bit fix.

 

image

 

Thus far we have been  focusing on receiving IDocs.  A reader has asked if I can demonstrate how to sent a flat file schema to SAP using the BizTalk Adapter Pack so that will be the next post in this series.

No comments: