on 05-14-2008 6:44 PM
Hi,
I have an RFC module created which has import parameters and table parameters to pass values to give the desired output back.
I have a requirement where I have to pass these values (inport parameters and table data) from the Java User defined fucntion in graphical mapping to the RFC. Can you assist me on how to pass the table data from Java UDF? How should my variable be declared for RFC table parameter ?
Appreciate your input.
Thanks,
Hi
The best solution is mentioned in this blog. Step by Step
/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups
Thanks
Sebin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Resolved by myself
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
UDF accepting the connection parameters at the runtime when you want to use the sample JCO code for performing RFC lookups across SAP systems.
function myudf(String a[], String b[], String c[],String d[], ResultList result, Container container)
{
String DBTABLE = a[0];
String lookUpField = d[0];
String WHERE_CLAUSE = b[0]" = ""'"c[0]"'" ;
String sapClient = SAP CLIENT;
String hostName = hostname of SAP system;
String systemNumber = system number;
String userName = SAP Logon UserName;
String password = SAP Logon password;
String language = "EN";
JCO.Repository mRepository;
JCO.Client mConnection = JCO.createClient(
sapClient,
userName,
password,
language,
hostName,
systemNumber );
// connect to SAP
mConnection.connect();
// create repository
mRepository = new JCO.Repository( "GenericRFCMappingLookup", mConnection );
// create function template to select data from any table
JCO.Function function = null;
IFunctionTemplate ft = mRepository.getFunctionTemplate("RFC_READ_TABLE");
function = ft.getFunction();
// Obtain parameter list for function
JCO.ParameterList input = function.getImportParameterList();
// Pass function parameters
// set import parameters table name and RFC
input.setValue( DBTABLE, "QUERY_TABLE");
input.setValue( "," , "DELIMITER");
//Fill the where clause of the table
JCO.ParameterList tabInput = function.getTableParameterList();
JCO.Table inputTable = tabInput.getTable("OPTIONS");
inputTable.appendRow();
inputTable.setValue(WHERE_CLAUSE,"TEXT");
mConnection.execute( function );
//Find the position of the field that has to be lookedUp
JCO.Table lookupFieldPos = function.getTableParameterList().getTable("FIELDS");
int pos = -1;
for (int i = 0; i < lookupFieldPos.getNumRows(); i++)
{
lookupFieldPos.setRow(i);
if (lookupFieldPos.getString("FIELDNAME").equals(lookUpField))
pos = i;
}
//Get the exact lookupvalue from the position obtained above
JCO.Table valueSet = function.getTableParameterList().getTable("DATA");
for (int i = 0; i < valueSet.getNumRows(); i++)
{
valueSet.setRow(i);
String resultSet [] = valueSet.getString("WA").split(",(?=(?:[\"]*\"[\"]\")(?![^\"]*\"))");
result.addValue(resultSet[pos]);
}
mConnection.disconnect();
}
/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.