Thursday, September 25, 2008

BizTalk SAP Adapter and Extended SAP IDocs

I recently ran into an interesting scenario when generating the BizTalk schema for an IDoc. I have generated several schemas from SAP in the past but was having trouble "finding" this particular IDoc.


SAP Background:
I do not confess to being an SAP expert, but this is the way that I understand IDocs. Out of the box, SAP provides lots of IDocs that relate to particular modules within SAP. These modules include Finance, HR, Plant Maintenance among many others. You can also buy separate packages that relate specifically to your industry. For instance I am in the energy industry so my organization heavily uses that ISU module. Generally organizations like to limit the amount of customization that they do to their SAP system but it is usually impossible to have no customizations.

When you want to customize one of these "out of the box" IDocs you have a couple options:

  • Creating an IDoc based upon a "copy" of an original IDoc. Kinda like a copy-paste, rename scenario. The naming convention for custom Idocs is to place a 'Z' in front of the IDoc that you just customized. For instance if you were to customize the 'CONF32' (Confirmation IDoc) you would name your IDoc ZConf32.

  • Extending an IDoc. You can think of this more like inheritance. You start by inheriting the "base" Idoc and adding, or extending, any segments that satisfy your needs.

My experience in the past primarily involved generating schemas for custom IDocs. So when I input the IDoc that I am looking for in the BizTalk Adapter Meta Generation wizard I would type in ZConf32* and it would return a result. The problem that I ran into is that when I typed this name as the IDoc that I was looking for, no results were returned.

At one point it was suggested by someone on our SAP team that perhaps BizTalk could not download Extended IDocs. I was not too surprised that the suggestion was made since BizTalk often mis-understood. On the flip side, BizTalk resources generally do not have a lot of SAP knowledge so I couldn't initially confirm whether BizTalk could or couldn't. However, I wasn't quite ready to throw in the towel.

Microsoft has done a pretty good job of abstracting the "little" details away from us by providing wizards that allow us to generate schemas. This is definitely a value-add offering by Microsoft and a key driver in organizations using middleware like BizTalk. It allows integration projects to turn around solutions faster and cheaper.

So I started by querying with a "wider" search criteria via wild cards. What I found was that since this IDoc was extended, I needed to find the "Standard" SAP IDoc and then drill down from there to find the extension.


Error returned while searching for "Custom Name" ZConf32

When I changed my query to include the "Standard" SAP Conf32 IDoc and drilled down a level I was presented with both the SAP Idoc and the version that had been extended. Since I wanted the extended version, I selected the entry called Conf32-ZConf32. The naming convention follows that of Custom IDocs in that "Z" is used to indicate that the extension is custom and not something provided out of the box.


Success! IDoc is found with the "Standard" SAP version.

The two preceding examples used the BizTalk Server 2006 (R1) Adapter. I was curious to see if the behaviour was similar with the WCF based SAP adapter that can be used with BizTalk Server 2006 (R2).

When searching for my Extended IDoc called ZConf32 I was presented with an "IDoc not found" message. Not the same message as the R1 error, but in essence the same meaning.



The next step I did was provide a search that included the "Standard" SAP IDoc Conf32 to see if the extended IDoc was hanging out with the original. While the experience in the Wizard is a little different, the end result is the same. The Extended IDoc is available for download by the Adapter Meta Data Generation wizard


So hopefully this post will help someone out. I know myself and a SAP resource were scratching our heads for a bit but in the end we got the result that we were looking for.

16 comments:

Ritesh said...
This comment has been removed by the author.
Ritesh said...

Hi Kent,
I am trying to generate a schema for a custom IDOC.
I am using the WCF-SAP adapter in BTS adapter pack 2.0.
I was going through your article and tried to follow the steps but was not able to get the custom IDOC schema.
There was a Z_RES under IDOC node when I try to search for the IDOC but using that IDOC too did not help and the custom segment did not get generated.
Kindly give some pointers.
Regards,
Ritesh

Kent Weare said...

Hi Ritesh,

I would try two things:

1) Browse to the IDoc via the tree without searching. I have found that the search does not always return you the latest version of the Idoc. If I have troubles with this method then I will browse and look for the latest version of the IDoc that was generated from the tree.

2)Custom IDocs should be no different than standard SAP IDocs. I have generated schemas for Custom IDocs with both adapters. However, I have run into a situation where the Idoc was not "released". At least I think this is the term used by SAP folks. If you have tried to browse for the Idoc and still don't have any luck, contact the BASIS admin and ask them to check if the IDoc has been fully "released".

Hope this helps

Ritesh said...

Hi Kent,
First of all thanks for the quick response.
I have another query regarding IDOC.
I have the scenario where a custom segment in the standard ORDERS05 IDOC. I talked to my SAP collegues and they are saying that this scenario is of a standard IDOC. Can you please let me know if you are referring to the same scenario as custom IDOC?
Regards,
Ritesh

Kent Weare said...

It sounds like you are in an "extended" IDoc scenario. They have taken an existing IDoc and added a custom segment. This is the scenario I have described in my blog. Our SAP team took a "CONF32" document and added a Segment. When I browsed using the tree, I found the extended IDoc "underneath" the standard "CONF32" Idoc. If I searched for "ZCONF32" I didn't find what I was looking for.

Another point is that I believe in this scenario that BASIS would need to "release" this new segment as well.

Ritesh said...

Hi Kent.
You are right. The IDOC has not been released.
Thanks for your help.
Regards,
Ritesh

Kent Weare said...

Cool...glad I could help.

Ritesh said...

Hi Kent.
Even after the segment has been released, I am not able to find the proper IDOC in the adapter generation.
Can you give any pointers as to why this could be happenning?
Regards,
Ritesh

Kent Weare said...

Have you checked out this link?

http://social.msdn.microsoft.com/Forums/en-US/biztalkr2adapters/thread/1ba020f2-85e7-4505-ac7e-5b0f7ea5b39d

Ritesh said...

Thanks Kent.
As mentioned in the article, the message type was changed by my SAP colleague and he forgot to tell me :)

Thanks for all your help.

Regards,
Ritesh

Ritesh said...

Hi Kent,
Its me again :)
I am facing another issue with SAP integratio. There is a node in the schema generated by BTS for ORDERS05 IDOC which has some enumeration values. Now my SAP colleagues have added some values for the corresponding field in SAP but BizTalk does not seems to be pulling those values in the schema. Have you seen any such scenario or do you have any idea?
Regards,
Ritesh

Kent Weare said...

Hi Ritesh,

Since you are using the WCF based adapter, I would expect that multiple schemas would be generated for you after you have run the wizard. The reason why multiple schemas would be there is for exactly this function. SAP has some enumerations which equate to Complex Types in the XSD world.

If these are not showing up, I would circle back to your SAP colleagues and make sure that these enumerations have been released. Also when generating your schemas ensure that you are retrieving the lastest version that includes these enums.

Kent

Ritesh said...

Hi Kent,
You are right. There are multiple schemas generated for IDOC. I checked with my SAP colleagues about releasing of custom text but they say that there is no option for releasing custom text. I even tried regenerating schema for the IDOC but no luck there as well. Do you have any other idea which I can try?
Regards,
Ritesh

Kent Weare said...

Hi Ritesh,

Without being there to see it, it is tough to determine what is happening.

You could always try with the old adapter to see what it brings back. Perhaps it is a bug with new adapter?

In the blog post I was able to bring back a custom segment though.

Kent

Kiran R said...

Hi Kent,
I am trying to pull a custom idoc from SAP using WCF-SAP adapter. Most of the times the file arrives OK but only in some instances a partial file arrives with no segment data. When checked in SAP the file has been sent successfully.
Is there anything you can suggest.

Thanks,
Kira

Kent Weare said...

Hi Kiran

I would confirm in WE19 transaction that Idoc was completely sent. I would also enable tracing for wcf-sap adapter. This link will help with that http://www.codit.eu/blog/2010/04/21/wcf-adapter-setting-a-trace/

Kent