cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Cloud Integration Value Mapping

helmut_skolaut3
Contributor
0 Likes
3,405

I try to understand the concept of Value Mapping. I also read following blogs:

https://blogs.sap.com/2020/09/10/sap-cloud-platform-integration-cpi-part-12-value-mapping/

https://answers.sap.com/questions/540900/cpi--accessing-value-mapping-using-groovy-script.html

Unfortunately I don't understand, if i have several ValueMappings in my Package - how to configure in the Groovy which Value Mapping needs to be taken - or is it necessary to have overall Value Mappings unique entries?

Please help me to understand this missing puzzle piece 😉

BR Helmut

Accepted Solutions (0)

Answers (1)

Answers (1)

Ryan-Crosby
Active Contributor
0 Likes

Hi Helmut,

You can do it via the Groovy script with the following import and code statements (referenced from answer of 7a519509aed84a2c9e6f627841825b5a to consolidate content of two posts) -

import com.sap.it.api.ITApiFactory
import com.sap.it.api.mapping.ValueMappingApi

def valueMapApi = ITApiFactory.getApi(ValueMappingApi.class, null)
def value = valueMapApi.getMappedValue('source-agency', 'source-identifier', 'source-value', 'target-agency', 'target-identifier')

See the image from the blog for association of the source agency, identifier, and target agency, identifier examples. If you have multiple possibilities then you can add a content modifier step or something as per your requirements.

https://blogs.sap.com/wp-content/uploads/2020/09/5-9.png

Regards,

Ryan Crosby

helmut_skolaut3
Contributor
0 Likes

Thanks Ryan,

but where to tell which Value Mapping object should be used?

BR Helmut

Ryan-Crosby
Active Contributor
0 Likes

helmut.skolaut3 - based on the API it looks like you need only the agency and identifier information, along with the source value.

helmut_skolaut3
Contributor
0 Likes

So what happens if I have configured exactly the same combination in a 2nd Value Mapping? Which one is taken ?

Ryan-Crosby
Active Contributor
0 Likes

If you have two value mappings with the same data input, then they should have the same target value... and essentially the entries can be collapsed into a unique mapping. If your scenario has two unique target values, then you have a data association problem because that should not be possible.

helmut_skolaut3
Contributor
0 Likes

I understand what you are saying. But if you have 20 developers in a system - how much you have to spend into Governance on not produce a duplicate on Agency names to avoid duplicates?

Ryan-Crosby
Active Contributor

If they are duplicates where the target value is the same, then I don't think you are going to lose much, but that is really a process question. I cannot provide any helpful feedback because I'm on a team where I'm the only developer in the SAP space including CPI. I would think that the value mapping space would require very little upkeep, however.

helmut_skolaut3
Contributor

I have now the result - i have created two Value Mapping Artifacts (even within the same package!)

Both could have been deployed w/o any error or warning. And then my demo groovy is accessing with value "1000" and gets the value "AEUR" from "ValueMapping1"

For me, it's a classic design problem of the whole Value Mapping concept. I would have expected to have at least a deployment error for the 2nd Value Mapping telling, combination of source/target Agency+Identifier is already existing or better to have the choice to trigger explicitly the correct ValueMapping Artifact.

BR Helmut

alex_bundschuh
Product and Topic Expert
Product and Topic Expert

Hi Helmut,

you actually should get a deployment error when you try to deploy a second value mapping that uses the same combination, I just tested this and I am able to successfully deploy the second value mapping only if undeploying the first value mapping before.

In your case, the second value mapping gets deployed because you have a typo in the identifier of the second value mapping, you entered comany instead of company and hence there is no clash. Try the same combination and you will see that the second value mapping won't get deployed.

Alex

helmut_skolaut3
Contributor
0 Likes

Hi Alex,

thanks for you eagle-eyes 😉 Indeed this will change the behavior and i am getting while deployments from the logs:

But the developer will still is lag of information which Artifact is causing the clash.

But I think from the government - it would be good to use as Agency not only very generic names (e.g. "SAP") rather than take the Package identifier as a prefix (e.g. "demo.helmut.SAP") to prevent this kind of problem.

Best Regards
Helmut