Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
Showing results for 
Search instead for 
Did you mean: 
0 Kudos

I am writing this blog post because I want to give back to this great collection of SAP knowledge and contribute myself. It is my very first blog post so bear with me.

There could be much better solutions out there but I was not able to find one within appropriate time so I came up with one that does the trick. As it did save my colleague some time I thought it might be helpful for the community, too.

I don´t mention the exact API as it was a custom one and it anyway does not matter that much as this approach can be applied in similar situations as well.



In order to process several records further in a next step, the UUIDs of those records had to be determined.

There already was an API in place that could be used to get the UUID but it needed to be called using another identifier and only returned a single record at a time.

A colleague approached me and asked if there was a way to collect the data using Postmans runner and then compile a list from it.


Challenge accepted.



Using Postmans runner, we can use a CSV file containing the identifiers to automate the requests.

During this we can utilize Java Script code to grab the UUID and log it in the console.

From the console we can grab the data and create a list for further usage.



  • API is activated

  • Postman is installed

  • API Call is already prepared incl. Authorization in Postman

  • CSV file with the input identifiers is available

  • Some experience with Postman is helpful


From the Get-Request we receive a response body that only contains the UUID and the respective XML structure.
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://systemID-api.s4hana.ondemand.com/sap/opu/odata/sap/YY1_BELNR_CDS/">
<title type="text">YY1_BELNR</title>
<link href="YY1_BELNR" rel="self" title="YY1_BELNR"/>
<title type="text">YY1_BELNR(guid'fa000000-6000-1000-a000-0000000000000')</title>
<category term="YY1_BELNR_CDS.YY1_BELNRType" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="YY1_BELNR(guid'fa000000-6000-1000-a000-0000000000000')" rel="edit" title="YY1_BELNRType"/>
<content type="application/xml">
<m:properties xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

After I checked several google hits stating that the body could be parsed to JSON with no success I decided to try it my own way.

I ended up with the following code, utilizing the fixed character lenghts:
    var jsonData = responseBody;
let guid = jsonData.substr(911,36)



EDIT: In a later, similar case I changed the coding in order to find a specific text which did not appear to be at the same character number in every iteration. I then learned the function .indexOf("insertstringhere"). It gives the number of the character where the string starts.

I added a variable I called start and adjusted the .substr function by giving variable start, adding the length of the string I was looking for and all characters between it and my target string:
    var jsonData = responseBody;
let start = jsonData.indexOf("ActivityType")
let id = jsonData.substr(start+13,4)


It needs to be inserted under the test tab of the request:

Test Code

  1. line: Store the response body in variable "jsonData" (the name is left from trying other people´s code)

  2. line: String operation, getting the part of the body starting at character 911 and taking the next 36 characters and storing it in variable "guid"

  3. line: Post value of variable "guid" to console as info message


After adding the code the request needs to be saved. Then the runner is set up using the CSV file with appropriate settings:

Runner Settings

After the runner iterated over the complete list all required records were visible in the console.

To maximize the console click "console" in the bottom left corner of the Postman window.


In order to see only info messages the console can be filtered.

To filter the console messages click "All Logs" in the top right corner of the console screen and deselect all options but "Info".


Filtering the console messages


After filtering the console only contained the info messages with the UUIDs:

UUIDs from console


Now I copied the console content to the clipboard using the icon:

Copy to clipboard

Now having a list of the UUIDs the next step could be automated as well by using it as a feed for a runner on a different API call.


Lessons Learned:

  • APIs combined with Postman and Java Script are indeed a powerful toolset

  • Java Script coding in this context can be quite simple but helpful (don´t be afraid to try it)

  • There are various possibilities to adapt this approach to different situations


In this blog post I outlined the challenge presented and the steps to accomplish the desired outcome using SAP S/4HANA Cloud APIs, Postman and a little bit of Java Script. I hope you also see the potential that lies in applying or even enhancing this approach in similar cases. The response content could for example also be fed into another API call thereby automating a otherwise tedious process - endless possibilities. 

Please leave a comment on how you applied this if you did. Any other feedback is of course also appreciated.
Labels in this area