Skip to main content

system.mes.inventory.scrapAll

Scraps all inventory of a specific material at a location from the MES based on the provided parameters. If no material is specified, it will scrap all inventory at the location.

Syntax

system.mes.inventory.scrapAll(**scrap_all_request)

Parameters

ParameterTypeNullableDescription
typeStringTrueThe type of request defined by the LotRecordType Enum. It is internally set to SCRAP and must not be modified.
sourceLocationIdOrPathStringFalseThe ID or path of the location from which inventory will be scrapped. Required.
materialIdOrPathStringTrueThe ID or path of the material being scrapped. Optional - if omitted, all materials at the location will be scrapped.
operationIdString (ULID)TrueThe ID of the operation scrapping this inventory.
inventoryOperationIdString (ULID)TrueThe ID of the inventory operation related to this scrap action.
productionOrderIdOrNameStringTrueThe ID or name of the production order associated with the scrap.
materialReasonCodeIdString (ULID)TrueThe ID of the material reason code to add additional context.
startDateInstantFalseThe start date and time of the scrap. Default value is Current Instant.
endDateInstantTrueThe end date and time of the scrap.
notesStringTrueNotes related to the scrap all request.
spare1StringTrueAdditional field for user-defined context.
spare2StringTrueAdditional field for user-defined context.
spare3StringTrueAdditional field for user-defined context.

Returns

Returns a list of JSON representation of each inventory lot records created for this scrap all action.

NameTypeDescription
lotRecordTypeStringThe type of change for the record.
inventoryLotIdString (ULID)The ULID of the primary inventory lot for the inventory lot record.
inventoryLotNameStringThe name of the primary inventory lot for the inventory lot record.
secondaryInventoryLotIdString (ULID)The ULID of the secondary inventory lot for the inventory lot record.
secondaryInventoryLotNameStringThe name of the secondary inventory lot for the inventory lot record.
operationRecordIdString (ULID)The ULID of the operation record for the inventory lot record.
inventoryOperationIdString (ULID)The ULID of the inventory operation for the inventory lot record.
productionOrderIdString (ULID)The ULID of the production order for the inventory lot record.
materialReasonCodeIdString (ULID)The ULID of the material reason code for the inventory lot record.
sourceLocationIdString (ULID)The source location of the inventory or lot being operated.
destinationLocationIdString (ULID)The destination location of the inventory or lot being operated.
lotStatusStringThe status of the inventory lot.
quantityDoubleThe quantity of units being changed depending on the lotRecordType.
startDateInstantThe beginning timestamp of the inventory lot change.
endDateInstantThe end timestamp of the inventory lot change.
statusStringThe status of the inventory lot record (e.g. Running, Completed, Faulted).
idString (ULID)The ULID of the inventory lot record (optional, used for updating an existing inventory lot record).
notesStringNotes related to the inventory lot.
enabledBooleanIndicates if the inventory lot is active and enabled.
spare1StringAdditional field for user-defined context.
spare2StringAdditional field for user-defined context.
spare3StringAdditional field for user-defined context.

Code Examples

# Generate the object structure for a new scrap all request
new_request = system.mes.inventory.newScrapAllRequest()

# Set basic attributes for the new scrap all request
new_request['materialIdOrPath'] = 'Bottle/Milk'
new_request['sourceLocationIdOrPath'] = 'DairyCo'

# Scrap all inventory at the specified location that matches the material (if specified)
scrapped_records = system.mes.inventory.scrapAll(**new_request)

# Output the JSON representation of the scrapped records
print(scrapped_records)