Fetch SOAP webservice call with deep structure in ABAP [Part I]

Fetch SOAP webservice call with deep structure in ABAP [Part I]

Here is a step by step guide on how I retrieve data from a SOAP web service in ABAP for storing data in an internal table.  This project was created on SAP BW 7.40 SP17.

. The first article below will be about checking the SOAP web service and creating the structures, so we can retrieve the deep structure XML. The second part will be about how to create a simple transformation. The third and final part will be about how to fetch the data from the web service with ABAP into internal tables.

The scenario for which I did the project and made the solution is following. We are gathering data about busses, trams and metros in a city. The data was provided by a third party and they had already set up a SOAP web service for people to call this data (so there was no negotiating on how I was going to receive the data or in which format). When inspecting the XML data all I knew was that in the XML if a node had a ChildNode that it could have 1 or multiple times this ChildNode. Example:

<firstnode>

<secondnode></secondnode>

</firstnode>

<firstnode>

<secondnode></secondnode>

<secondnode></secondnode>

</firstnode>

So from the start, I knew we were dealing with a complex XML structure. Below I will explain how I tackled the problem and what solution came out of it.

The first thing I do when I get such a request is to test the SOAP web service. I use SOAPUI for this. You can simply create a SOAP request fill in the WSDL and retrieve all the methods and test them to see if they all work. The main reason I use SOAPUI is to check the layout of the data I’m fetching. As well as extra parameters such as the body, URL and SOAPAction that we need later. It is not necessary to use SOAPUI if you know all parameters to do the call as well as the layout of the data you are retrieving.

 width=

 width=

 width=

Click ‘+’ open the method and double click the request.
 width=

On the top, you’ll retrieve the URL link (this is later needed) on the left the body (also needed later) and on the right the result from the SOAP request after running it.

And the XML we retrieve could be like this:

 width=

So we have a multi-structure of lignes that could have multiple indices which on their turn could have multiple statuts.

After this, we simply have to decide which data we need and create a table structure for it. For us it is simple we take all the data and our table structure will look like this:

  • Ligne structure
  • Including all data of the XML at ligne level
  • Including the indice table structure
  • Including all data of the XML at indice level
  • Including the statut table structure
  • Including all data of the XML at statut level

For creating the table structure we will start in a reversed way.

So in SE11 create a structure ZSVOI_STATUT (statut is the lowest level):

 width=

All the components are elements of the soap request in statut.

Afterward, create a display table of statut so we can use it in the indice table later:
 width=

Then create the indice structure:

 width=

So here you can see we are starting to create our table structure like the XML structure by including the structures into each other.

So again, create a display table for indice:

 width=

And then again do everything for Ligne:

 width=

 width=

As well as an overruling table with this display table of LIGNE:

 width=

This will conclude part 1 out of 3 for this article. The next article will show and explain how to create a simple transformation with XSLT_TOOL.

Blog by Sven Swennen