ReduceInv(Int32,String,String,String,String,String,Nullable<Int32>,DBDateTime,Double,DBString,DBString,Nullable<Double>,DBString,DBString,DBInt,Nullable<DateTime>,Nullable<Boolean>,Nullable<Boolean>,Nullable<Boolean>,Nullable<Boolean>,DBString,Nullable<Int32>) Method
- Last UpdatedNov 06, 2025
- 6 minute read
The ReduceInv() method reduces the inventory quantity of an item from the specified storage location.
This overload of the method:
- Identifies the storage entity by its entity and site names
- Identifies the item grade and status are identified by their descriptions
- Includes the reasCd, mustConsumeFromInv, mustConsFromWip, checkGrade, and logTransfer input parameters
- Uses UTC for when the inventory was reduced (dateOutUtc parameter)
'Declaration
Public Overloads Shared Sub ReduceInv( _
ByVal sessionId As Integer, _
ByVal entName As String, _
ByVal siteName As String, _
ByVal itemId As String, _
ByVal itemGradeDesc As String, _
ByVal itemStatusDesc As String, _
ByVal reasCd As Nullable(Of Integer), _
ByVal dateOutUtc As DBDateTime, _
ByVal reduceQty As Double, _
ByVal lotNo As DBString, _
ByVal subLotNo As DBString, _
ByVal reduceQtyErp As Nullable(Of Double), _
ByVal woId As DBString, _
ByVal operId As DBString, _
ByVal seqNo As DBInt, _
ByVal lastEditAt As Nullable(Of Date), _
ByVal goodsShipped As Nullable(Of Boolean), _
ByVal mustConsumeFromWip As Nullable(Of Boolean), _
ByVal mustConsumeFromInv As Nullable(Of Boolean), _
ByVal checkGrade As Nullable(Of Boolean), _
ByVal transferComments As DBString, _
ByVal logTransfer As Nullable(Of Integer) _
)
'Usage
Dim sessionId As Integer
Dim entName As String
Dim siteName As String
Dim itemId As String
Dim itemGradeDesc As String
Dim itemStatusDesc As String
Dim reasCd As Nullable(Of Integer)
Dim dateOutUtc As DBDateTime
Dim reduceQty As Double
Dim lotNo As DBString
Dim subLotNo As DBString
Dim reduceQtyErp As Nullable(Of Double)
Dim woId As DBString
Dim operId As DBString
Dim seqNo As DBInt
Dim lastEditAt As Nullable(Of Date)
Dim goodsShipped As Nullable(Of Boolean)
Dim mustConsumeFromWip As Nullable(Of Boolean)
Dim mustConsumeFromInv As Nullable(Of Boolean)
Dim checkGrade As Nullable(Of Boolean)
Dim transferComments As DBString
Dim logTransfer As Nullable(Of Integer)
StorageExec.ReduceInv(sessionId, entName, siteName, itemId, itemGradeDesc, itemStatusDesc, reasCd, dateOutUtc, reduceQty, lotNo, subLotNo, reduceQtyErp, woId, operId, seqNo, lastEditAt, goodsShipped, mustConsumeFromWip, mustConsumeFromInv, checkGrade, transferComments, logTransfer)
public static void ReduceInv(
int sessionId,
string entName,
string siteName,
string itemId,
string itemGradeDesc,
string itemStatusDesc,
Nullable<int> reasCd,
DBDateTime dateOutUtc,
double reduceQty,
DBString lotNo,
DBString subLotNo,
Nullable<double> reduceQtyErp,
DBString woId,
DBString operId,
DBInt seqNo,
Nullable<DateTime> lastEditAt,
Nullable<bool> goodsShipped,
Nullable<bool> mustConsumeFromWip,
Nullable<bool> mustConsumeFromInv,
Nullable<bool> checkGrade,
DBString transferComments,
Nullable<int> logTransfer
)
Parameters
- sessionId
- Required. Holds the session ID and thus the user who is making this method call.
- entName
- Required. Holds the name of the storage entity whose inventory quantity is being reduced.
- siteName
- Optional. Holds the site name of the storage entity whose inventory quantity is being reduced.
- itemId
- Required. Holds the ID of the item whose inventory is being reduced.
- itemGradeDesc
- Optional. Holds the description of the item grade.
- itemStatusDesc
- Optional. Holds the description of the item status.
- reasCd
- Optional. Holds the reason code if this quantity is being consumed from WIP inventory, to determine whether this quantity came from a good production or not.
- dateOutUtc
- Optional. Holds the UTC date/time when this quantity was removed from inventory at this location.
- reduceQty
- Required. Holds the quantity of inventory to be reduced.
- lotNo
- Optional. Holds the lot number.
- subLotNo
- Optional. Holds the sublot number.
- reduceQtyErp
- Optional. Holds the amount of the reduced quantity that has already been reported to the ERP system.
- woId
- Optional. Holds the ID of the work order to which the quantities are produced.
- operId
- Optional. Holds the ID of the operation to which the quantities are produced.
- seqNo
- Optional. Holds the operation sequence number to which the quantities are produced.
- lastEditAt
Required. Holds the date/time when this record was added or last edited, for optimistic concurrency control. The passed value must match the lastEditAt value in the record of the Item_Inv table for the update to succeed.
Output. Holds the date/time value when this record was updated by this called method.
- goodsShipped
- Optional. Holds a flag that, if set to true, indicates that these items have been shipped to a customer.
- mustConsumeFromWip
- Optional. Holds a flag that, if set to true, specifies that this item is consumed from WIP inventory.
- mustConsumeFromInv
- Optional. Holds a flag that, if set to true, specifies that this item is consumed from inventory.
- checkGrade
- Optional. Holds a flag that, if set to true, specifies that the supplied grade be verified against the existing item in the inventory.
- transferComments
- Optional. Holds comments about the inventory reduction that is being made.
- logTransfer
Optional. Holds an integer value to identify the log transfer.
Note: The logTransfer parameter is not used. The system parameter controls whether or not the item_transfer table is updated.
Observe the following two input parameter rules:
- Optional non-DB* parameters: Either enter a new value or leave the existing value unchanged by passing a null.
- Optional DB* parameters: To clear the existing value and enter an empty value, pass DB*.null (e.g., DBInt.null). To leave the existing value unchanged, pass a null.
The ent_id, item_id, lot_no, and sublot_no column uniquely identifies a row in the Item_Inv table as long as the inventory is not stored uniquely for this job (item.inv_unique_by_job is set to false). However, if this item is configured to differentiate inventory by job (item.inv_unique_by_job is set to true), then a unique row in the Item_Inv table is identified by ent_id, item_id, lot_no, sublot_no, wo_id, oper_id, and seq_no columns.
This method first determines whether an inventory row exists for the supplied item based on the condition specified above. If such a row is identified, then the specified quantities are reduced from the existing inventory. Otherwise a new inventory (row) is created with negative quantities if and only if this storage entity allows to store negative quantities. While creating a new inventory location with negative quantities, the grade code, status code, quantity erp, wo_id, oper_id, and seq_no from the supplied parameter are used. The supplied grade code and status code for this item is verified against the existing row (if any) only if the CheckGradeStatus flag is set to true.
If adding this quantity to an existing row results in zero quantity, and if the Auto Delete Zero Inventory flag is turned on for this storage entity (storage_exec.auto_del_zero_inv), then the existing inventory row is automatically deleted.
Additionally, if the sum of all quantities for a storage entity is greater than 0, then the storage status for that entity is set to USED. If the sum of all quantities for a storage location is less than or equal to 0, then:
- If the storage entity is configured to allow the Dirty state, then the storage status for this entity is set to DIRTY.
- If the storage entity does not allow the Dirty state, then the storage status for this entity is set to AVAILABLE.
If the supplied lot or a sublot does not exist for this item, then the lot and sublot are automatically created for this item while adding negative quantities for this item in the inventory. Additionally, if the LogInventoryTransfer flag is set to true, then a row is created in the Item_Transfer table identifying this inventory transaction.
All of the following conditions must be true for this method to succeed:
- The following supplied fields are not null or empty, and exist in the database: entity, item, quantity, storage property for this entity (Storage_Exec).
- The supplied entity is capable of storing items in the inventory (ent.can_store is true).
- A unique storage location is identified. That is, ent_id, item_id, lot_no, and sublot_no are unique if the item.inv_unique_by_job flag is set to false. Otherwise ent_id, item_id, lot_no, sublot_no, wo_id, oper_id. and seq_no are unique. Only one storage location (see condition above) is identified.
- The supplied item grade exists in the database. This condition is checked only if CheckGrade parameter is set to true.
- The supplied grade code matches those of the grade for the identified inventory row in the database. This condition is checked only if CheckGrade parameter is set to true.
- A non-null value for the item grade or status is supplied when creating a new inventory row
- Adding the supplied quantity to the existing quantities does not exceed the maximum storage capacity for this entity.
- If the storage exec property for this entity does not allow negative quantities to be stored in the inventory, then reducing the supplied quantity from the existing quantities does not result in negative quantities in the inventory.
- The entity is currently not in the dirty state.
- If the storage location is configured/does not support multiple items added to the inventory, then the item being added to the inventory does not result as a new item to this storage location.
- If the storage location is configured/does not support multiple lots added to the inventory, then the lot being added to the inventory does not result as a new lot to this storage location.