Creating Work Order Objects 3.0

Overview

There are three ways to generate work orders using the MES modules:

  1. Using the MES Work Order Table component
  2. Using the Business Connector Module 
  3. Using the script library (example below)


The following code block provides an example of how work orders can be created through scripting functions.

Example Function to Check and Create Work Order Objects

Code
def checkWorkOrder(woName):
	filter = system.mes.object.filter.createFilter()
	filter.setMESObjectTypeName('WorkOrder')
	filter.setMESObjectNamePattern(woName)
	filter.setEnableStateName('Enabled')
	list = system.mes.searchMESObjects(filter)
	
	if list.size() == 0:
		return False
	return True


woName = 'WO 1234'
quantity = 10000.0
dueDate = system.date.addDays(system.date.now(), 10)

#Check if work order already exists
if not checkWorkOrder(woName):
	
	##Get a material link for the work order material
	matLink = system.mes.getMESObjectLinkByName('MaterialDef', material)
	
	##Create the work order (named "WO 1234") against the material represented by the material link
	wo = system.mes.workorder.createMESWorkOrder(woName, matLink)
	
	##Set some production related properties
	wo.setWorkOrderQuantity(quantity)
	wo.setDueDate(dueDate)
	
	##Save the Work Order object to manifest the changes
	system.mes.saveMESObject(wo)

else:
	print 'work order ',woName, ' already exists'     return system.mes.workorder.getMESWorkOrder(woName)

References

MES Work Order Object