We’re running into a blocking issue with the Agile SDK cost rollup API on version 9.3.4. When processing complex BOMs, the cost rollup calculation fails whenever component cost attributes are missing or null. Our integration calls the cost rollup for assemblies with 100+ components, and even a single missing cost value causes the entire operation to fail.
The error we’re getting:
com.agile.api.APIException: Cost calculation failed
at CostRollupHelper.calculateTotalCost(line 234)
Caused by: NullPointerException - Component cost is null
We’ve validated that the BOM structure is correct and most components have valid cost data. The issue occurs specifically when a few components lack cost information. Is there a way to configure the API to skip null costs or use default values? Our automated cost analysis process is completely blocked until we resolve this.
I’ve seen this behavior before. The cost rollup API doesn’t handle null cost attributes gracefully by default. You need to pre-validate your component costs before calling the rollup. A quick check on the BOM items can identify which components are missing cost data.
I recommend checking your error handling implementation. The cost rollup API should allow you to catch these exceptions and handle them programmatically. You could iterate through the BOM, identify problematic components, log them for review, and then retry the rollup after addressing the data quality issues. This gives you better control over the process rather than having the entire operation fail.
I’ve implemented a complete solution for this exact scenario. Here’s the comprehensive approach that addresses all three key areas:
1. Agile SDK Cost Rollup API Usage:
The standard cost rollup API doesn’t provide built-in null handling, so you need to wrap it with validation logic. Before calling the rollup, iterate through all BOM components and check cost attributes.
2. BOM Component Cost Attribute Validation:
Implement pre-validation:
IBOM bom = (IBOM) session.getObject(IBOM.OBJECT_TYPE, bomNumber);
for (IRow row : bom.getRows()) {
IItem component = row.getReferent();
Object cost = component.getValue(ItemConstants.ATT_COST);
if (cost == null) logger.warn("Missing cost: " + component.getName());
}
3. Error Handling for Missing Data:
Create a wrapper method that catches APIException and processes components individually. For components with null costs, you have three options:
- Apply a zero-cost default for calculation purposes
- Exclude them from rollup and calculate partial costs
- Flag them for manual review and skip the rollup
Our implementation uses a configuration property to define default behavior. We set cost.rollup.null.handling=ZERO_DEFAULT which tells our wrapper to treat null costs as zero during calculation. This allows the rollup to complete while logging data quality issues.
The key is separating validation from calculation. Run validation first, handle exceptions gracefully, and provide clear logging for missing data. You can also extend this to automatically populate default costs based on material type or category if your business rules permit.
For complex BOMs with 100+ components, consider implementing batch validation with parallel processing to improve performance. We’ve processed BOMs with 500+ components successfully using this approach.
One additional recommendation: implement a scheduled job that identifies components with missing costs across all BOMs and generates reports for data stewards. This proactive approach reduces API failures over time.
From a data modeling perspective, this is actually highlighting a data quality issue. Missing component costs shouldn’t exist in a production BOM if cost rollup is a critical process. Consider implementing validation rules at the component creation stage or using workflows to enforce cost attribute population before items can be added to BOMs. This prevents the API issue from occurring in the first place.