MoveInventory(Int32,InvTransferSource[],Int32,Boolean,Nullable<Int32>,String,String,String,Nullable<Int32>,Nullable<Int32>,Nullable<DateTime>,Nullable<Int32>,String,String,Nullable<Int32>) Method
- Last UpdatedNov 06, 2025
- 9 minute read
The MoveInventory() method transfers a specified quantity of an item from a list of source storage locations to a single destination storage location.
This overload of the method:
- Identifies the destination entity by its entity ID
- Identifies the item grade and status by their codes
- Uses the local time of the destination storage entity for the inventory expiry date and time (toExpirationDate parameter)
'Declaration
Public Overloads Shared Sub MoveInventory( _
ByVal sessionId As Integer, _
ByVal sourceList() As InvTransferSource, _
ByVal transferOption As Integer, _
ByVal moveInvToDownstreamJob As Boolean, _
ByVal toEntId As Nullable(Of Integer), _
ByVal toItemId As String, _
ByVal toLotNo As String, _
ByVal toSubLotNo As String, _
ByVal toGradeCd As Nullable(Of Integer), _
ByVal toStatusCd As Nullable(Of Integer), _
ByVal toExpirationDate As Nullable(Of Date), _
ByVal toUomId As Nullable(Of Integer), _
ByVal toWoId As String, _
ByVal toOperId As String, _
ByVal toSeqNo As Nullable(Of Integer) _
)
'Usage
Dim sessionId As Integer
Dim sourceList() As InvTransferSource
Dim transferOption As Integer
Dim moveInvToDownstreamJob As Boolean
Dim toEntId As Nullable(Of Integer)
Dim toItemId As String
Dim toLotNo As String
Dim toSubLotNo As String
Dim toGradeCd As Nullable(Of Integer)
Dim toStatusCd As Nullable(Of Integer)
Dim toExpirationDate As Nullable(Of Date)
Dim toUomId As Nullable(Of Integer)
Dim toWoId As String
Dim toOperId As String
Dim toSeqNo As Nullable(Of Integer)
StorageExec.MoveInventory(sessionId, sourceList, transferOption, moveInvToDownstreamJob, toEntId, toItemId, toLotNo, toSubLotNo, toGradeCd, toStatusCd, toExpirationDate, toUomId, toWoId, toOperId, toSeqNo)
public static void MoveInventory(
int sessionId,
InvTransferSource[] sourceList,
int transferOption,
bool moveInvToDownstreamJob,
Nullable<int> toEntId,
string toItemId,
string toLotNo,
string toSubLotNo,
Nullable<int> toGradeCd,
Nullable<int> toStatusCd,
Nullable<DateTime> toExpirationDate,
Nullable<int> toUomId,
string toWoId,
string toOperId,
Nullable<int> toSeqNo
)
Parameters
- sessionId
- Required. Holds the session ID and thus the user who is making this method call.
- sourceList
- Required. Holds an array of InvTransferSource objects, each containing the items to be transferred.
- transferOption
- Required. Holds an integer that specifies the type of transfer to be made. For more information, refer to the Remarks.
- moveInvToDownstreamJob
- Required. Holds a flag that, if set to true, specifies that inventory should be moved to the downstream job.
- toEntId
- Optional. Holds the ID of the storage entity to which the inventory will be moved.
- toItemId
- Optional. Holds the new item ID for the transferred inventory.
- toLotNo
- Optional. Holds the lot number for the transferred inventory.
- toSubLotNo
- Optional. Holds the sublot number for the transferred inventory.
- toGradeCd
- Optional. Holds an integer that specifies the grade code of the transferred items.
- toStatusCd
- Optional. Holds an integer that specifies the status code of the transferred items.
- toExpirationDate
- Optional. Holds the expiry date and time of the transferred items in the local time of the destination storage entity.
- toUomId
- Optional. Holds the ID of the unit of measure of the transferred items.
- toWoId
- Optional. Holds the ID of the work order for the transferred inventory.
- toOperId
- Optional. Holds the ID of the operation for the transferred inventory.
- toSeqNo
- Optional. Holds the operation sequence number for the transferred inventory.
Each element in the SourceList array is an instance of the InvTransferSource class. The fields in this class are shown in the following table . These fields are initialized by the class constructor. The FromRowId field is required; all others are optional (i.e., null may be passed in for these values).
|
Field Name |
Description |
|---|---|
|
FromRowId |
An integer that is a row_id value from the Item_Inv table. |
|
FromStorageEntId |
An integer that is the ID of the entity from which the inventory is to be transferred. |
|
TransferQty |
A floating point number that is the quantity to be transferred. |
|
TransferQtyErp |
A floating point number that is the transfer quantity to be reported to an external ERP system. |
|
TransferComments |
A string that contains notes pertaining to the transfer. |
|
LastEditAt |
A datetime that indicates when the inventory record was last created or modified. Used for optimistic currency control. |
For each element of the SourceList array, this method moves the quantity from the source location to the destination location. The rules specified below are applicable for each inventory transfer. Thus, each inventory move is validated against these rules. The inventory transfer is completed only when all source quantities are successfully moved to a destination location. If any error occurs, none of the quantities will be moved from any source location to a destination location, thus putting the database back to the previous state, as if nothing has happened. 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.