Fetch SOAP web service call with deep structure in ABAP [Part III]

Fetch SOAP web service call with deep structure in ABAP [Part III]

This will be the last article that concludes the blog about fetching web service calls with deep structure into ABAP. Here we will review the ABAP code used to fetch the data into internal tables. If you haven’t read the 2 previous articles, please check them first at Part I and Part II

Now that we have a simple transformation we can start writing our program to fetch the data into the internal tables.
First, go to SE37 where we are going to create the function module which will call the SOAP request so we can retrieve the raw data.

Here is the full code I explain below the parameters that need to be changed in detail:


Ok, so the parameters that need to be changed in cl_http_client=>create_by_url.
All parameters come from the SOAPUI call that we did in the beginning, so I again suggest you take this next to you for filling in the correct parameters.


URL is number 1 on the image
proxy_host, proxy_service, ssl_id you only need these if your company uses a proxy, you’ll have to ask these parameters to your security or networking team.
lv_payload is the SOAPBody and is number 2 in the image.

set_header_field( name = 'SOAPAction' value = 'YourSOAPAction' )

In order to call a SOAP request you need to implement the SOAPAction this can be found as number 3 in the image, note you need to be in the WS-A tab. You can find more info on it: here

So what this code does is: do the SOAP call retrieve the data of that call and then convert it to UTF-8 and store it in a STRING.

The easiest way to test if the code is working is by going into debug mode and check the C_CONTENT variable with XML view:


If you are having errors on the call of lv_result, you should check if the SOAP web service is accessible and working. My preferred way of doing this is by using Postman. Select the POST option to enter the URL. For the headers, tab set the following 2: Content-Type with text/xml and SOAPAction with your soap action as explained above.  For the body, tab select raw and enter your body found in the SOAPUI. If you press send and you are able to retrieve the data here, it should also be accessible in ABAP. If not, you first must backtrace why your call isn’t working.

So now that we have the raw data, we want to use the simple transformation in a program to fetch the data into the corresponding fields of the structures we created at the start. And use this to fill up the internal tables.

So, go to transaction SE38 and create a new program.

I will again first post the complete code and then give some more info on it:


First, all of the data variables that we use are types of structures we made at the start.
In the CALL FUNCTION replace Your_FM with the FM you just created in SE37.
In CALL TRANSFORMATION replace Your_SimpleTransformation with the simple transformation you created before.

If you go into debug mode you’ll see that gt_create_nomin follows the exact structure of the tables you made at the start, you can fetch all of the data from all of the structures into individual internal tables by looping over them, and in each loop fetching the nested table into a new internal table as you can see in the code. You can then use all these internal tables filled with data to for example fill up a DSO as I did for my project in the empty area I left in the loops. I’m not including the code I used to fill up the DSO because it’s a lot of repetitive code and it’s not optimized yet.

This will conclude my blog on how to fetch data from a deep structure with ABAP.

Blog by Sven Swennen