pixiGetChangedItemStock2
Returns items whose stock changed in a time window, with physical, available and per-location stock, reorder level and open supplier order quantity, with paging.
Delta export of stock changes, typically used to sync shop stock levels.
1. Locations. All locations, or only LocID if it is set.
2. Changed items. Non-bundle items with entries in the bin item log (InvBinItemLog) whose UpdateDate is between Since and DateTo in the selected locations.
StockChangeis the sum of the logged quantities in the window.UpdateDateis the latest log date.OriginalUpdateDateis the item'sLastCalculateStockDate, or the latest log date if that is empty.
3. Order line changes. With IncludeOrderLineChanges = 1, items with order lines that were updated in the window are added if they are not already candidates. The line's LocationID must be one of the selected locations, and the item must have bin log entries in those locations.
- For these items
StockChangeis the sum of all log entries in those locations, not only those in the window. UpdateDateisLastCalculateStockDate, otherwise the latest log date, otherwise the current time.
4. Bundles. For every changed component, the bundle items that contain it are added (BundleItem = 1). Their StockChange is the largest component change divided (integer division) by the component quantity in the bundle. Items that are bundle heads are only returned as bundle rows.
5. Sorting and paging. Candidates are numbered by UpdateDate ascending, then by the highest log key. Rows with a number of at least Start + 1 are returned, at most Rowcount of them.
6. Stock figures.
PhysicalStock:items.Quantity.MinStockQty: sum of the non-negativeMinStockQtyvalues inItemLocationSpecificforLocID, or for all locations.- For non-bundles:
AvailableStock= the sum ofLocationQuantityover all locations that are not special stock, minus the reserved quantity (see notes).OpenSupplierOrderQTY= sum ofQty - DeliveredQty - UndeliveredQtyover supplier orders whose status hasIsAllOpen = 1.EstimatedDeliverycomes fromItem_EstimatedDelivery.ExportEstimatedDelivery.
- For bundles,
AvailableStockstaysitems.Quantity,OpenSupplierOrderQTYis 0 andEstimatedDeliveryis empty.
7. Excluded bin groups. If ExcludeBinGroups is set, the quantity in bins of these groups is subtracted from PhysicalStock, AvailableStock and StockChange. This quantity is the sum of all log entries up to DateTo. For bundles it is derived from the components. PhysicalStockLoc is then the sum of the bin quantities in the selected locations, without the excluded bin groups.
Without ExcludeBinGroups, PhysicalStockLoc is the sum of LocationQuantity in the selected locations, for non-bundles only.
The returned RowNr is renumbered from 1 within the returned page.
Notes
- Read-only. All reads use
NOLOCK, so results can contain uncommitted data.
Settings read at runtime:
StockExportUsePhysicalStock: only if0, open order quantities and reservations are subtracted fromAvailableStock.ReservePrepaymentOrdersandExportAvailableStock_WhenReservationsAreEnabled:- If reservations are off, or both settings are
1, the subtracted quantity is the sum of order lines in statusANG, plusHALlines with an order date within the lastHalOrdersActiveDaysdays (default 7). - Otherwise it is the number of reservations whose order line has a non-final status other than
EIN,FUTandFUS. Because of the join, reservations only count if the item also hasANG/HALlines.
- If reservations are off, or both settings are
ExportStock_locationsis read but not used.
Pitfalls:
Sincemust be a real date. The value 0 (1900-01-01) is turned into NULL and then no log entries match.DateTovalues up to 1990-01-01 are replaced by the current time.- The base for
AvailableStockcovers all non-special locations, even whenLocIDis set. - The bin group exclusion considers bins of all locations.
- For the next page, increase
Startby the number of rows received, or continue with a laterSince. The returnedRowNris page-relative. - The comment in the code says bundles use
LocationQuantity, but the code updatesPhysicalStockLoconly for non-bundles; for bundles it stays 0.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
Since
Required
|
datetime dateTime |
– |
Start of the change window. Bin log entries and, if enabled, order line changes from this time on are considered. Example: |
Rowcount
|
int | 1000 |
Maximum number of rows returned (page size). Example: |
LocID
|
varchar(3) string |
– |
Location ID to restrict changes, reorder level and Example: |
DateTo
|
datetime dateTime |
NULL |
End of the change window. NULL, 0 or a date up to 1990-01-01 means the current time. Example: |
Start
|
int | 0 |
Number of candidate rows to skip (paging offset). 0 starts with the first row. Example: |
ExcludeBinGroups
|
varchar(max) string |
NULL |
Comma-separated list of bin groups whose quantities are subtracted from the stock figures. Empty or NULL disables the exclusion. Example: |
IncludeOrderLineChanges
|
smallint int |
0 |
If 1, items with order lines updated in the window are also returned. Allowed values
Example: |
Response
Result set 1 · Always (may be empty)
One row per changed item or affected bundle, ordered by change date.
| Column | Type | Description |
|---|---|---|
ItemKey
|
int |
Internal item key. |
ItemNrInt
Nullable |
varchar(50) string |
Internal item number. |
EANUPC
Nullable |
varchar(13) string |
EAN/UPC of the item. |
ItemNrSuppl
Nullable |
varchar(50) string |
Supplier item number. |
PhysicalStock
Nullable |
int |
Physical stock from |
AvailableStock
Nullable |
int |
Available stock: location quantity minus open orders or reservations (non-bundles); |
StockChange
Nullable |
int |
Net stock change in the window (sum of bin log quantities). |
EstimatedDelivery
Nullable |
datetime dateTime |
Estimated delivery date for export; NULL for bundles or if not set. |
MinStockQty
Nullable |
int |
Reorder level summed over the selected location(s). |
Enabled
Nullable |
bit boolean |
Whether the item is enabled. |
OpenSupplierOrderQTY
Nullable |
int |
Open quantity in open supplier orders (0 for bundles). |
UpdateDate
Nullable |
datetime dateTime |
Latest change date used for sorting. |
OriginalUpdateDate
Nullable |
datetime dateTime |
The item's |
BundleItem
Nullable |
bit boolean |
1 if the row is a bundle item. |
RowNr
|
bigint long |
Row number within the returned page, starting at 1. |
PhysicalStockLoc
Nullable |
int |
Physical stock in the selected location(s), without excluded bin groups if given; 0 if not determined. |
Response example
<SqlRowSet1>
<row>
<ItemKey>10452</ItemKey>
<ItemNrInt>ART-10452</ItemNrInt>
<EANUPC>4012345678901</EANUPC>
<ItemNrSuppl>SUP-889</ItemNrSuppl>
<PhysicalStock>25</PhysicalStock>
<AvailableStock>21</AvailableStock>
<StockChange>-3</StockChange>
<MinStockQty>5</MinStockQty>
<Enabled>true</Enabled>
<OpenSupplierOrderQTY>50</OpenSupplierOrderQTY>
<UpdateDate>2024-05-01T09:15:22</UpdateDate>
<OriginalUpdateDate>2024-05-01T09:16:00</OriginalUpdateDate>
<BundleItem>false</BundleItem>
<RowNr>1</RowNr>
<PhysicalStockLoc>25</PhysicalStockLoc>
</row>
<row>
<ItemKey>20877</ItemKey>
<ItemNrInt>SET-20877</ItemNrInt>
<EANUPC>4012345678918</EANUPC>
<ItemNrSuppl/>
<PhysicalStock>0</PhysicalStock>
<AvailableStock>4</AvailableStock>
<StockChange>-1</StockChange>
<MinStockQty>0</MinStockQty>
<Enabled>true</Enabled>
<OpenSupplierOrderQTY>0</OpenSupplierOrderQTY>
<UpdateDate>2024-05-01T09:15:22</UpdateDate>
<OriginalUpdateDate>2024-05-01T09:15:22</OriginalUpdateDate>
<BundleItem>true</BundleItem>
<RowNr>2</RowNr>
<PhysicalStockLoc>0</PhysicalStockLoc>
</row>
</SqlRowSet1>
Examples
POST https://apigateway.descartes.com/tms/pixi/
Content-Type: text/xml; charset=utf-8
Authorization: Basic BASE64(USERNAME:PASSWORD)
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://apigateway.descartes.com/tms/pixi/">
<SOAP-ENV:Body>
<ns1:pixiGetChangedItemStock2>
<Since>2024-05-01T00:00:00</Since>
<!-- <Rowcount>500</Rowcount> -->
<!-- <LocID>001</LocID> -->
<!-- <DateTo>2024-05-02T00:00:00</DateTo> -->
<!-- <Start>0</Start> -->
<!-- <ExcludeBinGroups>RETURNS,DEFECT</ExcludeBinGroups> -->
<!-- <IncludeOrderLineChanges>1</IncludeOrderLineChanges> -->
</ns1:pixiGetChangedItemStock2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
curl -X POST 'https://apigateway.descartes.com/tms/pixi/' \
--user 'USERNAME:PASSWORD' \
--header 'Content-Type: text/xml; charset=utf-8' \
--data-binary @- <<'XML'
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://apigateway.descartes.com/tms/pixi/">
<SOAP-ENV:Body>
<ns1:pixiGetChangedItemStock2>
<Since>2024-05-01T00:00:00</Since>
<!-- <Rowcount>500</Rowcount> -->
<!-- <LocID>001</LocID> -->
<!-- <DateTo>2024-05-02T00:00:00</DateTo> -->
<!-- <Start>0</Start> -->
<!-- <ExcludeBinGroups>RETURNS,DEFECT</ExcludeBinGroups> -->
<!-- <IncludeOrderLineChanges>1</IncludeOrderLineChanges> -->
</ns1:pixiGetChangedItemStock2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
XML
<?php
$soapClient = new SoapClient(null, [
'login' => 'USERNAME',
'password' => 'PASSWORD',
'location' => 'https://apigateway.descartes.com/tms/pixi/',
'uri' => 'https://apigateway.descartes.com/tms/pixi/',
]);
$arguments = [
'Since' => '2024-05-01T00:00:00',
// 'Rowcount' => '500',
// 'LocID' => '001',
// 'DateTo' => '2024-05-02T00:00:00',
// 'Start' => '0',
// 'ExcludeBinGroups' => 'RETURNS,DEFECT',
// 'IncludeOrderLineChanges' => '1',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiGetChangedItemStock2', $soapArguments);
Tables used
- SQL object:
- dbo.pipiGetChangedItemStock2