cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Multiple records from functions

Former Member
0 Kudos

Hi Everyone

Im new to this stuff. Im trying through JCO. As far as the single recordsets like data of customer or article are concerned i get it through an array.

But i wanted to retrieve

1- Whole tables like (all articles)

2- Selected articles. or Customer order details (articles in PO)

That means multiple records in one go.

Later on ill display it in JTables.

Like for the past three days i was googling around. Thought like this ones not for my stomach. Came across this Forum. Thought its worth posting a request.

Here is the code

-


public String[] KSearch(String Knr) throws Exception{

String[] Result=new String[11];

IFunctionTemplate ftemplate= Con.repository.getFunctionTemplate("SucheKUNDE");

if (ftemplate == null)

throw new Exception("Funktionstemplate nicht gefunden");

JCO.Function function = ftemplate.getFunction();

JCO.ParameterList input = function.getImportParameterList();

input.setValue(Knr,"FieldName");

JCO.Client client = JCO.getClient(Con.conPoolId);

client.execute(function);

JCO.ParameterList output = function.getExportParameterList();

Result[0]=output.getString("NAME");

Result[1]=output.getString("VORNAME");

Result[2]=output.getString("GDATE");

Result[3]=output.getString("TELEFON");

Result[4]=output.getString("MAIL");

Result[5]=output.getString("STRASSE");

Result[6]=output.getString("PLZ");

Result[7]=output.getString("ORT");

Result[8]=output.getString("KONTO");

Result[9]=output.getString("INSTITUT");

Result[10]=output.getString("BLZ");

JCO.releaseClient(client);

return Result;

}

-


now instead of a single record what if im expecting a number of records, like what if i need customer over 25. Which means more than one. I have to get in tabular format so that i can display it in JTables.

Hope it a bit illustrative.

Regards

Edited by: Aaron Maleck on Jan 5, 2008 7:35 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

public String[] KSearch(String Knr) throws Exception{

String[] Result=new String11;

IFunctionTemplate ftemplate= Con.repository.getFunctionTemplate("SucheKUNDE");

if (ftemplate == null)

throw new Exception("Funktionstemplate nicht gefunden");

JCO.Function function = ftemplate.getFunction();

JCO.ParameterList input = function.getImportParameterList();

input.setValue(Knr,"FieldName");

JCO.Client client = JCO.getClient(Con.conPoolId);

client.execute(function);

-


// Maybe here you should use a JCO.Table Class to get the //ExportParameters such as

JCO.Table output = function.getTableParameterList().getTable( "tabelname" );

// so you can use setRow() Function to get the information of the //relevant record. such as the 3. Costum

output.setRow(3);// Record Number

Result[0]=output.getString("NAME");

Result[1]=output.getString("VORNAME");

Result[2]=output.getString("GDATE");

Result[3]=output.getString("TELEFON");

Result[4]=output.getString("MAIL");

Result[5]=output.getString("STRASSE");

Result[6]=output.getString("PLZ");

Result[7]=output.getString("ORT");

Result[8]=output.getString("KONTO");

Result[9]=output.getString("INSTITUT");

Result10=output.getString("BLZ");

-


JCO.releaseClient(client);

return Result;

}

Iam not sure that works. But you can try it. and reply me to tell if it really works as i think.

Hope helps.

Amao

Former Member
0 Kudos

Thanks alot.

Just wanted to ask if im supposed to set particular number of rows or i can get it through some built-in method.

I mean setting through output.getRowNumber or something in the direction instead of output.setRow(3)

Thanks once again.

Regards,