For access using the special lookup API, developers do not require any knowledge of the structure of the payload. Instead, they pass the API string commands that are to be executed in the application system called.
Currently, there is one special lookup API for the JDBC adapter. Developers use the DataBaseAccessor class to implement this API.
The special lookup API is part of the mapping API (see the getDataBaseAccessor method of the LookupService class in the Javadoc documentation). For more information about these APIs, see SAP Developer Network at https://www.sdn.sap.com/irj/sdn/javadocs (SDN user required).
import
java.util.Iterator;
import
java.util.Map;
import
com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
import com.sap.aii.mapping.lookup.*;
public class Parametraziation_Java extends AbstractTransformation {
public void transform(TransformationInput in, TransformationOutput out)
throws StreamTransformationException {
DataBaseAccessor accessor = null;
try {
//
1. Read Import Parameter to get the channel ID
for Lookup
Channel channel =
in.getInputParameters().getChannel("MYCHANNEL");
//
2. Get a database accessor for the
channel.
accessor
= LookupService.getDataBaseAccessor(channel);
//
3. Prepare a sql statement
"sqlStatement".
String
sqlStatement = "SELECT a, b, c FROM TABLE2";
//
4. Execute lookup.
DataBaseResult
result = accessor.execute(sqlStatement);
//
5. Iterate over the result rows.
for
(Iterator rows = result.getRows(); rows.hasNext();) {
Map
columnMap = (Map) rows.next();
Object
valueA = columnMap.get("a");
Object
valueB = columnMap.get("b");
}
// Steps 4. and 5. can be executed several times.
} catch (Exception e) {
// Exception Handling
}
finally {
// 6. Close the accessor
in order to free resources.
if
(accessor != null)
accessor.close();
}
}
}