Overview

This kb explains how to use scripting functions and the Work Order Table component to create Work Order objects.

Applies To and Version Info

This feature applies to Track & Trace and OEE 2.0 and is available in all versions.

Details

Work orders can be created using the new MES Work Order Table component in OEE 2.0. It is also possible to create Work Orders through scripting and this is the recommended approach when an interface exists between an ERP system and the MES application.

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

 

from java.util import Calendar
now = Calendar.getInstance()
now.set(2017, 02, 31)
 
##Get a material link for the work order material
matLink = system.mes.getMESObjectLinkByName('MaterialDef', 'Pepper')
 
##Create the work order (named "WO 1234") against the material represented by the material link
wo = system.mes.workorder.createMESWorkOrder('WO 1234', matLink)

##Set some production related properties
wo.setWorkOrderQuantity(10000.0)
wo.setDueDate(now.getTime())

##Save the Work Order object to manifest the changes
system.mes.saveMESObject(wo)
Example Function to Check and Create Work Order Objects
def checkWorkOrder(woName, matName):
	filter = system.mes.object.filter.createFilter()
	filter.setMESObjectTypeName('WorkOrder')
	filter.setMESObjectNamePattern(woName)
	list = system.mes.searchMESObjects(filter)
		
	if list.size() == 0:
		matLink = system.mes.getMESObjectLinkByName('MaterialDef', matName)
		obj = system.mes.workorder.createMESWorkOrder(woName, matLink)
		system.mes.saveMESObject(obj)
		woObj = system.mes.workorder.getMESWorkOrder(woName)	
	else:
		woObj = list.get(0).getMESObject()
		
	matObj = system.mes.loadMESObject(matName, 'MaterialDef')
	woObj.setMaterialRef(matObj)	
	system.mes.saveMESObject(woObj)
		
	return system.mes.workorder.getMESWorkOrder(woName)

References

MES Work Order Object

Keywords

 

 

  • No labels