cancel
Showing results for 
Search instead for 
Did you mean: 

Valuemapping in javascript - SAP CPI

jacqueso
Explorer
0 Kudos
1,145

Hi There,


I have seen alot of examples of using the (com.sap.it.api.mapping.ValueMappingApi) class in groovy script, however I would like to be able to call a value mapping from javascript in an Integration flow in CPI.


Has anyone been able to do this and can perhaps share an example?

Accepted Solutions (1)

Accepted Solutions (1)

benjaminnehring
Explorer

Hi Jaques,

this script has worked for me:

importClass(com.sap.gateway.ip.core.customdev.util.Message);
importClass(com.sap.it.api.ITApiFactory);

function processData(message) {
    var sourceValue = message.getBody(java.lang.String);
    var valueMapService = ITApiFactory.getService(com.sap.it.api.mapping.ValueMappingApi, null);
    var targetValue = valueMapService.getMappedValue("sourceAgency", "sourceIdentifier", sourceValue,
                                                    "targetAgency", "targetIdentifier");
    message.setBody(targetValue);
     return message;
}

BR, Benjamin

jacqueso
Explorer
0 Kudos

Thanks bng that works perfectly

Answers (1)

Answers (1)

PriyankaChak
SAP Champion
SAP Champion
0 Kudos

Hi Jacques,

I have not tried it but class and methods will remain same for accessing value mapping API. Only code syntax will differ.

Please refer to link.

Regards,

Priyanka

jacqueso
Explorer
0 Kudos

Thanks for the reply, I did try this but could not get it to work, if anybody has an example of how to use these in javascript it would be really helpful.