use of org.pentaho.di.trans.steps.sapinput.sap.SAPResultSet in project pentaho-kettle by pentaho.
the class SAPConnectionMock method executeFunctionUncursored.
public SAPResultSet executeFunctionUncursored(SAPFunction function, Collection<SAPField> input, Collection<SAPField> output) throws SAPException {
SAPResultSet srs = new SAPResultSet();
if (function.getName().equalsIgnoreCase("SearchCustomer")) {
for (int i = 1; i <= 9; i++) {
SAPRow sr = new SAPRow();
sr.addField(new SAPField("Name", "", "String", "Casters" + i));
sr.addField(new SAPField("Firstname", "", "String", "Matt" + i));
sr.addField(new SAPField("Adress", "", "String", "Pentahoway 77"));
sr.addField(new SAPField("Zipcode", "", "Number", 12345 + (i * 10000)));
sr.addField(new SAPField("CustomerGroup", "", "String", "ABC" + i));
srs.addRow(sr);
}
} else {
for (int i = 1; i <= 9; i++) {
SAPRow sr = new SAPRow();
sr.addField(new SAPField("Field4", "", "String", "Testvalue" + i));
sr.addField(new SAPField("Field5", "", "Number", 12345 + (i * 10000)));
sr.addField(new SAPField("Field6", "", "Decimal", 77.88 + (i * 10)));
srs.addRow(sr);
}
}
return srs;
}
use of org.pentaho.di.trans.steps.sapinput.sap.SAPResultSet in project pentaho-kettle by pentaho.
the class SAPConnectionMockTest method main.
/**
* How to use a SAPConnection
*
* @throws SAPException
*/
public static void main(String[] args) throws SAPException {
// how to obtain a connection
SAPConnection sc = SAPConnectionFactoryMock.create();
// how to open a connection
// @Matt:
// please show us how to retrieve the connection params from the
// pentaho environment
DatabaseMeta cp = new DatabaseMeta("SAP", "SAPR3", "Plugin", "192.168.9.50", null, null, "USER", "PASSWORT");
cp.getAttributes().setProperty(SAPR3DatabaseMeta.ATTRIBUTE_SAP_SYSTEM_NUMBER, "00");
cp.getAttributes().setProperty(SAPR3DatabaseMeta.ATTRIBUTE_SAP_CLIENT, "100");
cp.getAttributes().setProperty(SAPR3DatabaseMeta.ATTRIBUTE_SAP_LANGUAGE, "DE");
sc.open(cp);
// how to query all functions
System.out.println("how to query all functions");
Collection<SAPFunction> csf1 = sc.getFunctions("");
for (SAPFunction sapFunction : csf1) {
System.out.println(sapFunction);
}
System.out.println();
// how to query functions
System.out.println("how to query functions");
Collection<SAPFunction> csf2 = sc.getFunctions("1");
for (SAPFunction sapFunction : csf2) {
System.out.println(sapFunction);
}
System.out.println();
// how to get a function
System.out.println("how to get a function");
SAPFunction sf = sc.getFunction("SearchCustomer");
System.out.println(sf);
System.out.println();
// how to get function signature
System.out.println("how to get function signature");
SAPFunctionSignature sfs = sc.getFunctionSignature(sf);
System.out.println("input:");
for (SAPField field : sfs.getInput()) {
System.out.println(field);
}
System.out.println("output:");
for (SAPField field : sfs.getOutput()) {
System.out.println(field);
}
System.out.println();
// how to execute a function
System.out.println("how to execute a function");
Collection<SAPField> input = new Vector<SAPField>();
input.add(new SAPField("Name", "", "input_single", "Casters"));
Collection<SAPField> output = new Vector<SAPField>();
output.add(new SAPField("Name", "", "output_single"));
output.add(new SAPField("Firstname", "", "output_single"));
output.add(new SAPField("Adress", "", "output_single"));
output.add(new SAPField("Zipcode", "", "output_single"));
output.add(new SAPField("CustomerGroup", "", "output_single"));
SAPResultSet sfr = sc.executeFunctionUncursored(sf, input, output);
for (SAPRow row : sfr.getRows()) {
System.out.println(row);
}
System.out.println();
// Close the connection
//
sc.close();
}
Aggregations