Postman collection
Suppliers Write

pixiCreateDelivery

Creates a supplier delivery (goods receipt) with status NEW, either from a confirmed purchase order or from item lines passed as XML.

The call creates a delivery header in SDelHeader (status NEW) and its lines in SDelDetail. There are two modes, selected by OrderNr.

Header values

  • Without ParameterXML the plain parameters are used.
  • With ParameterXML the values of the single /CREATE_DELIVERY/Delivery node replace LocID (default 001), OrderNr (default 0), UserName (default API), the note and the external order number. SupplNr from the XML wins, otherwise the SupplNr parameter is used. ExternalReceiptNr can only be passed in the XML. If LocID does not exist, an error row is returned.

Mode 1: OrderNr <> 0 (template from purchase order)

  1. The supplier is taken from the purchase order (pixi.SupplierOrder.InternalNumber = OrderNr), which must have its delivery location at LocID.
  2. The order must be in a deliverable status: confirmed (IsConfirmed) when the setting ConfirmOrderedDocumentOnDelivery is 0, ordered or confirmed (IsOrderedConfirmed) when it is 1.
  3. No delivery with status NEW may already reference the order number.
  4. The delivery is created by Pixi_CreateSDeliveryByTemplate. It gets one line per order line with an open quantity (ordered minus delivered minus undelivered). Delivered quantity is 0, and price and discount come from the order line.

Mode 2: OrderNr = 0 (free delivery / XML lines)

  1. The supplier (SupplNr) must be given and must exist.
  2. Each ITEMS/Item node is resolved to an Artikel through AddItems of this supplier, by ItemNrInt, EAN or ItemNrSuppl. Lines that match no Artikel are reported as failed.
  3. A line with InternalNumber is matched to the purchase order with that internal number. A line with only ExternalCode is matched to the purchase order with that external code. Only orders delivered to LocID count, and the Artikel is looked up on the order lines.
  4. Lines that break a matching rule (Error01–Error07) are reported as failed and are not delivered. Lines without InternalNumber and ExternalCode are delivered without a link to an order line.
  5. For each remaining line:
    • Ordered is the XML value if it is not 0, otherwise the order line quantity.
    • SupplPrice is the XML value, otherwise the order line price.
    • Delivered is multiplied by the Artikel's order unit if the supplier has UsePackingUnitAtCreateDelivery set.
    • Discount is 0.
  6. The header field PurchaseOrderNr holds a comma-separated list of all matched order numbers. If no order was matched, it holds the external order number with a trailing ; removed.
  7. If lines failed, a block Failed To Import Line Items: listing them is appended to the delivery note. The note is limited to 8000 characters in total.
  8. Without any items, only a header is created.

Result

  • Result set 1: the created delivery header.
  • Result set 2: its lines, with the identifiers from the request echoed back.
  • Result set 3 (only when XML items were passed in mode 2): the failed lines.

Validation errors return a single row with column ERROR instead of these result sets.

Notes

  • No transaction. The header and the lines are inserted one after another without an explicit transaction in this procedure. A runtime error in the middle can leave a header with only part of its lines. The template path uses its own transaction for the lines only.
  • Template path changes the order status. When ConfirmOrderedDocumentOnDelivery = 1, Pixi_CreateSDeliveryByTemplate sets the purchase order to the confirmed status. Errors in that procedure are raised as ERROR --- ….
  • Open-delivery check is a substring match. The check for an existing NEW delivery searches the order number as text inside SDelHextOrderNr. Order 123 is therefore also blocked by an open delivery for order 1234.
  • ExternalReceiptNr is only read from the XML. Duplicates per supplier are rejected.
  • SuplierOrderNRExternal is mostly overridden. With XML it is set to NULL when OrderNr = 0. With OrderNr <> 0 it is not passed on at all. So it only takes effect without XML, as fallback for PurchaseOrderNr.
  • Note precedence. With XML, the note from the XML (or an empty string) replaces Note. In template mode an empty XML note falls back to the Note parameter.
  • LocID is only validated on the XML path. Without XML and with OrderNr = 0, a header is created even for an unknown LocID.
  • Ignored XML elements. ItemName and ItemKey in the XML items are read but ignored. Name and key always come from the Artikel master data.
  • One request line can produce several delivery lines. If the Artikel appears on several lines of the matched purchase order, one delivery line is created per order line, each with the full delivered quantity.
  • Error02 on shared external codes. Matching by ExternalCode also finds orders of other suppliers at the same location, and such lines are rejected with Error02.
  • Dirty reads. Most reads use NOLOCK.
  • Comment numbering. Comments in the code call the failed-lines set "result set 4", but it is the third result set returned.

Tables used

Location · Read Settings · Read SupplierOrder · Read SupplierOrderStatus · Read SupplierOrderLine · Read Suppliers · Read AddItems · Read items · Read SDelHeader · Write SDelDetail · Write
SQL object:
dbo.pipiCreateDelivery
Updated at 2026-10-30