V3_ItemInventory_ScrapWithStorageExec (Put)
- Last UpdatedNov 06, 2025
- 4 minute read
| Put | V3_ItemInventory_ScrapWithStorageExec |
Resource Path:/api/v3/ItemInventory/Scrap
| Name | Description |
|---|---|
| trans_id | Used to supply the ID of the transaction if the call is taking part in a transaction. |
The request body is of type Mes.WebApi.Models.V3.EnProd.ScrapInventory2.
The following ScrapInventory2 model properties are required, unless you want to scrap all inventory. In that case, set the item_id property to null.
- To identify the entity from which the scrapped inventory quantity is being consumed: ent_id.
- To identify the item whose inventory is being scrapped: item_id. If null is passed, all inventory is scrapped.
- To specify the inventory quantity being scrapped: qty_to_scrap. If a quantity is not provided, it defaults to 0 (e.g., can be null if item_id is null to scrap all inventory).
- To specify the grade code of the scrapped items: grade_cd. Can be null if item_id is null to scrap all inventory.
- To specify the status code of the scrapped items: status_cd. Can be null if item_id is null to scrap all inventory.
This operation calls the StorageExec.Scrap stored procedure.
The stored procedure first attempts to find an inventory record of the specified entity that also matches the following optional input parameters that act as a filter: item_id, lot_no, sublot_no, wo_id, oper_id, seq_no. If such an inventory record exists, then its quantity left value is reduced by the scrapped quantity. If that inventory record's entire quantity is scrapped and there is still remaining quantity to be scrapped, then it is scrapped from the next matching inventory record, and so on.
When updating the inventory records, the qty_left, qty_left_erp, date_out_utc, and date_out_local columns are updated. The values in the remaining columns are retained as they are.
If Inventory Quantity Left Will Be 0 or Negative
If the inventory quantity will be reduced to 0 or less:
- If the storage entity allows the inventory records to be deleted when the quantity reaches 0 (storage_exec.auto_del_zero_inv), then the inventory row is deleted.
- If the storage entity does not allow inventory records to be deleted when the quantity reaches 0 and negative quantities are allowed (storage_exec.allow_neg_qty), the inventory record's quantity will be the resulting negative value.
- If the storage entity does not allow inventory records to be deleted when the quantity reaches 0 and negative quantities are not allowed, then an exception is thrown to the caller.
How Inventory Quantity Left Affects Entity Storage Status
If after scrapping the specified quantity the sum of all inventory record quantities left for the storage entity will be greater than 0, then the storage status for the entity will be set to Used.
If the sum of all quantities left for the storage location will be 0 or less, then:
- If the storage entity is configured to allow the Dirty state, then the storage status for this entity will be set to Dirty.
- If the storage entity does not allow the Dirty state, then the storage status for this entity will be set to Available.
How Scrapped Inventory Unit of Measure Is Handled
If a unit of measure is supplied in the call, then the quantity to be scrapped has a specific unit of measure.
- If the inventory record includes a specific unit of measure and it is different than the one supplied in the Scrap call, then the quantity to be scrapped is converted to the inventory record's unit of measure. For example, say the inventory record's unit of measure is gallons and the unit of measure passed by the Scrap call is liters. If the quantity to be scrapped is 3.78 liters, this is converted to a scrapped quantity of 1 gallon. If the current quantity is 25 gallons, the quantity left in the inventory record after the Scrap call will be 24. The corresponding record in the Item_Transfer table will have a quantity of -1 transferred. If a conversion between liters to gallons does not exist, an exception is thrown.
- If the inventory record does not include a unit of measure, then the supplied quantity in the Scrap call is converted to the item's native unit of measure if their units of measure don't match.
- If the Scrap call does not include a specific unit of measure and the inventory record does, then the quantity to be scrapped is assumed to be in the unit of measure specified in the inventory record. Otherwise, it's assumed to be in the item's native unit of measure.
Logging the Scrapped Inventory as an Inventory Transfer
If the Log inventory transfers system parameter is set to true:
- A record is created in the Item_Transfer table identifying the scrapped inventory as an inventory transfer transaction.
- If provided in the Scrap call, the item grade and state for the scrapped items are included in the Item_Transfer record.
- Any supplied transfer comments will be prefixed with "Scrap:", indicating that the item transfer record was created from a scrap transaction. If no transfer comments are supplied, then the transfer_comments column will simply contain the text "Scrap:".
Conditions for a Successful Scrap Inventory Call
For the Scrap inventory call to succeed, all of the following conditions must be true:
- An inventory record that matches the specified entity and any supplied filter parameters (item_id, lot_no, sublot_no, wo_id, oper_id, seq_no) exists.
- The specified entity is capable of storing inventory items (ent.can_store is turned on).
- The quantity to scrap is not less than 0.
- If the entity is not configured to support negative inventory quantities (storage_exec.allow_neg_qty), the remaining inventory quantity after being reduced by the scrapped inventory is not less than 0.
- The entity is not currently in the Dirty state.
- The specified storage entity and if a scrap unit of measure, item grade, or item status are supplied, they must already exist in the database.