cancel
Showing results for 
Search instead for 
Did you mean: 

Can any one Modify this Code and reply back

Former Member
0 Kudos

Hi,

Iam using this UDF presently to get one return value from RFC Lookup mapping Table.

Now I want two return values from the RFC Lookup Mapping Table.

//write your code here

int length=pospymtvalue.length;

String DBTABLE = tabname[0];

String lookUpField = lkpfld[0];

String sapClient = "500";

String hostName = "xidev";

String systemNumber = "00";

String userName = "user1";

String password = "pass";

String language = "EN";

JCO.Repository mRepository;

JCO.Client mConnection = JCO.createClient(

sapClient,

userName,

password,

language,

hostName,

systemNumber );

// connect to SAP

mConnection.connect();

for(int j=0;j<length;j++)

{

String WHERE_CLAUSE = pospymt[0]" = ""'"pospymtvalue[j]"'";

// 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();

Regards

Bopanna

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Ans

Former Member
0 Kudos

Hi Boppana,

For loop at the end will return more than one values if it has more than one value for the input values.

chirag.

Former Member
0 Kudos

Hi,

Can you please modify it and reply back

Regards

Bopanna

Former Member
0 Kudos

Hi Bopanna,

U have already written four loop at the end of ur code so it will return the values as per the RFC output.

Chirag