pixiSetSupplierStockMultiple
Synchronises the stock of one supplier's items on a bin with a list of supplier item numbers and quantities, then returns the resulting bin stock.
Takes a list of supplier item numbers with target quantities and tries to make the stock of the given bin match it.
- The XML in
Itemsis parsed: each/ITEMS/ITEMnode givesItemNrSupplandQuantity. - The bin is looked up in
InvBinbyLocation(BinLocID) andBinName. If no bin is found, a single row withCode=500andMessage=Bin Not Foundis returned and nothing else happens. - The items to change are determined:
- Items from the XML whose
ItemNrSupplmatches anAddItemsentry of supplierSupplNr, whose article is enabled (Items.Enabled = 1), and whose target quantity differs from the current total quantity on the bin (missing stock counts as 0). - Items of the same supplier that currently have stock on the bin but are not listed in the XML. Their target quantity is 0, so they are meant to be cleared from the bin. The
Enabledflag is not checked for these.
- Items from the XML whose
- For every such item,
pixiSetStockis executed with the article'sEANUPC, theBinName, the target quantity andUsername. - Finally one row per article is returned with the supplier item number and the total quantity that is now on the bin, restricted to articles that have an
AddItemsentry forSupplNr.
Notes
- Stock is in practice not changed. A comment in the code states that the call to
pixiSetStockalways fails because noSMORefis passed.pixiSetStockraisesError Message: API pipiSetStockMultiple: SMO is not assigned to API!wheneverSMORefis NULL, writes an entry toLogTableand re-raises the error. The outer procedure has no error handling, so it continues with the next item and the error messages reach the caller asSqlMessageentries next to the final result set. - If the setting
API_Stock_Movementsis disabled,pixiSetStockreturns an extra status row (Status/StatusMessage) for every item to change instead of raising an error. These rows arrive as additional result sets before the final stock list, which shifts the numbering ofSqlRowSet. pixiSetStockis called without a location. It looks up the bin byBinNameonly, so if the same bin name exists in several locations, a different bin than the one checked here may be used.- Articles are passed to
pixiSetStockbyEANUPC. Articles without an EAN or with a duplicate EAN cannot be addressed reliably. - If any
ITEMin the XML has noItemNrSuppl, theNOT INcheck returns no rows, so no items are cleared from the bin. - Items whose
Quantityis missing or not numeric are ignored for the update. - All reads use
NOLOCK. There is no transaction around the loop.
Related calls
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
Items
Required
|
xml | – |
List of supplier item numbers with target quantities for the bin. Root Example:
|
SupplNr
|
varchar(4) string |
MGS |
Supplier number ( Example: |
Location
|
varchar(3) string |
001 |
Location ID ( Example: |
BinName
Required
|
varchar(50) string |
– |
Name of the bin ( Example: |
Username
|
varchar(50) string |
pipiSetSupplierStockMultiple |
User name passed to Example: |
Result set 1 · If the bin was found (after all item updates have been attempted).
Current stock on the bin, one row per article that has an AddItems entry for SupplNr.
| Column | Type | Description |
|---|---|---|
ItemNrSuppl
Nullable |
string |
Supplier item number of the article ( |
Quantity
Nullable |
int |
Total quantity of the article on the bin ( |
Result set 2 · If no bin with BinName exists in Location.
Error row. No stock is processed.
| Column | Type | Description |
|---|---|---|
Code
|
varchar(3) string |
Always |
Message
|
varchar(13) string |
Always |
Result set 3 · Once per item to change, before the stock list, if the setting API_Stock_Movements is disabled (returned by pixiSetStock).
Status row of the nested pixiSetStock call reporting that API stock movements are disabled.
| Column | Type | Description |
|---|---|---|
Status
|
varchar(5) string |
Always |
StatusMessage
|
varchar(73) string |
Error text about the disabled setting. |
Response example
<SqlRowSet1>
<row>
<ItemNrSuppl>mad566</ItemNrSuppl>
<Quantity>50</Quantity>
</row>
<row>
<ItemNrSuppl>mad602</ItemNrSuppl>
<Quantity>30</Quantity>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| 500 | Bin Not Found | No bin with the given `BinName` exists in `Location`. Check the bin name and location ID. |
| ERROR | Setting "API Calls Stock Movements" (API_Stock_Movements) is not enabled. | Returned by the nested `pixiSetStock` call for each item to change when the setting `API_Stock_Movements` is disabled. Enable the setting in Pixi. |
| RAISERROR | Error Message: API pipiSetStockMultiple: SMO is not assigned to API! | Raised by the nested `pixiSetStock` call for each item to change when the setting is enabled, because this procedure never passes an `SMORef`. The error is logged to `LogTable`. It cannot be avoided through this call; use `pixiSetStock` directly with a valid `SMORef` instead. |
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:pixiSetSupplierStockMultiple>
<Items><![CDATA[<ITEMS><ITEM><ItemNrSuppl>mad566</ItemNrSuppl><Quantity>50</Quantity></ITEM><ITEM><ItemNrSuppl>mad602</ItemNrSuppl><Quantity>30</Quantity></ITEM></ITEMS>]]></Items>
<!-- <SupplNr>MGS</SupplNr> -->
<!-- <Location>001</Location> -->
<BinName>A-10-A-1</BinName>
<!-- <Username>shopsync</Username> -->
</ns1:pixiSetSupplierStockMultiple>
</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:pixiSetSupplierStockMultiple>
<Items><![CDATA[<ITEMS><ITEM><ItemNrSuppl>mad566</ItemNrSuppl><Quantity>50</Quantity></ITEM><ITEM><ItemNrSuppl>mad602</ItemNrSuppl><Quantity>30</Quantity></ITEM></ITEMS>]]></Items>
<!-- <SupplNr>MGS</SupplNr> -->
<!-- <Location>001</Location> -->
<BinName>A-10-A-1</BinName>
<!-- <Username>shopsync</Username> -->
</ns1:pixiSetSupplierStockMultiple>
</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 = [
'Items' => '<ITEMS><ITEM><ItemNrSuppl>mad566</ItemNrSuppl><Quantity>50</Quantity></ITEM><ITEM><ItemNrSuppl>mad602</ItemNrSuppl><Quantity>30</Quantity></ITEM></ITEMS>',
// 'SupplNr' => 'MGS',
// 'Location' => '001',
'BinName' => 'A-10-A-1',
// 'Username' => 'shopsync',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiSetSupplierStockMultiple', $soapArguments);
- SQL object:
- dbo.pipiSetSupplierStockMultiple