pixi_CreateSDeliveryByTemplate
Creates a new supplier delivery (status NEW) from one or more confirmed supplier orders and then runs a delivery header list query.
Legacy wrapper that creates a supplier delivery document (SDelHeader / SDelDetail) using supplier orders as a template, then calls a paged list of delivery headers.
Step 1 – create the delivery (via Pixi_CreateSDeliveryByTemplate):
OrderNris split at;. Each element is matched against the internal number (InternalNumber) of a supplier order.- Only supplier orders in a suitable status are used. This depends on the setting
ConfirmOrderedDocumentOnDelivery:0: orders whose status is flagged as confirmed (IsConfirmed = 1).1: orders whose status is flagged as ordered-confirmed (IsOrderedConfirmed = 1). These orders are then switched to the first confirmed status. Confirmation date, confirming user, modification date and modifying user are also set.
- If no order qualifies, nothing is created.
- Otherwise one delivery header is inserted with these values:
- status
NEWand locationLocID - the supplier number of one of the found orders
- the full
OrderNrstring as external order number UserNameas creating and updating employee, and the current date
- status
- For every supplier order line with an open quantity > 0, one delivery line is created. Open quantity is
Qty - DeliveredQty - UndeliveredQty.- Delivered quantity is
0and the ordered quantity is the open quantity. - Supplier price and discount are taken from the order line. A percentage discount is used directly; an amount discount is converted to a percentage per unit.
- Final price and mid price are the price minus the discount amount.
- Delivered quantity is
Step 2 – list query (via Pixi_GetSDelHeaderByPage): the code queries delivery headers of location LocID with status NEW or INV (the ShowInv = NULL argument becomes 1). The call passes page number 0, so the row window is RowNum BETWEEN -PerPage+1 AND 0. As a result the returned result set never contains rows.
The ID of the new delivery is not returned.
Notes
-
A code comment states that this API call is no longer maintained.
-
The returned result set is always empty because page
0is requested. Do not rely on it to find the new delivery. Query the delivery headers separately, for example by location, statusNEWand external order number. -
Only the detail insert runs inside a transaction. These steps run before it and are not rolled back if the detail insert fails:
- the status update of the supplier orders (setting
1) - the header insert
A failure can therefore leave a delivery header without lines.
- the status update of the supplier orders (setting
-
If the setting
ConfirmOrderedDocumentOnDeliveryhas a value other than0or1, no order qualifies and nothing is created. -
If the orders belong to different suppliers, the header gets the supplier number of one arbitrary order (
TOP (1)withoutORDER BY). The lines of all orders are still added. -
If
UserNameis NULL, the inner procedure usesTemplateFromBuying. -
CONTEXT_INFOis set to0x10005during the line insert to bypass theSDelDetail_IUDtrigger. -
Order data is read with
NOLOCK. -
The page size of the list query comes from the setting
BuyingShowPerTab(fallback 500). -
OrderNris limited to 1000 characters in this wrapper.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
OrderNr
Required
|
varchar(1000) string |
– |
Internal numbers of the supplier orders to use as template, separated by Example: |
LocID
Required
|
varchar(3) string |
– |
Location (warehouse) ID for the new delivery. The list query is also filtered by this location. Example: |
UserName
Required
|
varchar(50) string |
– |
User name stored as creating/updating employee. It is also used to confirm the orders when the setting is Example: |
Response
Result set 1 · Always; it never contains rows because the code requests page 0.
Delivery header list of the location (status NEW or INV), produced by the inner list procedure.
| Column | Type | Description |
|---|---|---|
SDelHKey
|
int |
Delivery header key. |
SDelHDate
Nullable |
datetime dateTime |
Delivery date. |
SDelHLocationID
Nullable |
string |
Location ID. |
SDelHSupplNr
Nullable |
string |
Supplier number. |
SDelHNr
Nullable |
string |
Delivery number. |
SDelHNote
Nullable |
string |
Note. |
SDelHStatus
Nullable |
string |
Status (NEW, CLS, INV). |
SDelHCreateDate
Nullable |
datetime dateTime |
Creation date. |
SDelHCreateEmp
Nullable |
string |
Creating employee. |
SDelHUpdateDate
Nullable |
datetime dateTime |
Last update date. |
SDelHUpdateEmp
Nullable |
string |
Last updating employee. |
SDelHextInvoiceNr
Nullable |
string |
External invoice number. |
SDelHextOrderNr
Nullable |
string |
External order number(s), |
SDelHfinalDicsount
Nullable |
decimal |
Final discount of the delivery. |
PiccoUser
Nullable |
string |
Picco user working on the delivery. |
LockedByPicco
Nullable |
string |
Lock flag set by Picco. |
SupplName
Nullable |
string |
Supplier name (left join). |
SuppliersKey
Nullable |
int |
Supplier key (left join). |
ExternalReceiptNr
Nullable |
string |
External receipt number. |
Response example
<SqlRowSet1/>
Error messages
| Status | Message | Cause |
|---|---|---|
| RAISERROR | ERROR --- %s | Inserting the delivery lines failed; `%s` is the original SQL error message. The line insert is rolled back, but the header and any order status changes remain. |
Examples
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:pixi_CreateSDeliveryByTemplate>
<OrderNr>100234;100235</OrderNr>
<LocID>001</LocID>
<UserName>jdoe</UserName>
</ns1:pixi_CreateSDeliveryByTemplate>
</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:pixi_CreateSDeliveryByTemplate>
<OrderNr>100234;100235</OrderNr>
<LocID>001</LocID>
<UserName>jdoe</UserName>
</ns1:pixi_CreateSDeliveryByTemplate>
</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' => '100234;100235',
'LocID' => '001',
'UserName' => 'jdoe',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixi_CreateSDeliveryByTemplate', $soapArguments);
Tables used
- SQL object:
- dbo.pipi_CreateSDeliveryByTemplate