cancel
Showing results for 
Search instead for 
Did you mean: 

Pass Table data from UDF to the RFC function module

Former Member
0 Kudos

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,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (2)

Answers (2)

Former Member
0 Kudos

Resolved by myself

Former Member
0 Kudos

cOULD U EXPLIAN HOW TO RESOLVE BY YOURSELF???

Regards

GabrielSagaya
Active Contributor
0 Kudos

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