TransferAndUpdateInvAsync(Int32,String,DBString,String,DBString,String,DBString,DBString,DBString,DBString,DBString,DBString,DBString,DBString,DBString,Double,Nullable<Double>,Nullable<Int32>,DBString,Nullable<Int32>,DBString,DBString,Nullable<Int32>,DBString,DBString,Nullable<Int32>,DBDateTime,Nullable<Int32>,Nullable<DateTime>) Method
- Last UpdatedNov 06, 2025
- 10 minute read
The TransferAndUpdateInvAsync() method transfers a specified quantity of an item between two storage locations, with the option of updating the grade code, status code, and expiry date of the transferred item should it conflict with these same dependent fields in the source item. This method also allows the item ID and lot number to be changed during the transfer.
This overload of the method identifies the unit of measure of the transferred inventory by its ID (toUom parameter) and includes the eventTime parameter (which is currently not used).
Note: It is recommended that the MoveInventory() method be used instead of the TransferAndUpdateInvAsync() method.
'Declaration
Public Overloads Shared Sub TransferAndUpdateInvAsync( _
ByVal sessionId As Integer, _
ByVal fromEntName As String, _
ByVal fromSiteName As DBString, _
ByVal toEntName As String, _
ByVal toSiteName As DBString, _
ByVal fromItemId As String, _
ByVal toItemId As DBString, _
ByVal fromLotNo As DBString, _
ByVal toLotNo As DBString, _
ByVal fromSubLotNo As DBString, _
ByVal toSubLotNo As DBString, _
ByVal fromGradeDesc As DBString, _
ByVal toGradeDesc As DBString, _
ByVal fromStatusDesc As DBString, _
ByVal toStatusDesc As DBString, _
ByVal transferQty As Double, _
ByVal transferQtyErp As Nullable(Of Double), _
ByVal transferOption As Nullable(Of Integer), _
ByVal transferComments As DBString, _
ByVal logTransfer As Nullable(Of Integer), _
ByVal fromWoId As DBString, _
ByVal fromOperId As DBString, _
ByVal fromSeqNo As Nullable(Of Integer), _
ByVal toWoId As DBString, _
ByVal toOperId As DBString, _
ByVal toSeqNo As Nullable(Of Integer), _
ByVal toExpiryDate As DBDateTime, _
ByVal toUom As Nullable(Of Integer), _
ByVal eventTime As Nullable(Of Date) _
)
'Usage
Dim sessionId As Integer
Dim fromEntName As String
Dim fromSiteName As DBString
Dim toEntName As String
Dim toSiteName As DBString
Dim fromItemId As String
Dim toItemId As DBString
Dim fromLotNo As DBString
Dim toLotNo As DBString
Dim fromSubLotNo As DBString
Dim toSubLotNo As DBString
Dim fromGradeDesc As DBString
Dim toGradeDesc As DBString
Dim fromStatusDesc As DBString
Dim toStatusDesc As DBString
Dim transferQty As Double
Dim transferQtyErp As Nullable(Of Double)
Dim transferOption As Nullable(Of Integer)
Dim transferComments As DBString
Dim logTransfer As Nullable(Of Integer)
Dim fromWoId As DBString
Dim fromOperId As DBString
Dim fromSeqNo As Nullable(Of Integer)
Dim toWoId As DBString
Dim toOperId As DBString
Dim toSeqNo As Nullable(Of Integer)
Dim toExpiryDate As DBDateTime
Dim toUom As Nullable(Of Integer)
Dim eventTime As Nullable(Of Date)
StorageExec.TransferAndUpdateInvAsync(sessionId, fromEntName, fromSiteName, toEntName, toSiteName, fromItemId, toItemId, fromLotNo, toLotNo, fromSubLotNo, toSubLotNo, fromGradeDesc, toGradeDesc, fromStatusDesc, toStatusDesc, transferQty, transferQtyErp, transferOption, transferComments, logTransfer, fromWoId, fromOperId, fromSeqNo, toWoId, toOperId, toSeqNo, toExpiryDate, toUom, eventTime)
public static void TransferAndUpdateInvAsync(
int sessionId,
string fromEntName,
DBString fromSiteName,
string toEntName,
DBString toSiteName,
string fromItemId,
DBString toItemId,
DBString fromLotNo,
DBString toLotNo,
DBString fromSubLotNo,
DBString toSubLotNo,
DBString fromGradeDesc,
DBString toGradeDesc,
DBString fromStatusDesc,
DBString toStatusDesc,
double transferQty,
Nullable<double> transferQtyErp,
Nullable<int> transferOption,
DBString transferComments,
Nullable<int> logTransfer,
DBString fromWoId,
DBString fromOperId,
Nullable<int> fromSeqNo,
DBString toWoId,
DBString toOperId,
Nullable<int> toSeqNo,
DBDateTime toExpiryDate,
Nullable<int> toUom,
Nullable<DateTime> eventTime
)
Parameters
- sessionId
- Required. Holds the session ID and thus the user who is making this method call.
- fromEntName
- Required. Holds the name of the storage entity from which the inventory quantity is being transferred.
- fromSiteName
- Optional. Holds the site name of the storage entity from which the inventory quantity is being transferred.
- toEntName
- Required. Holds the name of the storage entity to which the inventory quantity is being transferred.
- toSiteName
- Optional. Holds the site name of the storage entity to which the inventory quantity is being transferred.
- fromItemId
- Required. Holds the ID of the item that is being transferred.
- toItemId
- Optional. Holds the ID of the item when it will be stored in the destination location.
- fromLotNo
- Optional. Holds the lot number of the item that is being transferred.
- toLotNo
- Optional. Holds the lot number of the item when it will be stored in the destination location.
- fromSubLotNo
- Optional. Holds the sublot number of the item that is being transferred.
- toSubLotNo
- Optional. Holds the sublot number of the item when it will be stored in the destination location.
- fromGradeDesc
- Optional. Holds the grade description of the item that is being transferred.
- toGradeDesc
- Optional. Holds the grade description of the item when it will be stored in the destination location.
- fromStatusDesc
- Optional. Holds the grade description of the item that is being transferred.
- toStatusDesc
- Optional. Holds the status description of the item when it will be stored in the destination location.
- transferQty
- Required. Holds the item quantity to be transferred.
- transferQtyErp
- Optional. Holds the transferred quantity that has already been reported to the ERP system.
- transferOption
- Required. Holds an integer that specifies the options should the grade code, status code, and expiry date dependent fields of the source and possible destination row not match. For more information on the transfer options, refer to the Remarks.
- transferComments
- Optional. Holds comments about the item quantity transfer that is being made.
- logTransfer
- Optional. Holds an integer value to identify the log transfer.
- fromWoId
- Optional. Holds the work order of the job transferring inventory from.
- fromOperId
- Optional. Holds the operation id of the job transferring inventory from.
- fromSeqNo
- Optional. Holds the sequence number of the job transferring inventory from.
- toWoId
- Optional. Holds the work order of the job transferring inventory to.
- toOperId
- Optional. Holds the operation id of the job transferring inventory to.
- toSeqNo
- Optional. Holds the sequence number of the job transferring inventory to.
- toExpiryDate
- Optional. Holds the expiry date and time of the inventory in the local time of the destination storage entity.
- toUom
- Optional. Holds the ID of the unit of measure of the transferred items.
- eventTime
Optional. Holds the event time.
Note: This parameter is not currently used.
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.
This method transfers the quantity from the source inventory location to a destination inventory location. All inventory transactions are automatically logged to the Item_Transfer table to track inventory movements.
If the destination entity, item, lot, sublot, work order, operation, or job sequence number is not supplied, then the value is defaulted from the source inventory location. If the item grade, status, or expiry date and time is not supplied, then the value from the existing destination row (if any) is used.
If the destination item is configured to identify the inventory quantities uniquely by job (item.inv_unique_by_job = true) and the Supplied Move Inventory To Downstream Job flag (move_inv_to_dwnstrm_job XML tag) is set to true, and the override serialization flag for this work order is set to false, then the inventory table identifying which job produced this serial number will be updated to match those of any job immediately preceding the first job identified by the work order and operation that produces the item being transferred. If there are no such upstream job(s), then these fields are left unchanged.
The ent_id, item_id, lot_no, and sublot_no column 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_id, item_id, lot_no, sublot_no, wo_id, oper_id, and seq_no columns.
If a destination inventory location could not be identified, then a new inventory location is created. If item grade, status, expiry, work order, operation, and job sequence number are supplied, then those values are used while creating a destination inventory location. Otherwise these values are defaulted from the source inventory location. If the supplied lot or a sublot does not exist for the destination item, then the lot and sublot are automatically created for the destination item while adding the item to the inventory. Finally, a destination inventory location is created based on the supplied values and the default values specified on the previous step. Subsequently, the quantities (item_inv.qty_left, .qty_left_erp) from the source inventory location are reduced, and the date out is set to the current date and time, indicating that some quantity(s) of this tem was removed at this time.
If the supplied source inventory location and the destination inventory location are same, then the inventory location is updated with the supplied item grade, status, expiry date, work order, operation, and job sequence number.
If the supplied source inventory location differs from the destination inventory location, and the item grade, status code, and expiry date from the source inventory location do not match those of the destination inventory location, then the caller must supply one of the transfer options (defaults to 2 when a null value is supplied) specified below to perform an inventory transfer. Otherwise, the method fails.
- Transfer Option 1: The grade code, status code, and the expiry date from the source inventory location match those in the destination inventory location. If they match, then this option is selected by default regardless of the transfer option supplied by the client. Otherwise, the method fails if this transfer option is selected. The supplied quantities are added to the destination inventory location, and the work order, operation, and job sequence number are updated to the destination inventory location. Subsequently, the supplied quantities are reduced from the source inventory location, and the date out is set to the current date and time, indicating that some quantities are removed at this time.
- Transfer Option 2: Either the grade code, status code, or the expiry date from the source inventory location do not match those in the destination inventory location. The supplied quantities are added to the destination inventory location. If a non-null value for the grade, status, expiry date, work order, operation, and job sequence number are supplied, then those values are updated against the destination inventory location. Otherwise the existing values in the destination location are retained. Subsequently, the supplied quantities are reduced from the source inventory location, and the date out is set to the current date and time, indicating that some quantities are removed at this time.
- Transfer Option 3: Either the grade code, status code, or the expiry date from the source inventory location do not match those in the destination inventory location. The supplied quantities are added to the destination inventory location, and the grade, status and expiry date in the destination location are overwritten with the values from the source location. Subsequently, the supplied quantities are reduced from the source inventory location, and the date out is set to the current date and time, indicating that some quantities are removed at this time.
If a destination inventory location already exists with a unit of measurement (UOM) other than the supplied UOM (if the UOM for the destination item is not explicitly supplied, then the item’s UOM is inferred), then the supplied units are converted to the destination units based on the conversion factor specified in the Uom_Conv table.
Regardless of the source/destination inventory locations, if the quantity in the storage location results in zero quantity, and if the Auto Delete Zero Inventory flag is turned on for that storage entity (storage_exec.auto_del_zero_inv), then the 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 LogInventoryTransfer flag is set to true, then a row is created in the Item_Transfer table identifying this inventory transaction.
Finally, a genealogy is logged for this inventory transfer. A lot split type of genealogy is logged when this inventory transfer results in a single lot. Otherwise, a lot combine type of genealogy is logged for this inventory transfer. While logging the genealogy (item_cons), the current shift time for the source entity, item reason code derived from the grade code of the source item are used. Not a sentence
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: source inventory row id, source entity, source item, quantity, storage property for the source entity (Storage_Exec), destination entity, destination item, storage property for the destination 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 destination item grade or destination item status exists in the database.
- The source grade code, status, and expiry do match those of the destination grade, status or expiry for the destination inventory row in the database, and the supplied transfer option is 2 or 3.
- 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, adding the supplied quantity to the existing quantities does not result in negative quantities.
- 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 not to/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.
- If the inventory exists for an item in units other than the supplied units for an item, a conversion factor to convert the source units for the item to a destination units exists in the database.