==== 6.9. Free stock screen ==== === Overview === In Produmex WMS, free stock is always calculated the same way: **the stock WMS has on its locations, minus the stock that is reserved by locks**. This calculation is done at four levels: item, batch, logistic unit and location. The real free quantity is the lowest of the four. Each screen that shows free stock then adds its own filters on top of this calculation. This is why the **Free stock screen**, the **Get Free Stock** button on the sales order and a custom query on the free stock view can show three different numbers for the same item. **In short:** * **The free stock view (PMX_FREE_STOCK) shows all stock.** It lists every stock row with its free quantity, and does not filter on quality status, warehouse, disallowed locations or anything else. Each screen adds its own filters. * **The free quantity of a row cannot be added up.** A reservation on an item or a batch is shown on every row it covers. When the rows are added up, the same reservation is counted several times, and the total is too high. This, and not a missing filter, is the most common reason why a free stock query gives a wrong result. * **The Get Free Stock button and the Item Master Data do not use the view.** They add up the stock and the reservations separately per SAP warehouse, and subtract one from the other. * **Picking uses its own calculation.** Pick list proposals, picking and production use the same logic as the view, but with extra rules, for example for expiry dates and customer reservations. === Definitions === ^ Term ^ Meaning ^ | Free stock | The physical stock WMS knows about, minus the stock that is reserved by a lock. | | Stock | All stock WMS has on a storage location, whatever the location type: bin locations, docks, moving locations, pick carts and lost and found. Goods that are picked but not shipped yet are still included. | | Lock | A reservation of stock. A lock can reserve an item, a batch, a logistic unit or a location. Locks are created by sales orders, pick list proposals and pick lists, 'Ready' pick lists, ad-hoc picking, production and Beas. Users can also create locks manually on the inventory report, on the stock allocation screen and with locking in advance (see [[implementation:wms:inventorylock|Inventory locking]]). | | Warehouse | The Produmex warehouse, not the SAP warehouse. One SAP warehouse can be linked to several Produmex warehouses. | | Quality status | Both stock and locks are stored per quality status. A lock on status A never reserves stock with status B. The settings of the quality status (can be shipped, can be shipped under quarantine, can be used for production) decide which stock a screen counts. | **Note:** Free stock only exists in WMS. The SAP Business One available quantity (In Stock + Ordered − Committed) is not used. **For technical users:** stock is stored in PMX_INVT (one row per item, quality status, batch, logistic unit and location), and locks in PMX_INLD (inventory locking detail). The Produmex warehouse of a location is PMX_OSEL.PmxWhsCode, and the link to the SAP warehouse is PMX_OSWH.SboWhsCode. Locks store the Produmex warehouse code directly in PMX_INLD.PmxWhsCode. Quality statuses are stored in PMX_QYST, with the settings CanBeShipped, CanBeShippedUnderQuarantine and CanBeUsedForProduction. === How free stock is calculated === Free stock is the stock that is in the warehouse and not reserved for anything else. WMS calculates it in three steps. **1. WMS takes the stock on the locations** WMS starts with all the stock it has on its locations: bin locations, docks, pick carts, moving locations and so on. Goods that are picked but not shipped yet are still counted. **2. WMS subtracts the reserved stock** Stock is reserved with a lock. A lock can be broad or narrow, depending on what it reserves: ^ A lock can reserve ^ Typical example ^ | A quantity of an item, from anywhere in the warehouse | A reservation of the item without a batch, logistic unit or location | | A quantity of a specific batch | A sales order reserves 90 pcs of batch 123 | | A quantity on a specific logistic unit | A pick list reserves logistic unit 001 | | A quantity on a specific location | A 'Ready' pick list or ad-hoc picking reserves the stock on location A-01-01 | A narrow lock also counts for everything above it. For example, a lock on a location also reduces the free stock of the logistic unit, the batch and the item on that location. A broad lock does not belong to any single logistic unit or location. For example, a sales order that reserves 90 pcs of a batch does not say which logistic units the goods will come from, so it reduces the free stock of every logistic unit of that batch. **3. WMS checks four levels and takes the lowest result** For every logistic unit on every location, WMS asks four questions: ^ Level ^ Question ^ | Item | How much of this item, with this quality status, is still free in the warehouse? | | Batch | How much of this batch is still free? | | Logistic unit | How much is still free on this logistic unit? | | Location | How much is still free on this location? | The lowest answer is the real free quantity, because users cannot take more than that without breaking a reservation. **Example** A logistic unit holds 20 pcs on location A-01-01. Nothing on the logistic unit or the location is reserved, so at logistic unit and location level 20 pcs are free. But a sales order has reserved most of the batch, and only 10 pcs of the batch are still free. The free quantity of this logistic unit is therefore **10 pcs**, the lowest of the four answers. ^ Level ^ Free quantity ^ | Item | 10 | | Batch | 10 | | Logistic unit | 20 | | Location | 20 | ^ Free quantity of the logistic unit | **10** | **For technical users:** * This calculation is done by the database view PMX_FREE_STOCK (Src/Logex/Produmex.Sbo.Logex.Data/Scripts/Views/PMX_FREE_STOCK.sql, same definition on SAP HANA with IFNULL instead of ISNULL). It returns one row for every PMX_INVT row and has no WHERE clause: it does not filter anything, each screen adds its own filters. * The lock level is stored in the InvLockLevel column of PMX_INLD: Q (item and quality status), B (batch / best before date), L (logistic unit) and D (location). * Item level: grouped by ItemCode, QualityStatusCode and PmxWhsCode, all locks are subtracted. Columns: InventoryQuantityItem, LockedQuantityItem, FreeQuantityItem. * Batch level: also grouped by ItemTransactionalInfoKey, locks B, L and D are subtracted. Columns: InventoryQuantityBatch, LockedQuantityBatch, FreeQuantityBatch. * Logistic unit level: also grouped by LogUnitIdentKey, locks L and D are subtracted. Columns: InventoryQuantityLUID, LockedQuantityLUID, FreeQuantityLUID. * Location level: also grouped by StorLocCode, only D locks are subtracted. Columns: InventoryQuantityDetail, LockedQuantityDetail, FreeQuantityDetail. * At each level: FreeQuantity = InventoryQuantity − ISNULL(LockedQuantity, 0). ActualFreeQuantity is the lowest of the four free quantities. * All columns of PMX_INVT are also returned (PMX_INVT.*), for example StorLocCode, QualityStatusCode, LogUnitIdentKey, ItemTransactionalInfoKey, Uom and QuantityUom2, so screens and queries can filter on them. == Why the free quantities of the rows cannot be added up == A reservation on an item or a batch is not linked to one logistic unit, so it is shown on every row of that item or batch. If users add up the free quantities of the rows, the same reservation is counted once for every row, and the total is too high. **Example:** Item X in warehouse 01, 100 pcs on 5 logistic units of 20 pcs. A sales order reserves 90 pcs of the batch, and the batch is on all 5 logistic units. ^ Logistic unit ^ Stock on the location ^ Free (item) ^ Free (batch) ^ Free (logistic unit) ^ Free (location) ^ Free quantity of the row ^ | LU1 | 20 | 10 | 10 | 20 | 20 | 10 | | LU2 | 20 | 10 | 10 | 20 | 20 | 10 | | LU3 | 20 | 10 | 10 | 20 | 20 | 10 | | LU4 | 20 | 10 | 10 | 20 | 20 | 10 | | LU5 | 20 | 10 | 10 | 20 | 20 | 10 | ^ Total | **100** | | | | | **50** | Only 10 pcs are really free, but the rows add up to 50 pcs. Without reservations, the total is correct, because the free quantity of each row is simply the stock on it. This is why such a total looks correct on a test item, but is wrong on live data. **Note:** The free quantity of a row only answers one question: how much can users still take from this logistic unit on this location without breaking a reservation? This is how the Free stock screen uses it. **For technical users:** ActualFreeQuantity is the lowest value of the four levels, calculated with a CASE expression. The item and batch level values are repeated on every row they cover, so SUM(ActualFreeQuantity) counts the same shortage once per row. To get a correct total for a warehouse, use MAX(FreeQuantityItem) per quality status, or subtract SUM(locks) from SUM(stock) directly on PMX_INVT and PMX_INLD. The Get Free Stock button and the Item Master Data use the second method. === Where free stock is calculated === Free stock appears in several places in WMS, and each place calculates it in its own way. The basic calculation is always the same (stock minus reservations), but each place decides which stock to count. This is why the numbers can differ. **The table below shows, for each place:** * **Screen or process:** where users see free stock. * **Result on the screen:** what users see there: a list of rows, or a single number, and what that number stands for. * **Stock and reservations included:** which stock and which reservations are counted in the calculation. ^ Screen or process ^ Result on the screen ^ Stock and reservations included ^ | **Free stock screen** \\ Opens when stock is selected for a delivery, an A/R invoice, an issue for production or another document that takes stock out | A list of logistic units and locations, with the free quantity of each | • Only stock of the item in the SAP warehouse of the document line \\ • Only quality statuses allowed for the document type \\ • Deliveries and A/R invoices: stock on disallowed locations is left out \\ • Only rows with free stock are shown \\ • Sorted by best before date, batch, pick location and logistic unit | | **Get Free Stock** button on the sales order \\ Fills the //PMX Free Stock// column of the lines | One number per sales order line | • All stock of the item in the SAP warehouse of the line, minus all reservations \\ • Quality statuses based on the //Shipping quality option// of the line \\ • Stock and reservations on disallowed locations are left out \\ • Only lines with an open quantity are updated | | **Item Master Data**, Inventory tab, //PMX Free Stock// column | One number per SAP warehouse | • Stock: only quality statuses that can be shipped \\ • Reservations: **all quality statuses** \\ • Stock and reservations on disallowed locations are left out \\ • Updated when the item is opened or 'OK' is pressed. There is no //Get Free Stock// button on this screen. | | **Picking and other WMS processes** \\ Pick list proposals, picking, packing, production, moves, stock allocation, minimum customer stock and Beas | The stock WMS will actually use | • Uses the most rules of all, for example expiry dates, customer reservations and pick locations (see Filters added by each screen below) \\ • **This calculation decides what WMS actually picks.** | == Good to know about the Free stock screen == * **The 'Quantity in stock' column shows the free quantity, not the stock.** It shows how much users can still take from that logistic unit on that location, not how much is physically there. The editable 'Quantity' column is filled with the same value. * **The rows can add up to more than users can select.** A reservation on a batch is shown on every logistic unit of that batch (see Why the free quantities of the rows cannot be added up above). When users press 'OK', WMS checks the total against the free stock of the item and the batch. If the total is too high, the message //The total entered quantity exceeds the free quantity// is displayed. * **The Free stock screen and picking can show different quantities.** The Free stock screen does not use the picking rules. For example, it can list an expired batch or stock on the lost and found location that a pick list proposal would not use. **For technical users:** * **Free stock screen:** reads the view PMX_FREE_STOCK and filters on ActualFreeQuantity > 0, the SAP warehouse (PMX_OSWH.SboWhsCode) and the quality status list. Code: PmxStockSelectionForm.ShowDataFromCurrentStockForIssue → AddOn/SboCommands.GetStockLinesForStockSelection. On 'OK', the total is checked against FreeQuantityItem per quality status and FreeQuantityBatch per batch and logistic unit. * **Get Free Stock button:** does not use the view. It runs two queries on PMX_INVT and PMX_INLD and subtracts the locks from the stock. Code: PmxSalesOrderForm.RefreshOrderMatrixPmxFreeColumn → GetQueryGetTotalQuantityByWarehouse and GetQueryGetTotalLockedQuantityByWarehouse. * **Item Master Data column:** uses the same two queries. Code: PmxItemMasterDataForm.GetTotalQtyTotalLockedQtyPerWarehouse. * **Picking and other processes:** use the GetFreeStock engine, which calculates the same values as the view on the fly from PMX_INVT and PMX_INLD (or PMX_INVENTORY_LOCKING_EXTENSION), at item and quality status, batch, logistic unit or location level, chosen with GroupingLevel. Code: PmxInventoryProvider.GetFreeStock(GetFreeStockParams) → Data.Common/SboCommands.GetCombinedFreeStock. * **Other uses of the view:** PMX_FREE_STOCK is also read per row when a manual move is checked (GetFreeStockFromViewForMove, PmxMoveProvider.CheckBO) and on the line details of a sales document (GetAllVariablePackagingTypesInStock). Neither adds up the rows. === Filters added by each screen === The free stock view itself does not filter anything. Each screen or process adds the filters it needs. The table shows which filters each one uses. ^ Filter ^ What it does ^ Free stock screen (delivery) ^ Get Free Stock button ^ Item Master Data ^ Picking and proposals ^ | Warehouse | Only counts stock in one warehouse | SAP warehouse of the line | SAP warehouse of the line | Per SAP warehouse | Produmex warehouse | | Quality status | Only counts stock with certain quality statuses | • Delivery and A/R invoice: can be shipped, or can be shipped under quarantine \\ • Issue for production: can be used for production \\ • Other documents: all statuses | Based on the //Shipping quality option// of the line: \\ • Released: can be shipped \\ • Can use SUQ: can be shipped, or can be shipped under quarantine \\ • Must use SUQ: can be shipped under quarantine only | • Stock: can be shipped \\ • Reservations: **all statuses** | Set by the process. Pick list proposals use the same rule as the button, sample orders use all statuses. | | Disallowed locations | Leaves out stock on disallowed locations | Yes (delivery and A/R invoice only) | Yes, for stock and reservations | Yes, for stock and reservations | Optional | | Lost and found | Leaves out the lost and found location of the warehouse | Yes, as part of the disallowed locations | Yes, as part of the disallowed locations | Yes, as part of the disallowed locations | Optional | | Reservations of the document itself | Does not subtract the reservations that the document itself created | No | **No.** The reservation of the sales order reduces its own free stock. | Not applicable | Optional | | Customer reservations | Stock reserved for a customer counts as free for that customer | No | No | No | Optional | | Expiry date and shelf life | Leaves out batches whose best before date is earlier than the date plus the shelf life. The shelf life can be set per item, customer and country. | No | No | No | Optional | | Location type, pick location, bin location | Only counts stock on certain location types, pick locations or bin locations | No | No | No | Optional | | Batch attributes | Only counts batches with matching batch attributes | No | No | No | Optional | | Specific batch or logistic unit | Only counts one batch, best before date or logistic unit | No | No | No | Optional | | Location of a reservation | For a reservation without a location, uses the current location of the logistic unit, or the location of the batch if the batch is on one location only | No | No | No | Yes, when disallowed locations are left out | | Only free stock | Only shows rows with free stock | Yes | Not applicable (one number, which can be negative) | Not applicable | Yes | **For technical users:** * The quality status settings are the PMX_QYST flags CanBeShipped, CanBeShippedUnderQuarantine and CanBeUsedForProduction. * The disallowed locations are read from PMX_DISALLOWED_LOCATIONS_FOR_PICKING, which combines PMX_CDLP with the storage locations that have PMX_OSSL.LockedBy filled. * The reservations of the document itself are excluded with NOT (BaseType = x AND BaseEntry = y [AND BaseLine = z]). Customer reservations use PMX_INLD.CardCode. Bin locations are stored in PMX_OSBN, and batch attributes in PMX_ITRI. * The GetFreeStock engine sets these filters with GetFreeStockParams: PmxWarehouseCode, QualityStatusCodes, ExcludeDisallowedLocations, ExcludeLostAndFound, IgnoreDocType / IgnoreDocEntry / IgnoreDocLine, IgnoreCardCode, GetExpiredStock, DateToGetExpiredStock, AddShelfLifeToDateToGetExpiredStock, ShelfLifeOverride, ListOfShelfLifes, CardCode, CountryCode, LocationTypes, IsPickLocation, OnlyFromBinLocation, PrioritizeByPickLocations, ListOfBatchAttributes, BatchNumber, ItemTransactionalInfoKey, BestBeforeDate, LogisticUnitIdentificationKey and ForceSpecificLogisticUnitIdentificationKey. The location of a reservation is resolved with PMX_INVENTORY_LOCKING_EXTENSION when ExcludeDisallowedLocations is set. == Disallowed locations == Disallowed locations are locations that WMS does not use when it proposes stock for picking. WMS keeps a list of these locations, and some screens leave their stock out of the free stock (see Filters added by each screen above). The stock on these locations is still in the warehouse, it is only left out of the free stock on those screens. **The list contains:** * all production line locations * all moving locations * production line input and pick-to locations * lined-up locations * the logistic carrier, returnable item and lost and found locations of the warehouse * warehouse automation input, input-with-box and output locations * all storage locations where //Block stock from being used on proposal// is enabled * storage locations that are locked at the moment, for example during a cycle count **Picked goods are not on the list.** Stock on a shipping dock, on a pick cart or in a packing area still counts as stock. It is normally protected by the reservation of the pick list, so it does not show up as free stock. If the //Do Not Lock Stock on Picking// option is enabled on the Organization Structure, there is no reservation, and picked goods count as free stock on every screen. **For technical users:** the list is available in the view PMX_DISALLOWED_LOCATIONS_FOR_PICKING. It combines the cached table PMX_CDLP, which the add-on rebuilds (GetQueryInsertCachedDisallowedLocationsForPicking), with the storage locations that are currently locked (PMX_OSSL.LockedBy IS NOT NULL). The cache contains all locations of the type PRODLINE and MOVLOC, production line input and pick-to locations, lined-up locations (PMX_CBLU), the logistic carrier, returnable item and lost and found locations of the warehouse, warehouse automation input, input-with-box and output locations, and every storage location with //Block stock from being used on proposal// = Y. == What does not reduce free stock == * **Sales orders without a WMS reservation.** The committed quantity in SAP Business One is not subtracted. WMS only subtracts its own reservations. * **Temporary reservations and locking in advance.** Temporary locks are not subtracted. Locks in advance are only subtracted when the stock has arrived and the lock becomes a normal lock. * **The quality status itself.** A quality status that cannot be shipped is not a reservation. Stock with this status is only left out when the screen filters on quality status. **For technical users:** only PMX_INLD is subtracted. The SAP committed quantity (IsCommited), temporary locks (PMX_TINL) and locks in advance (PMX_AINL) are not part of the calculation. Locks in advance become PMX_INLD rows when the stock arrives. === Common mistakes in a free stock query === **This section is for consultants and partners who write their own SQL queries on free stock.** A common way to calculate a free stock total is to add up ActualFreeQuantity on the free stock view, with filters on the warehouse, the disallowed locations and the quality status. **Such a query is not correct.** The problem is not a missing filter, but the total itself: adding up ActualFreeQuantity counts item, batch and logistic unit reservations once for every row they cover, so the result is too high (see Why the free quantities of the rows cannot be added up above). For an item without reservations, or with location reservations only, the result is correct. This is why the query passes a quick test, but shows different numbers than the screens on live data. The table below reviews the typical parts of such a query. ^ # ^ Part of the query ^ Result ^ Why ^ | 1 | ''%%SUM("ActualFreeQuantity")%%'' | Wrong | ActualFreeQuantity is the free quantity of one row, and item, batch and logistic unit reservations are repeated on every row they cover. Sales orders reserve batches, and pick list proposals and pick lists reserve batches or logistic units, so almost every reserved item is affected. | | 2 | ''%%"StorLocCode" IN (SELECT "Code" FROM PMX_OSEL WHERE "PmxWhsCode" = ...)%%'' | Correct, with a limitation | This filters on the Produmex warehouse. The screens filter on the SAP warehouse (PMX_OSWH.SboWhsCode), which can be linked to several Produmex warehouses. The result is only the same when the codes match. | | 3 | ''%%"StorLocCode" NOT IN (SELECT "Code" FROM PMX_DISALLOWED_LOCATIONS_FOR_PICKING)%%'' | Correct | Works the same way as the Free stock screen and the Get Free Stock button. Add ''%%WHERE "Code" IS NOT NULL%%'', as the add-on does: a single empty (NULL) value in a NOT IN list makes the whole result empty. | | 4 | ''%%"QualityStatusCode" IN (... "CanBeShipped"='Y' OR "CanBeShippedUnderQuarantine"='Y' OR "CanBeUsedForProduction"='Y')%%'' | Wrong for every screen | Mixes three different uses. The Free stock screen for deliveries counts statuses that can be shipped or shipped under quarantine. The Get Free Stock button (Released) and the Item Master Data count statuses that can be shipped only. Issue for production counts statuses that can be used for production only. Statuses that are only allowed for production make the free stock for sales too high. | | 5 | No ''%%"ActualFreeQuantity" > 0%%'' condition | Not relevant for a total | Only matters when listing rows. The Free stock screen uses this condition. | Even the highest FreeQuantityItem per quality status cannot match the Get Free Stock button, because the item level stock in the view includes stock on disallowed locations, and the view cannot leave it out. The reliable way is the method the add-on uses: add up the stock and the reservations directly on the tables, and subtract one from the other. == Correct query == This query returns the same value as the //Get Free Stock// button with the //Shipping quality option// set to Released, and as the //PMX Free Stock// column of the Item Master Data. DECLARE @ItemCode nvarchar(50) = '160731'; DECLARE @SboWhsCode nvarchar(8) = '01'; SELECT ISNULL(inv."Quantity", 0) - ISNULL(lck."Quantity", 0) AS "FreeStock", ISNULL(inv."Quantity", 0) AS "InventoryQuantity", ISNULL(lck."Quantity", 0) AS "LockedQuantity" FROM ( SELECT SUM(PMX_INVT."Quantity") AS "Quantity" FROM PMX_INVT INNER JOIN PMX_OSEL ON PMX_OSEL."Code" = PMX_INVT."StorLocCode" INNER JOIN PMX_OSWH ON PMX_OSWH."Code" = PMX_OSEL."PmxWhsCode" WHERE PMX_INVT."ItemCode" = @ItemCode AND PMX_OSWH."SboWhsCode" = @SboWhsCode AND PMX_INVT."QualityStatusCode" IN (SELECT "Code" FROM PMX_QYST WHERE "CanBeShipped" = 'Y') AND ISNULL(PMX_INVT."StorLocCode", '') NOT IN (SELECT "Code" FROM PMX_DISALLOWED_LOCATIONS_FOR_PICKING WHERE "Code" IS NOT NULL) ) AS inv CROSS JOIN ( SELECT SUM(PMX_INLD."Quantity") AS "Quantity" FROM PMX_INLD INNER JOIN PMX_OSWH ON PMX_OSWH."Code" = PMX_INLD."PmxWhsCode" WHERE PMX_INLD."ItemCode" = @ItemCode AND PMX_OSWH."SboWhsCode" = @SboWhsCode AND PMX_INLD."QualityStatusCode" IN (SELECT "Code" FROM PMX_QYST WHERE "CanBeShipped" = 'Y') AND ISNULL(PMX_INLD."StorLocCode", '') NOT IN (SELECT "Code" FROM PMX_DISALLOWED_LOCATIONS_FOR_PICKING WHERE "Code" IS NOT NULL) ) AS lck; **How to adjust the query:** * **To get the same value as the Item Master Data:** remove the quality status condition from the reservations part (''lck'') only, because the Item Master Data does not filter reservations by quality status. The result can then be lower than the value of the Get Free Stock button. * **To get the same total limit as the Free stock screen:** change the quality status condition to ''%%"CanBeShipped" = 'Y' OR "CanBeShippedUnderQuarantine" = 'Y'%%'' in both parts. * **To see the result per quality status or per Produmex warehouse:** group both parts by QualityStatusCode and PmxWhsCode, and join them on these columns instead of using CROSS JOIN. * **On SAP HANA:** use IFNULL instead of ISNULL, and fixed values or parameters instead of DECLARE variables. * **Reservations without a location:** item, batch and logistic unit reservations have no location (StorLocCode is empty). The ISNULL(..., '') part makes sure these reservations are still counted. This is correct: a batch reservation must count even if the batch is on several locations. === Why the numbers differ === When users compare a query that adds up the free quantities of the rows, the Get Free Stock button and the Free stock screen for the same item, they usually see three different numbers. Each number answers a different question. None of them is wrong, they only look like the same number. ^ ^ Query that adds up ActualFreeQuantity ^ Get Free Stock button / Item Master Data ^ Free stock screen (delivery) ^ ^ Question it answers | None, the total has no real meaning | How much of this item in this SAP warehouse is not reserved by anyone? | Which logistic units and locations can users take from, and how much from each, without breaking a reservation? | ^ Result | The free quantities of all rows added up | One number per item and SAP warehouse | One row per logistic unit and location. When 'OK' is pressed, the total is limited to the free stock of the item. | ^ Calculated from | The free stock view | The stock minus the reservations | The free stock view | ^ Item, batch and logistic unit reservations | Counted once **for every row**, so the total is too high | Counted once | Shown on every row, but only applied once when 'OK' is pressed | ^ Quality statuses | Depends on the query (in the example above: can be shipped, can be shipped under quarantine and can be used for production) | • Button: based on the //Shipping quality option// of the line (Released: can be shipped) \\ • Item Master Data: stock that can be shipped, reservations of **all** statuses | Can be shipped, or can be shipped under quarantine | ^ Disallowed locations | Left out, if the query filters on them | Left out of both stock and reservations | Left out | ^ Warehouse | Produmex warehouse, if the query filters on it | SAP warehouse | SAP warehouse | ^ Rows without free stock | Included. Negative rows lower the total. | Not applicable | Hidden | ^ Reservations of the sales order itself | Subtracted | Subtracted | Subtracted | **The most common reasons why the numbers differ on live data:** - **The item has a sales order, pick list proposal or pick list reservation:** a query that adds up the rows shows more than the Get Free Stock button. The difference can be as much as the free quantity × (the number of rows the reservation covers − 1). This is the most common case. - **Stock has a quality status that can only be shipped under quarantine:** the Free stock screen shows it, but the Get Free Stock button (Released) and the Item Master Data do not. - **Stock has a quality status that is only allowed for production:** a query that includes production statuses counts it, but no screen does. - **Stock with a quality status that cannot be shipped is reserved** (for example blocked stock): the Item Master Data subtracts these reservations, but the Get Free Stock button does not. The Item Master Data can show less than the button for the same warehouse. - **One SAP warehouse is linked to two Produmex warehouses:** the Get Free Stock button and the Free stock screen add both up, but a query on one Produmex warehouse only shows one. - **More stock is reserved than is available on a row** (for example after a partial move or a cycle count): the negative free quantity lowers the total of the query, but the Free stock screen simply hides the row. - **The sales order line has no open quantity:** the Get Free Stock button skips these lines and does not update their //PMX Free Stock// value, so a closed line can show an old value. The Free stock screen itself can also be misleading: the rows show the free quantity per row, and together they can add up to more than users can actually select. The screen only shows this when users press 'OK'. === Recommended approach === **Which free stock number to use depends on the question users want to answer:** ^ Question ^ Where to look ^ | How much of this item is free in the warehouse? | The //Get Free Stock// button on the sales order, or the //PMX Free Stock// column in the Item Master Data. For a report, use the query in Correct query above. | | Which logistic units and locations can stock be taken from? | The free stock view (PMX_FREE_STOCK). It shows the free quantity of each logistic unit on each location. The Free stock screen shows the same values, but only the rows with free stock. | | What will WMS actually pick? | The pick list proposal. Only picking uses all the picking rules. | **Free stock in a report** * Do not add up the free quantities of the Free stock screen or its view. The same reservation would be counted on every logistic unit, and the total would be too high. * Use the query in Correct query above instead. * Decide which quality statuses to count: stock for sales, stock that can be shipped under quarantine, or stock for production. * Write next to the number what it includes. "Free stock" on its own can mean different things. **Free stock per logistic unit or location** The free stock view (PMX_FREE_STOCK) is the right source to see where the free stock is, and where a reservation applies, because it lists every logistic unit on every location. The Free stock screen shows the same values, but hides the rows without free stock. The free quantity on each row is only valid for that row. It shows how much users can take from that logistic unit, not how much is free in total. **What WMS will actually pick** Neither the **Free stock screen** nor the //Get Free Stock// button shows exactly what WMS will pick. **Picking also takes into account:** * expiry dates and shelf life * the reservations of the document itself * reservations for the customer * pick location and bin location rules * batch attributes When a customer asks why a pick list proposal has a different quantity, the debug log of the add-on can help. It contains the exact calculation that WMS used. **For technical users:** * **Report total:** add up the stock (PMX_INVT) and the locks (PMX_INLD) directly on the tables, as in Correct query above. Do not use SUM(ActualFreeQuantity) on PMX_FREE_STOCK. * **Per row:** PMX_FREE_STOCK is the right source. Use ActualFreeQuantity per row only. For the item or batch total, read FreeQuantityItem or FreeQuantityBatch on any row. * **Picking:** picking uses the GetFreeStock engine (PmxInventoryProvider.GetFreeStock). With debug logging enabled on the add-on, the log contains the full generated query (//Freestock query = ...//), which can be run on the database as it is.