Friday 7 June 2019

Accessing value mapping in groovy script

For some scenarios, we would need to access the deployed Value mapping table in the iflow, there is a possible way to access the values using the below script:


Groovy Script:

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import com.sap.it.api.ITApiFactory;
import com.sap.it.api.mapping.ValueMappingApi;

def Message processData(Message message)
{
def a = ITApiFactory.getApi(ValueMappingApi.class, null);

//format sourceAgency, sourceIdentifier, sourceValue, targetAgency, targetIdentifier

def mappedValue = a.getMappedValue("C4C", "Country", "yMKT", "Country", "Austria");

def messageLog = messageLogFactory.getMessageLog(message);

messageLog.setStringProperty("Mapped Value", mappedValue);

return message;
}


Hope this Helps!!!



2 comments:

  1. Hi,

    I tried your coding in a normal groovy script, outside of the mapping. Unfortunately it doesn’t work there:

    https://tinyurl.com/y38auwqn

    Do you any idea how to resolve this?

    Thanks,

    Chris

    ReplyDelete