pixiUpdateDeliveryItem
Updates an existing item line of a supplier delivery (quantity, purchase price, batch, best-before date), optionally matched to a purchase order line.
Changes one existing line (SDelDetail) of a supplier delivery. The call never adds new lines. It only updates a line that already exists for the item on the delivery.
-
Find the delivery. Pass
SDelHKeyorDeliveryNumber(SDelHNr).SDelHSupplNrcan narrow the search. The first matchingSDelHeaderrow is used. The call stops if:- no delivery matches,
- the delivery status is
CLSorINV, - the delivery is locked by Picco (
LockedByPiccoset) andPiccoUserdiffers from the user who holds the lock.
After this step the delivery's own supplier number is used for everything else.
-
Find the item.
fpixi_GetItemKeyresolves the item fromEANUPC, or fromItemNrInternalif no EAN is given. It looks up scannable item codes (pixi.ItemCodejoined withItemCodeTypewhereScannable = 1). If both values are given, onlyEANUPCis used. -
Optional purchase order match. This step runs only if
InternalNumberorExternalCodeis given.InternalNumbertakes priority. The call searchespixi.SupplierOrderbyInternalNumberorExternalCodeand checks rulesError01toError07:- the external code must not appear on several orders of the delivery's supplier,
- an order must be found,
- the order must belong to the delivery's supplier,
- the item must be on the order,
- the order status must be allowed for delivery.
Allowed statuses depend on the setting
ConfirmOrderedDocumentOnDelivery:0uses statuses withIsConfirmed = 1,1uses statuses withIsOrderedConfirmed = 1. The matched order line id is then used to find the delivery line whoseSDelDsorderlineRefpoints to that order line. -
Find the delivery line without an order match. All lines of the delivery for the item are read, filtered by
SdelDkeyif given. If there is no line, or more than one line and noSdelDkey, an error is returned. -
Fill in missing values. Parameters left empty keep the existing line values: delivered quantity, batch number, best-before date and order line reference. The ordered quantity is always taken from the existing line.
-
Update the purchase price. If
SupplPriceis not 0,Pixi_SetAddItemsSupPricewrites the price to the supplier item data (AddItems). This happens only for positive prices. The line then gets price, mid price and final price =SupplPrice, with discounts set to 0. IfSupplPriceis 0, the existing prices of the line are kept. -
Write the line.
GOS_SDelDetailInsertOrUpdateupdates the line and returns it in full, including order statistics for the item.
Notes
- Empty-value handling: the code applies
NULLIF(x, '')tointanddatetimeparameters, which turns0(and1900-01-01forBestBeforeDate) into NULL. As a result:DeliverdQty = 0does not set the quantity to 0; the existing quantity is kept.SDelHKey = 0andInternalNumber = 0count as not given.- Batch number and best-before date cannot be cleared; NULL or empty keeps the existing value.
DeliverdQtyis declared asint, so fractional quantities are not possible through this call.- If
DeliveryNumbermatches several deliveries, an arbitrary one is used (TOP (1)withoutORDER BY). PassSDelHKeyorSDelHSupplNrto be unambiguous. - Purchase order search is not limited to the delivery's supplier. If the same
ExternalCodeorInternalNumberalso exists on an order of another supplier,Error02is returned. - If the setting
ConfirmOrderedDocumentOnDeliveryholds a value other than0or1, no status is allowed andError06is always returned. Only the first character of the setting is evaluated. A missing setting counts as0. - When the order match is used together with
SdelDkey, the givenSdelDkeyis the line that gets updated. It is not checked against the matched order line. - A negative
SupplPriceis not written toAddItems, but it is still written to the delivery line. Pixi_SetAddItemsSupPriceupdatesAddItems.SupplPricefor all supplier item records with the sameIntLinkNr1and supplier number, not only for the delivered item.- If the setting
InsertAddItemOnSOrdersDragDrop=1and the item has noAddItemsrecord for the supplier,GOS_SDelDetailInsertOrUpdatecreates one viaPixi_InsertAddItemOnDelivery. That procedure is not attached, so it is unknown whether it returns an additional result set. - Errors are returned as rows with a column
ERROR. The procedure also returns1in that case.Error04is returned without a column alias. - No explicit transaction is used. Lookups use
NOLOCK; the update usesROWLOCK.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
SDelHKey
|
int | NULL |
Internal key of the delivery ( Example: |
DeliveryNumber
|
int | NULL |
Delivery number ( Example: |
UserName
|
varchar(50) string |
API |
User name stored as the last editor of the delivery line ( Example: |
ItemNrInternal
|
varchar(50) string |
NULL |
Item identifier, looked up among scannable item codes. Used only if Example: |
EANUPC
|
varchar(13) string |
NULL |
EAN/UPC of the item, looked up among scannable item codes. Takes priority over Example: |
SDelHSupplNr
|
varchar(4) string |
NULL |
Optional supplier number filter for finding the delivery. Afterwards the supplier number of the found delivery is used. Example: |
DeliverdQty
|
int | NULL |
New delivered quantity. NULL or 0 keeps the existing quantity of the line. Example: |
SupplPrice
|
money decimal |
0 |
New purchase price. If not 0, it is written to the line (price, mid price and final price; discounts are set to 0). Positive values are also stored in Example: |
PiccoUser
|
varchar(50) string |
NULL |
Picco user name. Required to update a delivery locked by Picco; it must match the locking user. Example: |
InternalNumber
|
int | NULL |
Internal number of a purchase order ( Example: |
ExternalCode
|
varchar(50) string |
NULL |
External code of a purchase order ( Example: |
BatchNumber
|
varchar(50) string |
NULL |
Batch number (Charge) for the line. NULL or empty keeps the existing value. Example: |
BestBeforeDate
|
datetime dateTime |
NULL |
Best-before date for the line. NULL keeps the existing value. Example: |
SdelDkey
|
int | NULL |
Key of the delivery line ( Example: |
Result set 1 · If a validation fails (all errors except Error04)
One row with the error text; nothing is changed.
| Column | Type | Description |
|---|---|---|
ERROR
|
nvarchar string |
Error message. |
Result set 2 · If Error04 occurs (search by ExternalCode, item not on the order)
One row with the error text in a column without alias; the column name in the response is not defined by the code.
| Column | Type | Description |
|---|---|---|
(unnamed)
|
varchar string |
Text |
Result set 3 · On success
The updated delivery line as returned by GOS_SDelDetailInsertOrUpdate.
| Column | Type | Description |
|---|---|---|
SDelDkey
|
int |
Key of the delivery line. |
SDelDHref
|
int |
Key of the delivery header. |
SDelDItemRef
|
int |
Item key. |
SDelDItemName
Nullable |
string |
Item name. |
SDelDqtyDelivered
|
money decimal |
Delivered quantity. |
SDelDqtyOrdered
|
money decimal |
Ordered quantity. |
SDelDsorderlineRef
Nullable |
int |
Reference to the purchase order line. |
SDelDsPrice
Nullable |
money decimal |
Purchase price. |
SDelDsDiscount
Nullable |
money decimal |
Discount. |
SDelDsFinalPrice
Nullable |
money decimal |
Final price. |
SDelDcreateDate
Nullable |
datetime dateTime |
Creation date of the line. |
SDelDcreateEmp
Nullable |
string |
User who created the line. |
SDelDupdateDate
Nullable |
datetime dateTime |
Date of the last change. |
SDelDupdateEmp
Nullable |
string |
User of the last change. |
SDelDsAddDiscount
Nullable |
money decimal |
Additional discount. |
SDelDsMidPrice
Nullable |
money decimal |
Mid price. |
BatchNumber
Nullable |
varchar(50) string |
Batch number. |
BestBeforeDate
Nullable |
datetime dateTime |
Best-before date. |
BuyingMatchQty
|
decimal |
Sum of |
OpenCustomersCountForItem
|
int |
Number of customers with active orderlines for the item in the delivery's location. |
OpenOrdersCountForItem
|
int |
Number of orders with active orderlines for the item in the delivery's location. |
OpenQTYSforItem
Nullable |
decimal |
Total quantity of active orderlines for the item in the delivery's location. |
ItemNrSuppl
Nullable |
string |
Supplier item number from |
ItemNrInt
Nullable |
string |
Internal item number from |
EANUPC
Nullable |
string |
EAN/UPC from |
Response example
<SqlRowSet1>
<row>
<ERROR>Item not exist on delivery</ERROR>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| ERROR | You must provide Delivery referenc or Delivery number. | Neither `SDelHKey` nor `DeliveryNumber` was given (or 0). |
| ERROR | You must provide item EAN or ItemNrInternal. | Neither `EANUPC` nor `ItemNrInternal` was given. |
| ERROR | For given parameters (@SDelHKey, @SDelHNr, @SDelHSupplNr) no delivery document found. | No delivery matches the given key, number and supplier number. |
| ERROR | You cant update items from closed or invoiced deliveries. | The delivery has status `CLS` or `INV`. |
| ERROR | Delivery is locked by picco | The delivery is locked by Picco and `PiccoUser` does not match the locking user. |
| ERROR | Item with EANUPC {EANUPC} does not exist. | No scannable item code matches the given EAN. |
| ERROR | Item with ItemNrInternal {ItemNrInternal} does not exist. | No scannable item code matches `ItemNrInternal` (and no EAN was given). |
| ERROR | Error01: External Code belongs to multiple Purchase orders | Search by `ExternalCode`: the code exists on more than one purchase order of the delivery's supplier. Use `InternalNumber` instead. |
| ERROR | Error02: Purchase order belongs to a different supplier | A purchase order found by `InternalNumber`/`ExternalCode` belongs to a supplier other than the delivery's supplier. |
| ERROR | Error03: No Purchase Order match for External Code | No purchase order has the given `ExternalCode`. |
| ERROR | Error04: Item not found on Purchase Order | Search by `ExternalCode`: the order (in an allowed status) has no line for the item. Returned without column alias. |
| ERROR | Error05: Item not found on Purchase Order | Search by `InternalNumber`: the order (in an allowed status) has no line for the item. |
| ERROR | Error06: Purchase Order is not on proper status | The purchase order status is not allowed for delivery according to the setting `ConfirmOrderedDocumentOnDelivery`. |
| ERROR | Error07: No Purchase Order match for Internal Number | No purchase order has the given `InternalNumber`. |
| ERROR | Item not exist on delivery | The delivery has no line for the item (or for the given `SdelDkey`). This call cannot add new lines. |
| ERROR | Multiple rows for this item exist, you must provide SdelDkey (delivery item line ID) | The item occurs on several lines of the delivery; pass `SdelDkey`. |
| ERROR | Purchase Order item with InternalNumber or ExternalCode reference does not exist on Delivery. | The matched purchase order line is not referenced by any line of this delivery for the item. |
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:pixiUpdateDeliveryItem>
<!-- <SDelHKey>10452</SDelHKey> -->
<!-- <DeliveryNumber>2024117</DeliveryNumber> -->
<!-- <UserName>API</UserName> -->
<!-- <ItemNrInternal>ART-100234</ItemNrInternal> -->
<!-- <EANUPC>4006381333931</EANUPC> -->
<!-- <SDelHSupplNr>LIEF</SDelHSupplNr> -->
<!-- <DeliverdQty>24</DeliverdQty> -->
<!-- <SupplPrice>12.50</SupplPrice> -->
<!-- <PiccoUser>picco01</PiccoUser> -->
<!-- <InternalNumber>5871</InternalNumber> -->
<!-- <ExternalCode>PO-2024-0815</ExternalCode> -->
<!-- <BatchNumber>CH-2024-07</BatchNumber> -->
<!-- <BestBeforeDate>2025-12-31T00:00:00</BestBeforeDate> -->
<!-- <SdelDkey>883104</SdelDkey> -->
</ns1:pixiUpdateDeliveryItem>
</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:pixiUpdateDeliveryItem>
<!-- <SDelHKey>10452</SDelHKey> -->
<!-- <DeliveryNumber>2024117</DeliveryNumber> -->
<!-- <UserName>API</UserName> -->
<!-- <ItemNrInternal>ART-100234</ItemNrInternal> -->
<!-- <EANUPC>4006381333931</EANUPC> -->
<!-- <SDelHSupplNr>LIEF</SDelHSupplNr> -->
<!-- <DeliverdQty>24</DeliverdQty> -->
<!-- <SupplPrice>12.50</SupplPrice> -->
<!-- <PiccoUser>picco01</PiccoUser> -->
<!-- <InternalNumber>5871</InternalNumber> -->
<!-- <ExternalCode>PO-2024-0815</ExternalCode> -->
<!-- <BatchNumber>CH-2024-07</BatchNumber> -->
<!-- <BestBeforeDate>2025-12-31T00:00:00</BestBeforeDate> -->
<!-- <SdelDkey>883104</SdelDkey> -->
</ns1:pixiUpdateDeliveryItem>
</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 = [
// 'SDelHKey' => '10452',
// 'DeliveryNumber' => '2024117',
// 'UserName' => 'API',
// 'ItemNrInternal' => 'ART-100234',
// 'EANUPC' => '4006381333931',
// 'SDelHSupplNr' => 'LIEF',
// 'DeliverdQty' => '24',
// 'SupplPrice' => '12.50',
// 'PiccoUser' => 'picco01',
// 'InternalNumber' => '5871',
// 'ExternalCode' => 'PO-2024-0815',
// 'BatchNumber' => 'CH-2024-07',
// 'BestBeforeDate' => '2025-12-31T00:00:00',
// 'SdelDkey' => '883104',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiUpdateDeliveryItem', $soapArguments);
- SQL object:
- dbo.pipiUpdateDeliveryItem