pixiSetStockMultiple
Sets or changes the stock of items on Lagerplätze (bins) from an XML document and returns one result row per processed bin entry.
Processes a list of items with bin entries and books stock movements (put to stock / take out) for each entry.
Steps
- Checks the setting
API_Stock_Movements. If it is not enabled, a singleERRORrow is returned and nothing else happens. - If
ParameterXMLis not empty, it replacesXML. The whole XML text is converted to upper case (element names and values). - The XML is read from
/ITEMSTOCK/ITEM/INVBINS/INVBIN. PerITEM:ITEMKEY,ITEMNRINT,EANUPC,OVERWRITESTOCK. PerINVBIN:BINNAME,STOCK,STOCKADD,STOCKREMOVE,NEUTRALINVENTORY,SMTREF,SMOREF,BATCHNUMBER,BESTBEFOREDATE. EmptySMTREF,SMOREF,BATCHNUMBERandBESTBEFOREDATEare treated as NULL. - The item is resolved in this order: by
ITEMKEY, then byITEMNRINT, then byEANUPC. Item key, item number and EAN of the found item are filled in. - If
OVERWRITESTOCK= 1, an additional entry with target stock 0 is added for every other bin (by bin name) that holds a positive stock of the item and is not listed in the XML – so the item's stock is cleared there. - If the highest
STOCK(orSTOCKADDwhenSTOCKis empty) exceeds the settingMaxStockOperationLimit, the call aborts with an error before any stock is changed. - Each entry with a found item and an existing bin name is processed:
- If the item is tagged for Charge/batch number (tag -6) but no
BATCHNUMBERis given, or tagged for best-before date (tag -7) but noBESTBEFOREDATEis given, the entry is skipped. If the item has no such tag, the value is ignored. - If
STOCKis set, the difference to the current stock on all bins with this name is calculated. A positive difference becomes a put-to-stock quantity, a negative difference a take-out quantity; a difference of 0 yields the success messageNo stock change needed. - Otherwise
STOCKADD/STOCKREMOVEare booked as given. - If
SMOREForSMTREFis missing, defaults are used: stock movement operationAPI/PutToStockwith stock movement type0201for additions,API/TakeOutwith type0301for removals. - The SMO/SMT combination must exist in the stock movement matching table; otherwise the entry fails with an error message.
- The booking is done by
Pixi_InvBinScanIn(addition) orPixi_InvBinTakeOut(removal) with the givenUsername, Charge and best-before date.
- If the item is tagged for Charge/batch number (tag -6) but no
- One result row per entry is returned: processed entries with their success or error message, entries whose item or bin was not found, and remaining unprocessed entries with the batch/best-before message.
- All resolved items are added to
pixi.ItemRecalculateStockQueuefor stock recalculation and export.
Notes
- No overall transaction: every booking is committed separately by
Pixi_InvBinScanIn/Pixi_InvBinTakeOut. A call can succeed partially; checkstatusper row. - The XML is converted to upper case completely, so bin names and batch numbers (Charge) are processed in upper case.
- Omit numeric elements instead of sending them empty: an empty
STOCKmay be read as 0 and would then set the stock to 0. - Bins are identified by
BINNAMEonly. If the same bin name exists in several locations, the current stock is summed over all of them and the location is taken from an arbitrary matching bin (TOP 1). The settingFilterStockOperationsWithLocationis read but not used. OVERWRITESTOCK= 1 clears the item on all other bins with positive stock, in all locations.MaxStockOperationLimitis checked here only forSTOCK/STOCKADD. The called procedures check the quantity again (also for take-outs); such an error is caught, logged and returned as a row withstatus0 and an emptyError.- Do not combine
STOCKwithSTOCKADD/STOCKREMOVEin the same entry: the explicit values may still be booked in addition. The calculated difference is also not reset between entries, which can affect entries withoutSTOCK. - If the SMO is not assigned to application
API, only an informational message (severity 10) is sent; the row is then reported with the misleading batch/best-before message. - Entries without any quantity to book (e.g. only
NEUTRALINVENTORY, which is read but not used) also receive the batch/best-before message. - In the result,
STOCKADD/STOCKREMOVE/SMOREF/SMTREFshow the input values, not the calculated or default values.Reasonis empty for XML entries and holds the bin item reason for entries added byOVERWRITESTOCK. The result has no defined sort order. - SMT/SMO mismatches and caught errors are written to
LogTable. Texts returned by the booking procedures come fromPixi_InvBinScanIn_Base/Pixi_InvBinTakeOut_Base, which are not attached. - Lookups use
NOLOCK.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
XML
|
varchar(max) xml |
NULL |
XML document with items and their bin entries (root Example:
|
ParameterXML
|
varchar(max) xml |
NULL |
Alternative to Example:
|
Username
|
varchar(50) string |
pipiSetStockMultiple |
User name recorded for the stock movements. NULL is replaced by Example: |
Result set 1 · If the setting API_Stock_Movements is not enabled.
Single status row; no stock is changed.
| Column | Type | Description |
|---|---|---|
Status
|
varchar(5) string |
Always |
StatusMessage
|
varchar(72) string |
Error text about the disabled setting. |
Result set 2 · If the setting is enabled and the quantity limit check passes.
One row per bin entry from the XML (plus entries added by OVERWRITESTOCK) with the processing result. No defined sort order.
| Column | Type | Description |
|---|---|---|
ITEMNRINT
Nullable |
varchar(50) string |
Internal item number (from the found item, otherwise from the XML). |
ITEMKEY
Nullable |
int |
Item key; NULL if the item was not found. |
EAN
Nullable |
varchar(50) string |
EAN/UPC of the item. |
BINNAME
Nullable |
varchar(50) string |
Bin name (upper case). |
STOCK
Nullable |
int |
Target stock from the XML (0 for entries added by |
STOCKADD
Nullable |
int |
Quantity to add as sent in the XML (not the calculated difference). |
STOCKREMOVE
Nullable |
int |
Quantity to remove as sent in the XML (not the calculated difference). |
Error
Nullable |
varchar(8000) string |
Error message if the entry failed or was not processed. |
Reason
Nullable |
varchar(50) string |
Empty for XML entries; bin item reason for entries added by |
SMOREF
Nullable |
int |
Stock movement operation key from the XML (defaults are not shown). |
SMTREF
Nullable |
int |
Stock movement type key from the XML (defaults are not shown). |
status
Nullable |
bit boolean |
1 = success, 0 = error or not processed. |
BATCHNUMBER
Nullable |
varchar(50) string |
Batch number (Charge) from the XML. |
BESTBEFOREDATE
Nullable |
datetime dateTime |
Best-before date from the XML. |
SuccessMessage
Nullable |
varchar(8000) string |
Success message, e.g. |
Response example
<SqlRowSet1>
<row>
<ITEMNRINT>ART-1001</ITEMNRINT>
<ITEMKEY>1234</ITEMKEY>
<EAN>4006381333931</EAN>
<BINNAME>A-01-01</BINNAME>
<STOCK>25</STOCK>
<STOCKADD>0</STOCKADD>
<STOCKREMOVE>0</STOCKREMOVE>
<Reason/>
<status>true</status>
<SuccessMessage>No stock change needed</SuccessMessage>
</row>
<row>
<ITEMNRINT>ART-1002</ITEMNRINT>
<ITEMKEY>1235</ITEMKEY>
<EAN>4006381333948</EAN>
<BINNAME>Z-99-99</BINNAME>
<STOCKADD>5</STOCKADD>
<Error>Bin not found</Error>
<Reason/>
<status>false</status>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| ERROR | Setting "API Calls Stock Movements" (API_Stock_Movements) is not enabled. | The setting `API_Stock_Movements` is not set to 1. Enable it in the Pixi settings. |
| RAISERROR | Stock can not be set, stock quantity is greater than limit of setting: MaxStockOperationLimit! | The highest `STOCK` (or `STOCKADD`) in the XML exceeds `MaxStockOperationLimit`. The whole call is aborted without changes; split or correct the quantities. |
| RAISERROR | Error Message: API pipiSetStockMultiple: SMO is not assigned to API! | The given `SMOREF` does not belong to a stock movement operation of application `API` and a stock difference exists. Informational message only (severity 10); the entry is skipped. Use an SMO of application `API`. |
| 0 | Error Message: API pipiSetStockMultiple: SMT is not matched to SMO - please check Control Center - Stock Movements matching table! ItemKey = {ItemKey}, BinName = {BinName} | The SMO/SMT combination is not in the stock movement matching table. Returned in `Error`, also logged and sent as message with severity 1. Maintain the matching in the Control Center. |
| 0 | Item and Bin not found | Neither the item (by key, number or EAN) nor the bin name could be found. |
| 0 | Item not found | The item could not be resolved by `ITEMKEY`, `ITEMNRINT` or `EANUPC`. |
| 0 | Bin not found | No bin with the given `BINNAME` exists. |
| 0 | Item stock was not updated. Item tagged with Batch Number and/or Best Before Date but no information provided. | The item requires a Charge and/or best-before date but the value was missing. Also returned for entries that were skipped for other reasons (SMO not assigned to API, no quantity to book). |
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:pixiSetStockMultiple>
<!-- <XML><![CDATA[<ITEMSTOCK><ITEM><ITEMKEY>1234</ITEMKEY><ITEMNRINT>ART-1001</ITEMNRINT><EANUPC>4006381333931</EANUPC><OVERWRITESTOCK>0</OVERWRITESTOCK><INVBINS><INVBIN><BINNAME>A-01-01</BINNAME><STOCK>25</STOCK><STOCKADD>0</STOCKADD><STOCKREMOVE>0</STOCKREMOVE><NEUTRALINVENTORY>0</NEUTRALINVENTORY><SMTREF></SMTREF><SMOREF></SMOREF><BATCHNUMBER>CH-2024-01</BATCHNUMBER><BESTBEFOREDATE>2025-12-31T00:00:00</BESTBEFOREDATE></INVBIN></INVBINS></ITEM></ITEMSTOCK>]]></XML> -->
<!-- <ParameterXML><![CDATA[<ITEMSTOCK><ITEM><ITEMKEY>1234</ITEMKEY><ITEMNRINT>ART-1001</ITEMNRINT><EANUPC>4006381333931</EANUPC><OVERWRITESTOCK>0</OVERWRITESTOCK><INVBINS><INVBIN><BINNAME>A-01-01</BINNAME><STOCK>25</STOCK><STOCKADD>0</STOCKADD><STOCKREMOVE>0</STOCKREMOVE><NEUTRALINVENTORY>0</NEUTRALINVENTORY><SMTREF></SMTREF><SMOREF></SMOREF><BATCHNUMBER>CH-2024-01</BATCHNUMBER><BESTBEFOREDATE>2025-12-31T00:00:00</BESTBEFOREDATE></INVBIN></INVBINS></ITEM></ITEMSTOCK>]]></ParameterXML> -->
<!-- <Username>shop-sync</Username> -->
</ns1:pixiSetStockMultiple>
</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:pixiSetStockMultiple>
<!-- <XML><![CDATA[<ITEMSTOCK><ITEM><ITEMKEY>1234</ITEMKEY><ITEMNRINT>ART-1001</ITEMNRINT><EANUPC>4006381333931</EANUPC><OVERWRITESTOCK>0</OVERWRITESTOCK><INVBINS><INVBIN><BINNAME>A-01-01</BINNAME><STOCK>25</STOCK><STOCKADD>0</STOCKADD><STOCKREMOVE>0</STOCKREMOVE><NEUTRALINVENTORY>0</NEUTRALINVENTORY><SMTREF></SMTREF><SMOREF></SMOREF><BATCHNUMBER>CH-2024-01</BATCHNUMBER><BESTBEFOREDATE>2025-12-31T00:00:00</BESTBEFOREDATE></INVBIN></INVBINS></ITEM></ITEMSTOCK>]]></XML> -->
<!-- <ParameterXML><![CDATA[<ITEMSTOCK><ITEM><ITEMKEY>1234</ITEMKEY><ITEMNRINT>ART-1001</ITEMNRINT><EANUPC>4006381333931</EANUPC><OVERWRITESTOCK>0</OVERWRITESTOCK><INVBINS><INVBIN><BINNAME>A-01-01</BINNAME><STOCK>25</STOCK><STOCKADD>0</STOCKADD><STOCKREMOVE>0</STOCKREMOVE><NEUTRALINVENTORY>0</NEUTRALINVENTORY><SMTREF></SMTREF><SMOREF></SMOREF><BATCHNUMBER>CH-2024-01</BATCHNUMBER><BESTBEFOREDATE>2025-12-31T00:00:00</BESTBEFOREDATE></INVBIN></INVBINS></ITEM></ITEMSTOCK>]]></ParameterXML> -->
<!-- <Username>shop-sync</Username> -->
</ns1:pixiSetStockMultiple>
</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 = [
// 'XML' => '<ITEMSTOCK><ITEM><ITEMKEY>1234</ITEMKEY><ITEMNRINT>ART-1001</ITEMNRINT><EANUPC>4006381333931</EANUPC><OVERWRITESTOCK>0</OVERWRITESTOCK><INVBINS><INVBIN><BINNAME>A-01-01</BINNAME><STOCK>25</STOCK><STOCKADD>0</STOCKADD><STOCKREMOVE>0</STOCKREMOVE><NEUTRALINVENTORY>0</NEUTRALINVENTORY><SMTREF></SMTREF><SMOREF></SMOREF><BATCHNUMBER>CH-2024-01</BATCHNUMBER><BESTBEFOREDATE>2025-12-31T00:00:00</BESTBEFOREDATE></INVBIN></INVBINS></ITEM></ITEMSTOCK>',
// 'ParameterXML' => '<ITEMSTOCK><ITEM><ITEMKEY>1234</ITEMKEY><ITEMNRINT>ART-1001</ITEMNRINT><EANUPC>4006381333931</EANUPC><OVERWRITESTOCK>0</OVERWRITESTOCK><INVBINS><INVBIN><BINNAME>A-01-01</BINNAME><STOCK>25</STOCK><STOCKADD>0</STOCKADD><STOCKREMOVE>0</STOCKREMOVE><NEUTRALINVENTORY>0</NEUTRALINVENTORY><SMTREF></SMTREF><SMOREF></SMOREF><BATCHNUMBER>CH-2024-01</BATCHNUMBER><BESTBEFOREDATE>2025-12-31T00:00:00</BESTBEFOREDATE></INVBIN></INVBINS></ITEM></ITEMSTOCK>',
// 'Username' => 'shop-sync',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiSetStockMultiple', $soapArguments);
- SQL object:
- dbo.pipiSetStockMultiple