Add(Int32,Int32,String,String,String,Nullable<Int32>,Nullable<Int32>,Double,Nullable<Double>,Nullable<Int32>,DateTime,Nullable<DateTime>,Nullable<DateTime>,String,String,Nullable<Int32>,String,String,String,String,String,String,DateTime,Int32) Method
- Last UpdatedNov 06, 2025
- 7 minute read
Note: This method is deprecated and will be removed in a future release. Use the StorageExec.AddInv() method instead.
The Add() method adds a new item inventory record to the Item_Inv table.
For this overload of the method, the inventory record date input parameters are passed in UTC.
'Declaration
<ObsoleteAttribute("This method is deprecated and will be removed in the future release. Please use StorageExec.AddInv", False)>
Public Overloads Shared Sub Add( _
ByVal sessionId As Integer, _
ByVal entId As Integer, _
ByVal itemId As String, _
ByVal lotNo As String, _
ByVal subLotNo As String, _
ByVal gradeCd As Nullable(Of Integer), _
ByVal statusCd As Nullable(Of Integer), _
ByVal qtyLeft As Double, _
ByVal qtyLeftErp As Nullable(Of Double), _
ByVal uomId As Nullable(Of Integer), _
ByVal dateInUtc As Date, _
ByVal dateOutUtc As Nullable(Of Date), _
ByVal expiryDateUtc As Nullable(Of Date), _
ByVal woId As String, _
ByVal operId As String, _
ByVal seqNo As Nullable(Of Integer), _
ByVal spare1 As String, _
ByVal spare2 As String, _
ByVal spare3 As String, _
ByVal spare4 As String, _
ByVal spare5 As String, _
ByVal spare6 As String, _
ByRef lastEditAt As Date, _
ByRef rowId As Integer _
)
'Usage
Dim sessionId As Integer
Dim entId As Integer
Dim itemId As String
Dim lotNo As String
Dim subLotNo As String
Dim gradeCd As Nullable(Of Integer)
Dim statusCd As Nullable(Of Integer)
Dim qtyLeft As Double
Dim qtyLeftErp As Nullable(Of Double)
Dim uomId As Nullable(Of Integer)
Dim dateInUtc As Date
Dim dateOutUtc As Nullable(Of Date)
Dim expiryDateUtc As Nullable(Of Date)
Dim woId As String
Dim operId As String
Dim seqNo As Nullable(Of Integer)
Dim spare1 As String
Dim spare2 As String
Dim spare3 As String
Dim spare4 As String
Dim spare5 As String
Dim spare6 As String
Dim lastEditAt As Date
Dim rowId As Integer
ItemInv.Add(sessionId, entId, itemId, lotNo, subLotNo, gradeCd, statusCd, qtyLeft, qtyLeftErp, uomId, dateInUtc, dateOutUtc, expiryDateUtc, woId, operId, seqNo, spare1, spare2, spare3, spare4, spare5, spare6, lastEditAt, rowId)
[Obsolete("This method is deprecated and will be removed in the future release. Please use StorageExec.AddInv", false)]
public static void Add(
int sessionId,
int entId,
string itemId,
string lotNo,
string subLotNo,
Nullable<int> gradeCd,
Nullable<int> statusCd,
double qtyLeft,
Nullable<double> qtyLeftErp,
Nullable<int> uomId,
DateTime dateInUtc,
Nullable<DateTime> dateOutUtc,
Nullable<DateTime> expiryDateUtc,
string woId,
string operId,
Nullable<int> seqNo,
string spare1,
string spare2,
string spare3,
string spare4,
string spare5,
string spare6,
out DateTime lastEditAt,
out int rowId
)
Parameters
- sessionId
Required. Holds the session ID and thus the user who is making this method call.
- entId
- Required. Holds the ID of the entity.
- itemId
- Required. Holds the ID of the item.
- lotNo
Optional. Holds the lot number of the item.
- subLotNo
Optional. Holds the sublot number of the item.
- gradeCd
Optional. Holds the grade code of the item. Set to null if it should default to the grade code of the lot or sublot that is associated with the inventory.
Required only if no lot or sublot number is associated with the inventory or if the supplied lot or sublot number is invalid (that is, the supplied lot or sublot does not exist in the Lot or Sublot table). If a valid lot or sublot number is supplied and a grade code is also supplied here, this grade code will be used instead of the one from the lot or sublot.
- statusCd
Optional. Holds the status code of the item. Set to null if it should default to the status code of the lot or sublot that is associated with the inventory.
Required only if no lot or sublot number is associated with the inventory or if the supplied lot or sublot number is invalid (that is, the supplied lot or sublot does not exist in the Lot or Sublot table). If a valid lot or sublot number is supplied and a status code is also supplied here, this status code will be used instead of the one from the lot or sublot.
- qtyLeft
- Required. Holds the quantity remaining in the storage entity.
- qtyLeftErp
- Optional. Holds the quantity remaining in the storage entity as last transmitted to an ERP system. The default is 0.
- uomId
Optional. Holds the ID of the unit of measure that is used for the item in the inventory record if the inventory UOM is different than its native UOM. If null, then the UOM in the inventory record is the item's native UOM.
- dateInUtc
Required. Holds the date and time when the items are last received to this lot or location in UTC.
- dateOutUtc
Optional. Holds the date and time when the items are last sent from this lot or location in UTC.
- expiryDateUtc
Optional. Holds the item's expiry date and time in UTC.
- woId
Optional. Holds the ID of the work order for the last job that produced these goods.
- operId
Optional. Holds the ID of the operation for the last job that produced these goods.
- seqNo
Optional. Holds the operation sequence number for the last job that produced these goods.
- spare1
Optional. Holds the contents of the user-defined spare1 field.
- spare2
Optional. Holds the contents of the user-defined spare2 field.
- spare3
Optional. Holds the contents of the user-defined spare3 field.
- spare4
Optional. Holds the contents of the user-defined spare4 field.
- spare5
Optional. Holds the contents of the user-defined spare5 field.
- spare6
Optional. Holds the contents of the user-defined spare6 field.
- lastEditAt
Output. Holds the returned date/time when this record was added. The lastEditAt parameter is used by other methods that modify or delete this type of record for optimistic concurrency control.
- rowId
Output. Holds the returned unique row ID of the record that was added.
Observe the following input parameter rules:
- Required non-DB* parameters: Must pass a value. Cannot be empty or null.
- Optional non-DB* parameters: Either enter a value or pass a null. If passing a null and a default value has been defined, the default value will be used for the parameter.
- Required DB* parameters: Must pass a value. To enter an empty value for the parameter, pass DB*.null (e.g., DBInt.null).
- Optional DB* parameters: To enter no value for the parameter, pass DB*.null (e.g., DBInt.null). To use the default value for the parameter if one has been defined for the object being added, pass a null.
The ent_name, site_name, item_id, lot_no and sublot_no columns uniquely identify 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_name, site_name, 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 supplied quantities are added to the existing inventory. Otherwise, a new inventory (row) is created. While updating the quantities in the existing row, the grade code, status code, quantity erp, wo_id, oper_id, and seq_no from the existing row are used, unless a non-null value is supplied. The supplied grade code and status code for this item is verified against the existing row (if any) only when 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 true 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 this storage entity is greater than 0, then the storage status for this entity is set to USED. If the sum of all quantities for this storage location is 0 or less, 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 this item to the inventory. Additionally, if the Log Inventory Transfer flag is set to true, then a row is created in the Item_Transfer table identifying this inventory transaction.
For this method to succeed, all of the following conditions must be true:
- 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 turned on).
- A unique storage location can be identified; i.e., ent_name, site_name, item_id, lot_no, sublot_no should be unique if this item.inv_unique_by_job is set to false, otherwise ent_name, site_name, item_id, lot_no, sublot_no, wo_id, oper_id and seq_no should be unique. If more than one storage location (see condition above) is identified, then an exception is thrown back to the caller.
- The supplied item grade or item status exists in the database (this condition is checked only if CheckGradeStatus is set to true).
- The supplied grade code or the status code matches those of the grade and status for the identified inventory row in the database.
- 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.
- Adding the supplied quantity to the existing quantities does not result in negative quantities in the inventory if the storage exec property for this entity does not allow negative quantities to be stored in the inventory.
- The entity is not currently in the dirty state.
- If the storage location is configured/does not support multiple items being added to the inventory, then the item being added to the inventory is not 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 is not a new lot to this storage location.