Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
ToanPT
Explorer
4,300

Basic Acknowledgement


A lot of very interesting blogs around CPI Value Mapping were published for the past 5 years, I noticed that automatic process was not possible because API is missing an easy way to create Value Mapping.

In the latest blog, SAP Cloud Integration: maintenance of Value Mapping artifacts through OData API

, author is suggesting this manual preliminary step  :

"Create a VM object and maintain Source and Target Agencies as well the Identifiers needed by your scenario. Please note that it is required to maintain the first default entry manually as it’s not possible to save an object without at least one value mapping entry. Deploy your initial VM to your tenant."

My first blog is suggesting a workaround to this step, to create Value Mapping using API.

Exploring API


Existing documentation

First method : "upsert" suggest ability to insert or update :


UpsertValMaps


POST /UpsertValMaps allows to add values to an existing  Value Mapping,

but trying to insert a value to a non-existing  <SrcAgency/SrcId/TgtAgency/TgtId> would respond with 404 :
"Could not find source agency:SourceAgency, source identifier:123, target agency:TargetAgency and target identifier:456"

2nd method :


ValueMappingDesigntimeArtifacts


 

POST /ValueMappingDesigntimeArtifacts

upload a value mapping


Available parameters


Let's make a focus on parameter ArtifactContent

"ArtifactContent": "integration flow zip content in base64-encoded format"

Let's assume this is as zipped representation of an exported Value Mapping.

 

So let's try to :

  • export (from CPI interface (Design => Arfifacts) a newly created value mapping

  • delete this value mapping (from the same interface)

  • encode zipped binary file as base64 String (this makes it compatible with json content)

  • try to call API /ValueMappingDesigntimeArtifacts, valuing ArtifactContent parameter with previously encoded in Base64 string


And it creates the Value Mapping => Hurray !

 

Now let's dig deeper in the zip archive file, it reveals following structure


Zip archive folder structure


 

Looking into  value_mapping.xml file :

 


value_mapping.xml file content


 

Playing with this zip content,  we can assume that it is possible to :

-delete the value mapping (via CPI interface)

-alter zip file to change some values in value_mapping.xml

-encode zip faile in base 64

-re-create value mapping through API call.

 

We have understood that the

  • POST method allows us to create a value mapping.

  • we can change archive content to create value mapping we want (with at least a couple of entries)


 

Now let's try to design a flow that will allow us to create a value mapping :

 

CPI IFLOW


For sure : CPI has the toolbox to handle zip and base64 contents.

 

Starting point : it seems easier to me to start from an existing archive zip file, and to alter value_mapping.xml file content.

 

Let's start with an existing and downloaded Value Mapping zip file.

Just to be sure, let's empty value_mapping.xml file, inside zip archive.

Then let's encode this zip as base-64 String using notepad++.

=> this base64 string will be helpful soon !

 

 


suggested Iflow


 

This is proposal of steps to build the iflow :

Step 1 : content modifier setting body with my base64 string

Step 2 : base64 decode (obtaining a zip file)

Step 3  : zip splitter  : iterating on archive files, one by one

router testing file name = value_mapping.xml

${header.zipFileName} = 'value_mapping.xml'

Step 4 : set the body with payload corresponding to ValueMapping xml representation

that could be found earlier :


 

Step 5 : Gather in zip mode => re-creates zip file

Step 6 : base64 encoding => result is a base64 String representing Value Mapping and that can be passed to API method

 

For now, using this base64 string with API call from Postman :

POST /ValueMappingDesigntimeArtifacts

as « ArtifactContent »


 

...works...


Created Value Mapping



Conclusion :


We are able to use base64 artifactContent parameter to create a Value Mapping through API.


I suggested a CPI flow to create this base64 string.

Nevertheless, we are unable to create a value mapping without a first set of value. So it may be hard to separate Value mapping creation from its dataset.

I hope you found this blog helpful, don't hesitate to comment or ask questions, I will do my best to answer to you quickly.

 

 

Related community content links and other related blog post


Dynamic Value Mapping in SAP CPI | SAP Blogs (2018)

Key-Value Mapping in CPI for huge data sets has never been easier | SAP Blogs (2018)

Key-Value Mapping in SAP Cloud Platform Integration (CPI) with an integration Flow | SAP Blogs (2018)

https://int4.com/sap-cpi-value-mapping-maintenance (2020)

SAP Cloud Integration: maintenance of Value Mapping artifacts through OData API (2023)
1 Comment
Labels in this area