pixiCreateSDeliveryByTemplate
Creates a new supplier delivery (status NEW) at a location from one or more confirmed supplier orders and returns its header.
Creates a supplier delivery document (SDelHeader with SDelDetail lines) using one or more supplier orders as a template.
OrderNris split at;into supplier order numbers (theInternalNumberof the supplier order, e.g. a BES number). Leading and trailing spaces are trimmed.- If a delivery with status
NEWalready exists at locationLocIDwhoseSDelHextOrderNrcontains any of the given numbers, the call stops and returns a single row with the columnERROR. - Otherwise the internal procedure
Pixi_CreateSDeliveryByTemplateis executed:- Only supplier orders whose status counts as confirmed are used. Which status flag is checked depends on the setting
ConfirmOrderedDocumentOnDelivery:0requiresIsConfirmed = 1,1requiresIsOrderedConfirmed = 1. - If no supplier order qualifies, nothing is created.
- With setting
1, the qualifying supplier orders that are not yet confirmed are set to the confirmed status (confirmation date and user are set). - One delivery header is inserted with status
NEW, the given location, the supplier of one of the orders,SDelHextOrderNr= the fullOrderNrstring, andUserNameas creating/updating user (defaultTemplateFromBuyingif NULL). - For every supplier order line with an open quantity (
Qty - DeliveredQty - UndeliveredQty > 0) a delivery line is inserted with delivered quantity 0, the open quantity as ordered quantity, the supplier price and the discount converted to percent and final price.
- Only supplier orders whose status counts as confirmed are used. Which status flag is checked depends on the setting
- Finally the header of the created delivery is returned (
SDelHKey, date, location, number, status, external order number, supplier).
Notes
- The code comment states that this API call is no longer maintained.
- The duplicate check uses a substring match (
CHARINDEX) onSDelHextOrderNr: a number such asBES100is also found insideBES1000, so the check can report false positives. - If no supplier order qualifies (unknown number, wrong status, or the setting
ConfirmOrderedDocumentOnDeliveryhas a value other than0/1), no delivery is created and the header result set is empty; no error is returned. - If the orders belong to different suppliers, the header gets the supplier of an arbitrary one of them (
TOP (1)without order), while lines from all orders are added. - The header insert and the optional status update of the supplier orders run outside the transaction; only the line insert is transactional. If the line insert fails, the header remains without lines and the error is raised as
ERROR --- <message>. CONTEXT_INFOis set during the line insert to suppress the trigger onSDelDetail.- Reads use
NOLOCK. The user ID for confirmation is resolved viainf.UserGetByName, which is not attached.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
OrderNr
Required
|
varchar(1000) string |
– |
One or more supplier order numbers ( Example: |
LocID
Required
|
varchar(3) string |
– |
Location (warehouse) ID for which the delivery is created; also used for the open-delivery check. Example: |
UserName
Required
|
varchar(50) string |
– |
User stored as creator/editor of the delivery; if NULL, Example: |
Result set 1 · If an open delivery (status NEW) at the location already references one of the order numbers
Error row; the call ends without creating anything.
| Column | Type | Description |
|---|---|---|
ERROR
|
varchar(52) string |
Error message text. |
Result set 2 · Otherwise; empty if no qualifying supplier order was found
Header of the newly created supplier delivery.
| Column | Type | Description |
|---|---|---|
SDelHKey
|
int |
Internal key of the delivery header. |
SDelHDate
Nullable |
datetime dateTime |
Delivery date (time of creation). |
SDelHLocationID
Nullable |
string |
Location ID of the delivery. |
SDelHNr
Nullable |
string |
Delivery number (not set by this call; assigned by the database). |
SDelHStatus
Nullable |
string |
Status of the delivery, |
SDelHextOrderNr
Nullable |
string |
The supplier order numbers as passed in |
SDelHSupplNr
Nullable |
string |
Supplier number of the delivery. |
Response example
<SqlRowSet1>
<row>
<SDelHKey>4711</SDelHKey>
<SDelHDate>2024-05-14T10:23:45.123+02:00</SDelHDate>
<SDelHLocationID>001</SDelHLocationID>
<SDelHNr>4711</SDelHNr>
<SDelHStatus>NEW</SDelHStatus>
<SDelHextOrderNr>BES0001234;BES0001235</SDelHextOrderNr>
<SDelHSupplNr>L001</SDelHSupplNr>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| ERROR | ERROR: Supplier order already has an open delivery. | An open delivery with status `NEW` at the given location already contains one of the order numbers in `SDelHextOrderNr`. Finish or delete the existing delivery first. |
| RAISERROR | ERROR --- %s | Inserting the delivery lines failed in the internal procedure (e.g. constraint violation or division error in the discount calculation); the original SQL error message follows. The header may already have been created. |
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:pixiCreateSDeliveryByTemplate>
<OrderNr>BES0001234;BES0001235</OrderNr>
<LocID>001</LocID>
<UserName>jdoe</UserName>
</ns1:pixiCreateSDeliveryByTemplate>
</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:pixiCreateSDeliveryByTemplate>
<OrderNr>BES0001234;BES0001235</OrderNr>
<LocID>001</LocID>
<UserName>jdoe</UserName>
</ns1:pixiCreateSDeliveryByTemplate>
</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 = [
'OrderNr' => 'BES0001234;BES0001235',
'LocID' => '001',
'UserName' => 'jdoe',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiCreateSDeliveryByTemplate', $soapArguments);
- SQL object:
- dbo.pipiCreateSDeliveryByTemplate