TransferAndUpdateInv(Int32,String,Int32,String,DBDateTime,Double,Int32,Nullable<Int32>,DBString,DBString,DBString,DBString,DBString,Nullable<Int32>,Nullable<Int32>,Nullable<Int32>,Nullable<Int32>,Nullable<Double>,DBString,Nullable<Int32>,DBString,DBString,Nullable<Int32>,DBString,DBString,Nullable<Int32>,Nullable<Int32>,Int32) Method
- Last UpdatedNov 06, 2025
- 10 minute read
The TransferAndUpdateInv() 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:
- Includes the userId input parameter
- Identifies the entities by their entity IDs
- Identifies the item grades and statuses by their codes
- Uses UTC for the inventory expiry date and time (toExpiryDateUtc parameter)
- Identifies the UOM of the inventory at its destination by its ID (toUom parameter)
- Includes the bulkMoveReclassify input parameter
'Declaration
Public Overloads Shared Sub TransferAndUpdateInv( _
ByVal sessionId As Integer, _
ByVal userId As String, _
ByVal fromEntId As Integer, _
ByVal itemId As String, _
ByVal toExpiryDateUtc As DBDateTime, _
ByVal transferQty As Double, _
ByVal transferOption As Integer, _
ByVal toEntId As Nullable(Of Integer), _
ByVal toItemId As DBString, _
ByVal lotNo As DBString, _
ByVal toLotNo As DBString, _
ByVal subLotNo As DBString, _
ByVal toSubLotNo As DBString, _
ByVal fromGradeCd As Nullable(Of Integer), _
ByVal toGradeCd As Nullable(Of Integer), _
ByVal fromStatusCd As Nullable(Of Integer), _
ByVal toStatusCd As Nullable(Of Integer), _
ByVal transferQtyErp As Nullable(Of Double), _
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 toUOM As Nullable(Of Integer), _
ByVal bulkMoveReclassify As Integer _
)
'Usage
Dim sessionId As Integer
Dim userId As String
Dim fromEntId As Integer
Dim itemId As String
Dim toExpiryDateUtc As DBDateTime
Dim transferQty As Double
Dim transferOption As Integer
Dim toEntId As Nullable(Of Integer)
Dim toItemId As DBString
Dim lotNo As DBString
Dim toLotNo As DBString
Dim subLotNo As DBString
Dim toSubLotNo As DBString
Dim fromGradeCd As Nullable(Of Integer)
Dim toGradeCd As Nullable(Of Integer)
Dim fromStatusCd As Nullable(Of Integer)
Dim toStatusCd As Nullable(Of Integer)
Dim transferQtyErp As Nullable(Of Double)
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 toUOM As Nullable(Of Integer)
Dim bulkMoveReclassify As Integer
StorageExec.TransferAndUpdateInv(sessionId, userId, fromEntId, itemId, toExpiryDateUtc, transferQty, transferOption, toEntId, toItemId, lotNo, toLotNo, subLotNo, toSubLotNo, fromGradeCd, toGradeCd, fromStatusCd, toStatusCd, transferQtyErp, transferComments, logTransfer, fromWoId, fromOperId, fromSeqNo, toWoId, toOperId, toSeqNo, toUOM, bulkMoveReclassify)
public static void TransferAndUpdateInv(
int sessionId,
string userId,
int fromEntId,
string itemId,
DBDateTime toExpiryDateUtc,
double transferQty,
int transferOption,
Nullable<int> toEntId,
DBString toItemId,
DBString lotNo,
DBString toLotNo,
DBString subLotNo,
DBString toSubLotNo,
Nullable<int> fromGradeCd,
Nullable<int> toGradeCd,
Nullable<int> fromStatusCd,
Nullable<int> toStatusCd,
Nullable<double> transferQtyErp,
DBString transferComments,
Nullable<int> logTransfer,
DBString fromWoId,
DBString fromOperId,
Nullable<int> fromSeqNo,
DBString toWoId,
DBString toOperId,
Nullable<int> toSeqNo,
Nullable<int> toUOM,
int bulkMoveReclassify
)
Parameters
- sessionId
- Required. Holds the session ID and thus the user who is making this method call.
- userId
- Required. Holds a user ID.
- fromEntId
- Required. Holds the ID of the storage entity from which the inventory quantity is being transferred.
- itemId
- Required. Holds the ID of the item that is being transferred.
- toExpiryDateUtc
- Optional. Holds the expiry date and time in UTC of the inventory at the destination storage entity.
- transferQty
- Required. Holds the item quantity to be transferred.
- 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.
- toEntId
- Optional. Holds the ID of the storage entity to which the inventory quantity is being transferred.
- toItemId
- Optional. Holds the ID of the item when it will be stored in the destination location.
- lotNo
- 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.
- subLotNo
- 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.
- fromGradeCd
- Optional. Holds the grade code of the item that is being transferred.
- toGradeCd
- Optional. Holds the grade code of the item when it will be stored in the destination location.
- fromStatusCd
- Optional. Holds the status code of the item that is being transferred.
- toStatusCd
- Optional. Holds the status code of the item when it will be stored in the destination location.
- transferQtyErp
- Optional. Holds the transferred quantity that has already been reported to the ERP system.
- 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.
- toUOM
- Optional. Holds the ID of the unit of measure of the inventory at its destination storage entity.
- bulkMoveReclassify
- Set to 1 if affecting every lot at that location, 0 otherwise.
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.
Setting bulkMoveReclassify to true will allow multiple entries to be affected by the transfer and update. Only the from information that is supplied will be used to identify the entries that are affected.