AddInvAsync(Int32,String,String,String,String,String,Double,DBString,DBString,Nullable<Double>,DBDateTime,DBDateTime,DBString,DBString,DBInt,DBString,DBString,DBString,DBString,DBString,DBString,DBString,DBString,Nullable<Boolean>,Nullable<Boolean>,Nullable<Int32>,DBString) Method
- Last UpdatedNov 06, 2025
- 7 minute read
The AddInvAsync() method adds a quantity of an item to a storage location.
This overload of the method specifies entities using entity names and site names, and specifies the item's grade and status using descriptions.
'Declaration
Public Overloads Shared Sub AddInvAsync( _
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 addQty As Double, _
ByVal lotNo As DBString, _
ByVal subLotNo As DBString, _
ByVal addQtyErp As Nullable(Of Double), _
ByVal dateIn As DBDateTime, _
ByVal expiryDate As DBDateTime, _
ByVal woId As DBString, _
ByVal operId As DBString, _
ByVal seqNo As DBInt, _
ByVal fromEntName As DBString, _
ByVal fromSiteName As DBString, _
ByVal spare1 As DBString, _
ByVal spare2 As DBString, _
ByVal spare3 As DBString, _
ByVal spare4 As DBString, _
ByVal spare5 As DBString, _
ByVal spare6 As DBString, _
ByVal goodsReceived As Nullable(Of Boolean), _
ByVal checkGradeStatus As Nullable(Of Boolean), _
ByVal logTransfer As Nullable(Of Integer), _
ByVal transferComments As DBString _
)
'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 addQty As Double
Dim lotNo As DBString
Dim subLotNo As DBString
Dim addQtyErp As Nullable(Of Double)
Dim dateIn As DBDateTime
Dim expiryDate As DBDateTime
Dim woId As DBString
Dim operId As DBString
Dim seqNo As DBInt
Dim fromEntName As DBString
Dim fromSiteName As DBString
Dim spare1 As DBString
Dim spare2 As DBString
Dim spare3 As DBString
Dim spare4 As DBString
Dim spare5 As DBString
Dim spare6 As DBString
Dim goodsReceived As Nullable(Of Boolean)
Dim checkGradeStatus As Nullable(Of Boolean)
Dim logTransfer As Nullable(Of Integer)
Dim transferComments As DBString
StorageExec.AddInvAsync(sessionId, entName, siteName, itemId, itemGradeDesc, itemStatusDesc, addQty, lotNo, subLotNo, addQtyErp, dateIn, expiryDate, woId, operId, seqNo, fromEntName, fromSiteName, spare1, spare2, spare3, spare4, spare5, spare6, goodsReceived, checkGradeStatus, logTransfer, transferComments)
public static void AddInvAsync(
int sessionId,
string entName,
string siteName,
string itemId,
string itemGradeDesc,
string itemStatusDesc,
double addQty,
DBString lotNo,
DBString subLotNo,
Nullable<double> addQtyErp,
DBDateTime dateIn,
DBDateTime expiryDate,
DBString woId,
DBString operId,
DBInt seqNo,
DBString fromEntName,
DBString fromSiteName,
DBString spare1,
DBString spare2,
DBString spare3,
DBString spare4,
DBString spare5,
DBString spare6,
Nullable<bool> goodsReceived,
Nullable<bool> checkGradeStatus,
Nullable<int> logTransfer,
DBString transferComments
)
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 where the quantity is being added to the inventory.
- siteName
- Optional. Holds the site name for this entity.
- itemId
- Required. Holds the ID of the item.
- itemGradeDesc
Optional. Holds the description of 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 description is also supplied here, this grade code will be used instead of the one from the lot or sublot.
- itemStatusDesc
Optional. Holds the description of 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 description is also supplied here, this status code will be used instead of the one from the lot or sublot.
- addQty
- Required. Holds the quantity to be added for this item in the inventory.
- lotNo
- Optional. Holds the lot number.
- subLotNo
- Optional. Holds the sublot number.
- addQtyErp
- Optional. Holds the amount of quantity that has already been reported to the ERP system.
- dateIn
- Optional. Holds the date and time when this quantity was received at the storage entity in the local time of that entity.
- expiryDate
- Optional. Holds the inventory's expiry date and time in the local time of the storage entity.
- woId
- Optional. Holds the ID of the work order that produced this quantity. Required only if the Inventory Unique by Job flag is set to true for this item.
- operId
- Optional. Holds the ID of the operation that produced this quantity. Required only if the Inventory Unique by Job flag is set to true for this item.
- seqNo
- Optional. Holds the operation sequence number of the job that produced this quantity. Required only if the Inventory Unique by Job flag is set to true for this item.
- fromEntName
- Optional. Holds the name of the entity from which this item is being transferred, if any.
- fromSiteName
- Optional. Holds the site name of the entity from which this item is being transferred, if any.
- spare1
- Optional. Holds the contents of the user-defined spare1 string field.
- spare2
- Optional. Holds the contents of the user-defined spare2 string field.
- spare3
- Optional. Holds the contents of the user-defined spare3 string field.
- spare4
- Optional. Holds the contents of the user-defined spare4 string field.
- spare5
- Optional. Holds the contents of the user-defined spare5 string field.
- spare6
- Optional. Holds the contents of the user-defined spare6 string field.
- goodsReceived
- Optional. Holds a flag that, if set to true, indicates that these items have been received from a supplier. Defaults to false. If supplied, this value will be logged in the Item_Transfer table.
- checkGradeStatus
Optional. Holds a flag that, if set to true, specifies that the grade and status for the supplied item ought to be verified against the existing inventory, if any.
- logTransfer
- Optional. Holds an integer value to identify the log transfer.
- transferComments
- Optional. Holds transfer comments.
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.