Casting is a method utilized in Java that uses an object of one type in place of another type, among the objects permitted by inheritance and implementations. The class and their respective hierarchy paths are shown in the table below:
Class | Hierarchy Path |
---|---|
Requisition | BaseObject → ClusterRoot → Approvable → LineItemCollection → PunchOutLineItemCollection → ProcureLineItemCollection → ReceivableLineItemCollection → Requisition → ShoppingCart |
ReqLineItem | BaseObject → LineItem → PunchOutLineItem → ProcureLineItem → ReqLineItem → ShoppingCartLineItemLineItem |
PurchaseOrder | BaseObject → ClusterRoot → Approvable → LineItemCollection → PunchOutLineItemCollection → ProcureLineItemCollection → ReceivableLineItemCollection → PurchaseOrder DirectOrder, PCardOrder, ERPOrder, CopyOrder |
POLineItem | BaseObject → LineItem → PunchOutLineItem → ProcureLineItem → POLineItem → CopyPOLineItem |
Invoice/InvoiceReconciliation | BaseObject → ClusterRoot → Approvable → LineItemCollection → PunchOutLineItemCollection → ProcureLineItemCollection → StatementCoreApprovable → Statement (Invoice, InvoiceReconciliation) |
Contract/ContractRequest | BaseObject → ClusterRoot → Approvable → LineItemCollection → PunchOutLineItemCollection → ProcureLineItemCollection → ReceivableLineItemCollection → ContractCoreApprovable (Contract, ContractRequest) |
Certain field paths can be used in customization without the use of casting, such as using the field path LineItemCollection.IsNonPO from a custom field created on the InvoiceLineItem class. There is a direct path for this in the system, so no special method such as casting needs to be used. However, if you wish to navigate between certain classes, casting needs to be used to facilitate the necessary field path. Casting follows the following basic format:
12(@(line-level class)field that links the accounting class and line-level class).desired field
path on the line-level class
If you need to employ two instances of casting simultaneously, you can use the following format:
1(@(header-level class)(@(line-level class)field that links the accounting class and line-level class).field that links the line-level class and header-level class).desired field path on the header-level class
The below examples help explain this:
- Casting from the SplitAccounting class to the InvoiceLineItem class:
Use case: The customer has implemented a custom validity condition on a certain accounting field but does not want to validate this field on tax line items. This can be achieved by adding the following OR statement within the validity statement. The casting allows the system to rule out the validation for tax line items.
Code Snippet12thisField != null or ((@(ariba.invoicing.core.InvoiceLineItem)LineItem).LineType.UniqueName.contains('Tax')) - Casting from the Accounting class to the Contract header (ContractCoreApprovable class, which encompasses both Contract and ContractRequest):
Use case: The customer wants to require a certain accounting field only for non-release contracts. The casting allows the system to rule out the validation for release-order contracts.
Code Snippet12(@(ariba.contract.core.ContractCoreApprovable (@(ariba.contract.core.ContractCoreApprovableLineItem)LineItem).LineItemCollection).ReleaseType == 0 ? thisField != null : true
You can apply a similar type of casting to read values across dependent classes based on customer business scenarios to be used on custom conditions as part of the deployment.