Implement RFC Lookup in a migrated mapping

Implement RFC Lookup in a migrated mapping

If you have a Message Mapping with an RFC lookup then the migration will create a Groovy script with a mock function like the following.

  1. import com.sap.it.api.mapping.*; import com.sap.conn.jco.JCoDestination; import com.sap.conn.jco.JCoDestinationManager; import com.sap.conn.jco.JCoFunction; import com.sap.conn.jco.JCoParameterList; import com.sap.conn.jco.JCoRepository; def void RFC_ZIS_EUCOUNTRY(String[] I_COUNTRYCODE, Output output, MappingContext context) {
  2. }
Having RFC lookup in your message mapping may not be ideal so consider if you can remove them and replace the function with some standard approach. 
If it is not possible to replace the functions without a major rewrite you can start from our sample.
You will need to implement the RFC Lookup your self. It can follow the structure. 
  1. import com.sap.it.api.mapping.*; import com.sap.conn.jco.JCoDestination; import com.sap.conn.jco.JCoDestinationManager; import com.sap.conn.jco.JCoFunction; import com.sap.conn.jco.JCoParameterList; import com.sap.conn.jco.JCoRepository; def void RFC_ZIS_EUCOUNTRY(String[] I_COUNTRYCODE, Output output, MappingContext context) { String RFCOutputFieldName = "O_IS_EU_COUNTRY"; String RFCModuleName = "ZIS_EUCOUNTRY"; //Get RFC destination name from property (Content Modifier) //Destination name can be found in Cloud Cockpit -> Subaccount -> Destinations JCoDestination destination = JCoDestinationManager.getDestination(context.getProperty("RFCDestination")); JCoRepository repo = destination.getRepository(); //Create connection to RFC module in question - in this case 'ZIS_EUCOUNTRY' JCoFunction RfcConnection = repo.getFunction(RFCModuleName); //Build RFC Request. JCoParameterList imports = RfcConnection.getImportParameterList() //setValue(<RFC Input field name>,<value>) imports.setValue("I_COUNTRYCODE", I_COUNTRYCODE[0]); //Call/execute RFC. RfcConnection.execute(destination); //Get RFCResponse fields. JCoParameterList exports = RfcConnection.getExportParameterList(); //Get <RFC output Field> = 'O_IS_EU_COUNTRY' String retValue = exports.getString(RFCOutputFieldName); //Add RFC Value to output(mapping) Context output.addValue(retValue); //Add lookup value to log - if logProperty is 'yes' String logMe = context.getProperty("logProperty") if (logMe.equalsIgnoreCase("yes")) { context.setProperty("RFC_" + RFCModuleName + ":" + RFCOutputFieldName, retValue); } }
For this to work you will need to define an RFC destination in Cloud Foundry and link it to the iFlow.