Oracle Agile PLM SDK Java Snippet Generator: Items and BOM
This generator writes Java against the Oracle Agile PLM SDK (com.agile.api) that logs in, loads an item, reads its title block description and iterates its BOM table, plus a Process Extension custom action skeleton. It targets Agile PLM 9.3.x, including 9.3.6.
Fill in
Standalone SDK client (ReadItemBom.java)
import com.agile.api.APIException;
import com.agile.api.AgileSessionFactory;
import com.agile.api.IAgileSession;
import com.agile.api.IItem;
import com.agile.api.IRow;
import com.agile.api.ITable;
import com.agile.api.ItemConstants;
import java.util.HashMap;
import java.util.Iterator;
public class ReadItemBom {
public static void main(String[] args) {
IAgileSession session = null;
try {
HashMap<Object, Object> params = new HashMap<Object, Object>();
params.put(AgileSessionFactory.USERNAME, "integration_user");
params.put(AgileSessionFactory.PASSWORD, System.getenv("AGILE_PASSWORD"));
AgileSessionFactory factory = AgileSessionFactory.getInstance("http://agile.example.com:7001/Agile");
session = factory.createSession(params);
IItem item = (IItem) session.getObject(IItem.OBJECT_TYPE, "1000-0123");
if (item == null) {
System.out.println("Item 1000-0123 not found");
return;
}
Object desc = item.getValue(ItemConstants.ATT_TITLE_BLOCK_DESCRIPTION);
System.out.println("1000-0123: " + desc);
ITable bom = item.getTable(ItemConstants.TABLE_BOM);
System.out.println("BOM lines: " + bom.size());
Iterator<?> it = bom.iterator();
while (it.hasNext()) {
IRow row = (IRow) it.next();
Object child = row.getValue(ItemConstants.ATT_BOM_ITEM_NUMBER);
Object qty = row.getValue(ItemConstants.ATT_BOM_QTY);
System.out.println(" " + child + " qty " + qty);
}
} catch (APIException e) {
System.err.println("Agile API error: " + e.getMessage());
} finally {
if (session != null) {
session.close();
}
}
}
}Process Extension custom action (BomLineCountAction.java)
import com.agile.api.APIException;
import com.agile.api.IAgileSession;
import com.agile.api.IDataObject;
import com.agile.api.IItem;
import com.agile.api.INode;
import com.agile.api.ITable;
import com.agile.api.ItemConstants;
import com.agile.px.ActionResult;
import com.agile.px.ICustomAction;
public class BomLineCountAction implements ICustomAction {
public ActionResult doAction(IAgileSession session, INode actionNode, IDataObject affectedObject) {
try {
IItem item = (IItem) affectedObject;
ITable bom = item.getTable(ItemConstants.TABLE_BOM);
return new ActionResult(ActionResult.STRING, "BOM lines: " + bom.size());
} catch (APIException e) {
return new ActionResult(ActionResult.EXCEPTION, e);
}
}
}Compile and run
javac -cp AgileAPI.jar ReadItemBom.java java -cp AgileAPI.jar:. ReadItemBom (On Windows use ; instead of : in the classpath. Take AgileAPI.jar from the same Agile server release and patch level.)
Class, method and constant names follow the Agile PLM SDK Developer Guide and API reference (com.agile.api and com.agile.px): AgileSessionFactory.getInstance, createSession, USERNAME and PASSWORD, IItem.OBJECT_TYPE, ItemConstants.ATT_TITLE_BLOCK_DESCRIPTION, TABLE_BOM, ATT_BOM_ITEM_NUMBER, ATT_BOM_QTY, ICustomAction.doAction and ActionResult. The BOM table returned is for the item's current (latest released) revision unless you set a revision first. Verify the URL form and JDK level against your 9.3.x release notes.
Need an Agile to ERP BOM interface?
Tell us your Agile release and target ERP; we will outline the SDK calls, mapping and error handling for a reviewed design.
Optional. The tool and every export work without this. No spam.
How to use it
Enter your Agile application URL (the same base the Java client uses, typically http://host:port/Agile), an integration user and an item number. Put AgileAPI.jar from your server's SDK folder on the classpath, set the AGILE_PASSWORD environment variable and run. The program prints the description, the BOM line count and each child item number with its quantity. The second block is a Process Extension: once deployed and configured as a custom action, a user can run it from the Actions menu on an item and see the BOM line count.
- Always close the session in finally; leaked sessions count against server limits.
- Use an integration user with read privileges on the items you query.
- Match the AgileAPI.jar version to the server, including patch level.
How the SDK object model works
AgileSessionFactory.getInstance(url) returns a factory for one server, and createSession takes a map of USERNAME and PASSWORD. session.getObject(IItem.OBJECT_TYPE, number) returns the item or null. Values on the main page (title block, page two, page three) are read with getValue and an attribute constant such as ItemConstants.ATT_TITLE_BLOCK_DESCRIPTION. Tabs are tables: item.getTable(ItemConstants.TABLE_BOM) returns an ITable whose rows are IRow objects, and each cell is read with row.getValue and a BOM attribute constant. Custom attributes are read by their API name or attribute ID, which you find in Java client Admin under the class attributes.
Standalone client versus Process Extension
A standalone client runs outside Agile, opens its own session and suits integrations, nightly extracts or ERP interfaces. A Process Extension runs inside the Agile application server: Agile passes in an already authenticated session, the node that triggered it and the affected object, so you never handle passwords. Custom actions implement ICustomAction and return an ActionResult; event-driven logic uses the event framework interfaces instead. PX classes are packaged as a jar, deployed to the server's SDK extensions folder (integration/sdk/extensions under the Agile home in a default install) and registered in Java client Admin under Process Extensions.
Gotchas
After an Agile upgrade, recompile every PX and SDK client against the new AgileAPI.jar; mismatched jars cause odd runtime errors. Reading a BOM returns rows for the current revision, so pending changes may not appear unless you set the revision on the item first. Iterating very large BOMs one row at a time is slow over the network; for bulk extracts, use queries or the Agile Integration Services where available. Run integrations as a dedicated user and audit what it can see; the SDK enforces the same privileges as the UI.
Frequently Asked Questions
How do I connect to Oracle Agile PLM from Java?
Add AgileAPI.jar to the classpath, create a HashMap with AgileSessionFactory.USERNAME and PASSWORD, call AgileSessionFactory.getInstance(url) and then factory.createSession(params). The URL is the Agile application URL, for example http://host:7001/Agile. Close the session when done.
How do I read a BOM with the Agile PLM SDK?
Load the item with session.getObject(IItem.OBJECT_TYPE, number), call item.getTable(ItemConstants.TABLE_BOM), iterate the table and cast each element to IRow. Read child number and quantity with row.getValue(ItemConstants.ATT_BOM_ITEM_NUMBER) and ATT_BOM_QTY. For a full multi-level BOM, recurse into each child item.
What is a Process Extension (PX) in Agile PLM?
A Process Extension is custom Java code that runs inside the Agile server. Custom actions implement ICustomAction and can be triggered from the Actions menu, workflow or other PX hooks. They receive an authenticated session and the affected object, so no credentials are stored. They are deployed as a jar and registered in Java client Admin.
Where is the Agile PLM SDK Developer Guide?
It is part of the Oracle Agile PLM documentation library for each release, published on Oracle's documentation site alongside the API reference Javadoc. Use the guide that matches your release (for example 9.3.6), since constants and supported features change between versions.
If you want engineers to ask Agile PLM about items, BOMs and changes in plain English on your own servers, we can build that on top of these same SDK calls.
More Developer Tools tools
See all- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
- SAP Quality Notification Pareto SQL Query Generator
- SAP QM Usage Decision BAPI Skeleton
- ABAP Custom Exception Class Generator
- ABAP Unit Test Class Generator
Keep exploring
Free tools
- Oracle Agile PLM End of Life and Cloud PLM Migration Readiness AssessmentTen questions on your Agile PLM release, process extensions, event handlers, integrations, vault and data quality, scored into a readiness band with next steps.
- Oracle Agile PLM 9.3.6 Installation and Upgrade ChecklistA step-by-step checklist for installing Agile PLM 9.3.6 or upgrading from an earlier 9.3.x release, from certified stack checks to post-install smoke tests.
- SuiteScript search.create Snippet GeneratorBuild a ready-to-paste N/search snippet with a filter, three columns and a paged result loop that respects governance.
Runs with your ERP
- Arena PLM and Oracle NetSuite: syncing items, BOMs and ECOsHow Arena PLM passes released items, BOMs and ECOs to Oracle NetSuite, what data flows, setup steps, common mapping pitfalls and where a private AI layer helps.
- OpenBOM and Oracle NetSuite: from CAD BOM to assembly itemsHow OpenBOM for NetSuite moves SOLIDWORKS and other CAD BOMs into NetSuite assembly items and BOMs, push and pull modes, setup steps, pitfalls and AI use.