pixiShopLinkGetItemsStockRange
Returns the exportable available stock quantity and minimum stock of items, paged by item key, for synchronising shop stock levels.
Returns one row per item with its available quantity for a stock export to a shop. The behaviour depends on the settings OldStockExport, StockExportUsePhysicalStock, ReservePrepaymentOrders and ExportAvailableStock_WhenReservationsAreEnabled. A missing setting counts as 0.
Parameter defaults: FromItemKey NULL becomes 0, RowCount NULL becomes 1000, ExcludeZeros NULL becomes 0.
Standard mode (OldStockExport is not 1):
- Only items with
ItemKey >= FromItemKeyare read. At mostRowCountrows are returned, sorted byItemKeyascending. AvailableQtyis the precomputed export stock of the item (ItemQtyIBIExportStock_locations) minus a deduction:- The open order line quantity (
ItemQtyOpenOrderLines) if reservations are disabled, or if they are enabled andExportAvailableStock_WhenReservationsAreEnabled=1. This applies only ifStockExportUsePhysicalStock=0and the item is not a bundle. - The open reservation quantity (
ItemQtyOpenReservations) if reservations are enabled and the other setting is not1. This also applies only ifStockExportUsePhysicalStock=0and the item is not a bundle. - Nothing in all other cases: physical stock is used, or the item is a bundle.
- The open order line quantity (
- With
ExcludeZeros=1, only items withAvailableQty > 0are returned. - With
ExcludeZeros=0, all items in the range are returned and negative quantities are set to0.
Old mode (OldStockExport = 1):
- Returns
ItemNrInt,QuantityasAvailableQty(NULL becomes 0) andMinStockQtyfor all items. - There is no
ItemKeycolumn, no paging and no sort order. - With
ExcludeZeros=1, items with a quantity of0are left out.
Paging: in standard mode, call again with FromItemKey = last returned ItemKey + 1 until fewer than RowCount rows come back.
Notes
- All reads use
NOLOCK, so results may include uncommitted data. - The quantities come from precomputed columns of
Items(ItemQtyIBIExportStock_locations,ItemQtyOpenOrderLines,ItemQtyOpenReservations). Which stock locations or bins they include is defined elsewhere and is not visible in this procedure. - Old mode differences:
FromItemKeyandRowCountare ignored and all items are returned in one call.ItemKeyis missing from the result.- With
ExcludeZeros=1, negative quantities are still returned. - With
ExcludeZeros=0, negative quantities are not set to 0.
- In standard mode with
ExcludeZeros=1, items whose computed quantity is NULL are also left out. RowCount=0returns no rows. A negative value causes a SQL error fromTOP.- The value of
OldStockExportis converted toint. A non-numeric setting value would cause a conversion error. - The large commented-out legacy block in the source has no effect.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
FromItemKey
|
int | NULL |
Smallest Example: |
RowCount
|
int | NULL |
Maximum number of rows to return. NULL means Example: |
ExcludeZeros
|
bit boolean |
NULL |
Controls whether items without stock are left out. NULL means Allowed values
Example: |
Result set 1 · Standard mode (OldStockExport not 1) and ExcludeZeros = 0 or NULL
Up to RowCount items from FromItemKey on, sorted by ItemKey. Negative quantities are set to 0.
| Column | Type | Description |
|---|---|---|
ItemKey
|
int |
Internal item key. |
ItemNrInt
Nullable |
varchar(50) string |
Internal item number. |
AvailableQty
Nullable |
int |
Exportable available quantity, never negative. |
MinStockQty
Nullable |
int |
Minimum stock quantity of the item. |
Result set 2 · Standard mode (OldStockExport not 1) and ExcludeZeros = 1
Up to RowCount items from FromItemKey on with a positive available quantity, sorted by ItemKey.
| Column | Type | Description |
|---|---|---|
ItemKey
|
int |
Internal item key. |
ItemNrInt
Nullable |
string |
Internal item number. |
AvailableQty
|
int |
Exportable available quantity, always greater than 0. |
MinStockQty
Nullable |
int |
Minimum stock quantity of the item. |
Result set 3 · Old mode (OldStockExport = 1)
All items, or only those with a quantity other than 0 if ExcludeZeros = 1. No paging and no sort order.
| Column | Type | Description |
|---|---|---|
ItemNrInt
Nullable |
string |
Internal item number. |
AvailableQty
|
int |
Item quantity ( |
MinStockQty
Nullable |
int |
Minimum stock quantity of the item. |
Response example
<SqlRowSet1>
<row>
<ItemKey>1001</ItemKey>
<ItemNrInt>ART-10001</ItemNrInt>
<AvailableQty>25</AvailableQty>
<MinStockQty>5</MinStockQty>
</row>
<row>
<ItemKey>1002</ItemKey>
<ItemNrInt>ART-10002</ItemNrInt>
<AvailableQty>0</AvailableQty>
<MinStockQty>0</MinStockQty>
</row>
</SqlRowSet1>
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:pixiShopLinkGetItemsStockRange>
<!-- <FromItemKey>0</FromItemKey> -->
<!-- <RowCount>500</RowCount> -->
<!-- <ExcludeZeros>1</ExcludeZeros> -->
</ns1:pixiShopLinkGetItemsStockRange>
</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:pixiShopLinkGetItemsStockRange>
<!-- <FromItemKey>0</FromItemKey> -->
<!-- <RowCount>500</RowCount> -->
<!-- <ExcludeZeros>1</ExcludeZeros> -->
</ns1:pixiShopLinkGetItemsStockRange>
</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 = [
// 'FromItemKey' => '0',
// 'RowCount' => '500',
// 'ExcludeZeros' => '1',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiShopLinkGetItemsStockRange', $soapArguments);
- SQL object:
- dbo.pipiShopLinkGetItemsStockRange