Skip to Content
Author's profile photo Former Member

Create XML Files XSD-compliant exploiting SPROXY functionalities and XSLT transformation

In large enterprise environments, it happens more and more frequently to deal with XML files for a large variety of purposes. I won’t list here the benefits of this self-explanatory files, since there are already many blogs around talking about this.

Speaking about concrete cases, in recent times SEPA pain formats within EU payment gave a huge boost into the adoption of XML for communication between partners and authorities. For them, the recommended technology to use, often with pre-build templates like CGI_XML_CT, are DMEE trees.

But what about other formats that are not related to payments or for which we cannot use the ‘new’ Payment Medium Workbench? It may happens that what we get is simply an XSD and we’d need to carefully adhere to it to produce a file. XSD normally are complex (to adapt to different situations) and strict (to minimize the errors at the destination), so building a file manually is definitely not recommended.

Investigating the possibilities within our ECC 6.05 environment, we targeted three possibilities:

– DOM/SAX technology to build in memory the tree and then render it into an output stream via iXML classes

– passing through SAP PI via an ABAP Proxy

use SPROXY to automatically load the XSD into the system and generate the ABAP structures, as well as the XSLT transformation to be used in our program

In this BLOG, I will focus on the third option, since DOM/SAX technology require lots of custom code and the usage of PI may not be possible for all customers because:

– direct connection to the external partner is not possible/convenient

– we don’t want to introduce an additional point of failure (PI is down, I cannot produce my file?)

– or simply we would like to give back the file to the user immediately for manual processing

Following are the main steps to achieve the result:

  • load the External Definition of the XSD on SAP PI and create an Outbound Service Interface in PI, using the new External Definition

ExternalDef PI.png

  • Generate the proxy in SPROXY on the backend

Service Interface Proxy.png

     All ABAP structure are automatically generated inside the system:

Proxy Structures.png

  • Take the generate XSLT transformation name and use it in your program to pass from the (automatically generated) ABAP structures to the XML

XSLT Transform.png

ABAP Code.png

  • OPTIONAL: Fine tune the parameters of the proxy to be compliant with your external partner specifications

Proxy Parameters.png

In case XSD is changed, you’ll just need to re-upload it into PI (or SOAMANAGER), regenerate the proxy and adjust your ABAP code to fill out new fields.

That’s all Folks 🙂

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Mohammed Zia Shaik
      Mohammed Zia Shaik

      Hi ,

      I have a requirement where I need to use the XSD file to generate a XML file. I want to do it in ABAP without going to PI . Is it possible ? Do we have any standard classes or methods which can give me a XML file from XSD file ?

      Author's profile photo Juan Pablo Vargas Rodríguez
      Juan Pablo Vargas Rodríguez
      Author's profile photo Matthew Billingham
      Matthew Billingham

      I used this technique to write a ZUGFeRD parser. Very useful!