Postman collection
Stock Read

pixiGetStockBinsEmpty

Returns empty stock bins (Lagerplätze without any bin item record), optionally only those sorted near a reference bin.

Searches for empty bins (Lagerplätze). A bin counts as empty if no row in InvBinItem references it (BinRef = BinKey).

  1. If both BinName and LocID are passed, the key of the bin with that name in that location is looked up and used as the reference bin (NearBinKey). If no such bin exists, a passed NearBinKey stays unchanged.
  2. LocID empty or NULL means all locations; otherwise only bins of that location (BinLocID) are considered.
  3. Without a reference bin (NearBinKey is NULL or 0): returns the first Rows empty bins ordered by BinSortNum ascending.
  4. With a reference bin: reads the BinSortNum of the reference bin and returns up to Rows / 2 (integer division) empty bins with BinSortNum less than or equal to the reference (the closest ones, i.e. the highest sort numbers below it) plus up to Rows / 2 empty bins with a higher BinSortNum (the closest ones above it). The combined list is sorted by BinSortNum ascending.

The reference bin itself is part of the result if it is empty and matches the location filter.

Notes

  • All reads use NOLOCK, so the result may include uncommitted changes; a bin reported as empty may already be occupied.
  • Any InvBinItem row makes a bin non-empty, regardless of its quantity.
  • With a reference bin and an odd Rows, at most Rows - 1 bins are returned (e.g. Rows = 1 returns nothing).
  • If NearBinKey points to a non-existing bin, the reference sort number is NULL and the result is empty.
  • The location of the reference bin is not checked against LocID; when only NearBinKey is passed, its sort number is compared with bins of the filtered location.
  • BinName is only used together with LocID; on its own it is ignored.
  • Rows must not be NULL or negative, otherwise the TOP clause raises a SQL error.

Tables used

InvBin · Read InvBinItem · Read
SQL object:
dbo.pipiGetStockBinsEmpty
Updated at 2026-10-30