on 04-01-2008 11:59 AM
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
Ans
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.