on ‎2022 Sep 06 2:48 PM
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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
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
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
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
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.