Consuming Sublots As Material Lots in a Downstream Process 2.0

Material Lots are snapshots of some identifiable quantity of a kind of material at a point in time.  Movements and transformations of materials require new snapshots, or Material Lots, to be created in order to capture the necessary information to map out the genealogy of the material in view.  Material Lots can have Sublots within them - a sublot being an identifiable member of the Material Lot.  This model is most commonly used where serial numbers are applied to individual units or pieces that are being batch processed.

A need may arise to split sublots away from the parent MES Material Lot to track individually (e.g. de-palletize, de-nest). 


Splitting sublots is done by removing the sublot via the response segment during execution.

In the below example, we are consuming a single sublot from the material lot parent and generating a new material lot (now named after the sublot) as output from the process.

Material In:


Material Out:


Sublot_Consume Script example

Code
#These items would be selected from a UI, Scanned in via Barcode/RFID, or could come from a PLC
sublot = 'AAAA'
lot = '123'
bin = 'Bin 3'
storageLocation = 'Enterprise\\Site\\Area\\Storage Zone 1\\Storage Unit 1'
materialOut = 'Final Product Z'
eqPath = 'Enterprise\\Site\\Area\\Line 1'

#https://help.sepasoft.com/docs/display/SEPA/system.mes.createSegment
seg = system.mes.createSegment('Sublot_Consume', eqPath, 0)
sublotUUIDS = []

#https://help.sepasoft.com/docs/display/SEPA/system.mes.getLotInventoryByEquipment
equipLotSummary = system.mes.getLotInventoryByEquipment(bin)

#https://help.sepasoft.com/docs/display/SEPA/MES+Lot+Quantity+Summary+List
for lotSummary in equipLotSummary:
	#Check if lot is valid inventory at selected equipment
	if lotSummary.getLotNumber() == lot:
		lotObj = lotSummary.getMaterialLot()
		sublotUUIDS = lotObj.getChildCollection()
		break

if len(sublotUUIDS) > 0:
	#https://help.sepasoft.com/docs/display/SEPA/Response+Segment
	seg.setMaterial('ParentLotIn', lot, -1, 1.0)
	#New output lot name is sublot name. I retrieved it in a different table. lotObj.getChildCollection() is how to retrieve all sublots belonging to a lot.
	seg.setMaterial('New Material Out', materialOut, storageLocation, sublot, 1.0)

	seg = seg.begin()
	
	for i in range(len(sublotUUIDS)):
		sublotName = sublotUUIDS.getList().get(i).getName()
		if sublotName == sublot:
			#Remove sublot from the input material lot
			seg.removeSublot('ParentLotIn',sublotName)
			break
	seg.end()


Note 

Each sublot removed will be removed from the segment.  The trace graph will show all links between the new output lots and original input parent lot but you may not see all sublots that were consumed in upstream views.