Postman collection
Suppliers Write

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.

  1. Find the delivery. Pass SDelHKey or DeliveryNumber (SDelHNr). SDelHSupplNr can narrow the search. The first matching SDelHeader row is used. The call stops if:

    • no delivery matches,
    • the delivery status is CLS or INV,
    • the delivery is locked by Picco (LockedByPicco set) and PiccoUser differs from the user who holds the lock.

    After this step the delivery's own supplier number is used for everything else.

  2. Find the item. fpixi_GetItemKey resolves the item from EANUPC, or from ItemNrInternal if no EAN is given. It looks up scannable item codes (pixi.ItemCode joined with ItemCodeType where Scannable = 1). If both values are given, only EANUPC is used.

  3. Optional purchase order match. This step runs only if InternalNumber or ExternalCode is given. InternalNumber takes priority. The call searches pixi.SupplierOrder by InternalNumber or ExternalCode and checks rules Error01 to Error07:

    • 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: 0 uses statuses with IsConfirmed = 1, 1 uses statuses with IsOrderedConfirmed = 1. The matched order line id is then used to find the delivery line whose SDelDsorderlineRef points to that order line.

  4. Find the delivery line without an order match. All lines of the delivery for the item are read, filtered by SdelDkey if given. If there is no line, or more than one line and no SdelDkey, an error is returned.

  5. 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.

  6. Update the purchase price. If SupplPrice is not 0, Pixi_SetAddItemsSupPrice writes 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. If SupplPrice is 0, the existing prices of the line are kept.

  7. Write the line. GOS_SDelDetailInsertOrUpdate updates the line and returns it in full, including order statistics for the item.

Notes

  • Empty-value handling: the code applies NULLIF(x, '') to int and datetime parameters, which turns 0 (and 1900-01-01 for BestBeforeDate) into NULL. As a result:
    • DeliverdQty = 0 does not set the quantity to 0; the existing quantity is kept.
    • SDelHKey = 0 and InternalNumber = 0 count as not given.
    • Batch number and best-before date cannot be cleared; NULL or empty keeps the existing value.
  • DeliverdQty is declared as int, so fractional quantities are not possible through this call.
  • If DeliveryNumber matches several deliveries, an arbitrary one is used (TOP (1) without ORDER BY). Pass SDelHKey or SDelHSupplNr to be unambiguous.
  • Purchase order search is not limited to the delivery's supplier. If the same ExternalCode or InternalNumber also exists on an order of another supplier, Error02 is returned.
  • If the setting ConfirmOrderedDocumentOnDelivery holds a value other than 0 or 1, no status is allowed and Error06 is always returned. Only the first character of the setting is evaluated. A missing setting counts as 0.
  • When the order match is used together with SdelDkey, the given SdelDkey is the line that gets updated. It is not checked against the matched order line.
  • A negative SupplPrice is not written to AddItems, but it is still written to the delivery line.
  • Pixi_SetAddItemsSupPrice updates AddItems.SupplPrice for all supplier item records with the same IntLinkNr1 and supplier number, not only for the delivered item.
  • If the setting InsertAddItemOnSOrdersDragDrop = 1 and the item has no AddItems record for the supplier, GOS_SDelDetailInsertOrUpdate creates one via Pixi_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 returns 1 in that case. Error04 is returned without a column alias.
  • No explicit transaction is used. Lookups use NOLOCK; the update uses ROWLOCK.

Tables used

SDelHeader · Read SDelDetail · Write Suppliers · Read SupplierOrderStatus · Read SupplierOrder · Read SupplierOrderLine · Read ItemCode · Read ItemCodeType · Read Settings · Read Items · Read AddItems · Write BuyingMatch · Read Customers · Read Orderlines · Read OrderStates · Read OrderHeader · Read
SQL object:
dbo.pipiUpdateDeliveryItem
Updated at 2026-10-30