Example 4: Working with Manufacturing Orders
How to work with Manufacturing Orders using ProcessForce API
Adding New Manufacturing Order
-
Create IManufacturingOrder Object
IManufacturingOrder mor = company.CreatePFObject(CompuTec.ProcessForce.API.Core.ObjectTypes.ManufacturingOrder);
-
Set which BOM object you want to copy from:
//Set ItemCode if BillOfmaterial does not have a Revision
mor.U_ItemCode = "Chair01";
//or Get Code of BillOFMaterial
SAPbobsCOM.Recordset rec = company.SapCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
rec.DoQuery(string.Format("Select Code from [@CT_PF_OBOM] where U_ItemCode=N'{0} and U_Revision=N'{1}'", "Table01", "Rev01"));
mor.U_BOMCode = rec.Fields.Item(0).Value; -
Set quantity and required date:
mor.U_Quantity = 100;
mor.U_RequiredDate = DateTime.Today.AddDays(20); -
Add a document to a database:
mor.Add();
Updating Manufacturing Order
-
Create an IManufacturingOrder object:
IManufacturingOrder mor = company.CreatePFObject(CompuTec.ProcessForce.API.Core.ObjectTypes.ManufacturingOrder);
-
Load from the database:
//parameter for GetBykey is DocEntry
mor.GetByKey("4"); -
Change the values you require in this object:
mor.U_PlannedStartDate = DateTime.Today.AddDays(3);
///Calculate MOR Times
mor.CalculateManufacturingTimes();
mor.U_Status = ManufacturingOrderStatus.Released;
///Set Accept Lower Quantity for all backflushItems
///
var itemsToChange = mor.Items.Where(p => p.U_IssueType == "B");
foreach (var item in itemsToChange)
{
item.U_AcptLowerQty = YesNoType.Yes;
} -
Call update method:
mor.Update()