Order and Inventory Management Apex API Developer Reference

scmc.ProductionOrderAPI

global with sharing class ProductionOrderAPI

Methods

Complete

global void Complete(Id productionOrderId, String lotNumber, String[] serialNumbers)

Complete specified production order. Lot Number and Serial Numbers are assigned to the resulting products. Costs from items are rolled up from the items used up in the production order and become the cost for the resulting product.

Input Parameters

Name Type Description
productionOrderId Id The ID of the production order to be completed.
lotNumber String A string that indicates the lot number that is assigned to the items created by the production order.
serialNumbers String[] A list of strings that contains the serial numbers to be assigned to the items produced by the production order. @group Inventory Management

Exceptions Thrown

Value Description
Exception - Exception indicating issues with the completion.

Return Value

Does not return a value.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

//A list of strings that contains the serial numbers to be assigned to the items produced by the production order.
//If the item needs no serial number, an empty list should be used.
List<String> serialNumberList = new List<String>{'serialNumber_123'};

//A string that indicates the lot number that is assigned to the items created by the production order.
String lotNumber = 'lotNumber_123';

//The ID of the production order to be completed.
Id productionOrderId = [SELECT Id FROM Production_Order__c LIMIT 1].Id;

new ProductionOrderAPI().Complete(productionOrderId, lotNumber, serialNumberList);

createProductionOrdersForSalesOrder

global List<scmc__Production_Order__c> createProductionOrdersForSalesOrder(Id salesOrderId)

Creates a production order from a sales order. The sales order usually has items on it that must be configured.

Input Parameters

Name Type Description
salesOrderId Id The ID of the sales order that indicates what needs to be built.

Exceptions Thrown

Value Description
Exception - Exception indicating issues with the production order completion.

Return Value

A list of production orders.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

//The ID of the sales order that indicates what needs to be built. The sales order usually has items on it that must be configured.
Id salesOrderId = [SELECT Id FROM Sales_Order__c LIMIT 1].Id;

new ProductionOrderAPI().createProductionOrdersForSalesOrder(salesOrderId);

CreateRequisition

global Id CreateRequisition(Id productionOrderId)

Creates a requisition to fulfill the requirement to complete the production order.

Input Parameters

Name Type Description
productionOrderId Id The ID of the production order that can't be fulfilled because one or more of its items are on backorder.

Exceptions Thrown

Value Description
Exception - Exception indicating issues when creating the requisition.

Return Value

The ID of the requision that was created.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

//The ID of the production order that can't be fulfilled because one or more of its items are on backorder.
Id productionOrderId = SELECT Id FROM Production_Order__c LIMIT 1].Id;

new ProductionOrderAPI().CreateRequisition(productionOrderId);

allocate

global void allocate(ID productionOrderId)

Allocates a production order. Checks the status on the production order to determine if it has been completely allocated or not.

Input Parameters

Name Type Description
productionOrderId ID The ID of the production order that needs to be allocated.

Exceptions Thrown

Value Description
Exception - Exception indicating issues when allocating the production order.

Return Value

There is no return.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

//The ID of the production order that needs to be allocated.
Id productionOrderId = [SELECT Id FROM Production_Order__c LIMIT 1].Id;

new ProductionOrderAPI().allocate(productionOrderId);

reverseAllocate

global void reverseAllocate(ID productionOrderId)

Reverses the allocation of a production order. This puts the production order back into an "Open" status and releases any inventory that was associated with the production order.

Input Parameters

Name Type Description
productionOrderId ID The ID of the production order that needs to be reverse allocated.

Exceptions Thrown

Value Description
Exception - Exception indicating issues when reverse allocating the production order.

Return Value

There is no return.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

//The ID of the production order needs to be reverse allocated.
Id productionOrderId = [SELECT Id FROM Production_Order__c LIMIT 1].Id;

new ProductionOrderAPI().reverseAllocate(productionOrderId);
© Copyright 2009–2023 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.