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.
- 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) {
- }
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.
- 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.
Related Articles
Transporting your migrated SAP CPI iFlows to production
See how to handle the transport of your iFlow to production Here you will see how to transport your migrated and tested iflow into production. Create a landscape for the transport. It is possible to use only one system for the setup to see the ...
How to migrate Function Libraries
What to use for your migration of message mappings from SAP PI/PO to Cloud Integration? That's a great question and there are two options for handling linked Function Libraries (FL): Use the new FL object in Cloud Integration Convert the FL into ...
FAQ: What kinds of problem will I face with my SAP PI/PO to Cloud Integration migration with your tool
We are still improving the Figaf Tool to make SAP PI/PO to Integration Suite/CPI better. We often get asked what is not supported. Many of the problems comes from the fact that it is two different environments that we try to convert artifacts ...
Protecting Virtual Assets
Protecting the virtual assets One you have used the tool to move items to the virtual QA how to you ensure that nobody has access to it and make modifications to it. It is pretty easy to ensure that the artifacts are protected with the access ...