Converting XSD into SAP-PI compatible XSD

Added by Ruslim Chang , last edited by Ruslim Chang on Aug 07, 2008

Normally, we would love to get XSD from the partner, so that we can upload it directly to SAP-PI, and use it to create message interface. However, some time, we may not be able to upload it correctly, as it may contains certain tags which SAP-PI does not support, like <xsd:import> or <xsd:include>. SAP-PI currently on works with one single XSD file, not with multiple modularized XSDs. How should we go about it if we have to face this situation?

  1. One alternative is to create the data type, message type, and message interface manually in PI. However, this will be a tedious task to do, especially if we the original XSD is quite complicated
  2. Other alternative is to create a new single XSD by merging those modularized XSDs manually. If the XSD size is not too big, and number of XSDs involved are still manageable, then this may be worth trying.

However, what if we receive huge modularized XSDs which covers the whole products range that offered by a certain company, whereas we just actually interested in one of their products offering. Those 2 alternatives above may not be a a visible solutions anymore.

This is what happened in one of the project in states when we have requirements from user to connect SAP CRM with credit scores companies using SAP-PI. They provide us a huge main XSD which covers the whole range of products offered y their companies, and which links to many other XSDs using <xsd:import> and <xsd:include>. After trying and struggling with alternative 1 and 2, we end up doing this alternative.

The idea is to create XML instance from XSD. And then later on, we create back the XSD using the XML created from the previous step. These 2 steps are breeze of cakes to do, if you have XML tool of course However, there are several things we need to remember, if we dont want to have problem uploading the generated XSD into SAP-PI as well as creating the proxy from it in your back end application.

  1. Make sure that the cardinality (which is values of "minOccurs" and "maxOccurs") of generated XSD element is correct. You need to check this values against the original XSD.
  2. If you have <xs:sequence> tag in your XSD, make sure "maxOccurs" is set to "1" instead of "unbounded". Otherwise you will get a field named 'Sequence' in generated proxy structure.
  3. Change <xs:choice> tag to <xs:sequence> tag. SAP does not support <xs:choice> tag as it allows flexible field sequencing in the structure, which does not go hand in hand with ABAP structure. You will get an error while generating the proxy object if your XSD contains <xs:choice> tag.
  4. If you have <xs:enumeration> tag (to define a list of acceptable values for the element) in your generated XSD, make sure the enumeration value for the field is correct. If you are not sure, better comment them out or you would have to spend more time in testing and populating all the possible values.
  5. Make sure that all elements with no subsequent elements underneath is typed using <xs:simpleType> tag, and not using <xs:complexType> tag. Otherwise, you will not be able to generate proxy object properly.

And last but not least, you need to check the correctness of the generated XSD by validating it against the sample XML file you get from the partner system.

Comments (Hide Comments)

Add Comment

Really nice way. However I am still facing the problem while trying it out. I created XML instance using stylus studio deleted XMLSchemaLocation which it was referring to and then created the XSD from the XML. But I again end up with a XSD which refers to another XSD for some elements though it has taken out now "import" statements from original XSD. It has created a small schema under the same folder where new schema is created and referring it by tag SchemaLocation again.

Any help on this matter will be appreciated. (Not sure if it is a right place to ask the query).

Many Thanks.

Hi Calvin,

Have you make sure that when you convert the XML back to XSD using XML tool, you have checked all types to be local?

Regards - Lim...

Posted by Calvin at Aug 12, 2008 11:22

Posted by Ruslim Chang at Aug 25, 2008 10:28 | Edit

Life is beautiful! Let's make it meaningful and colorful!