pixiCreateSupplierOrderFromProfile
Creates supplier (purchase) orders from a stored supplier order suggestion profile and returns the numbers of the created orders.
Runs the supplier order suggestion (Bestellvorschlag) for a saved profile and confirms the result in one step, which creates or extends supplier orders.
Steps:
- Checks that
ProfileIdis given and that a Pixi user namedAPIexists. This user is passed on as the acting user. - Reads the profile XML from
pixi.SupplierOrderSuggestionProfile.Datafor the givenId. If there is no profile or no data, an error row is returned. - Maps the profile settings below
/SuggestionProfileDboto the suggestion parameters:OrderMethod:OrderOnDemand= 1,OrderForTargetStock= 2,OrderOnStockTurnover= 3.SupplierPriority:LowestPrice= 1 (default),FastestDelivery= 2,LatestDelivery= 3.CalculationSuggestionLocation:CalculateSuggestionForEachLocationSeparately= 0 (default),CalculateSuggestionsBasedOnSummarizedParametersForSelectedLocations= 1.ConsiderationOfSuppliers:FromSelectedSuppliers= 0 (default),IfSelectedSupplierIsOptimal= 1.SupplierOrdersCreation:CreateOnlyNewSupplierOrders= 0 (default),AddSuggestedItemsToOpenSupplierOrders= 1.SelectedLocations/int,SelectedSuppliers/intand the tag ids inTagKeysOr,TagKeysAnd,TagKeysNotare joined to comma-separated lists.ConsiderPackagingUnit,ConsiderMinimumOrderAmount,DeliveryLocationId,OrderLocationId,ExcludeSuppliersWithZeroPriceandIncludeOversoldItemsare taken over directly.- Only for
OrderOnStockTurnover:TurnoverInDays,ConsiderReorderLeveland the sales period. WithStockTurnoverSalesOption=SalesPerDayForLastXDaysthe period is the lastSalesForLastXDaysdays up to now; otherwiseSalesFrom/SalesToare used.
- Generates a suggestion run number from the current time (
yyMMddHHmmss) and callspixi.SupplierOrderSuggestionPrepareDataand thenpixi.SupplierOrderSuggestionConfirmData. Validation is skipped in the confirm step. - Returns one row per supplier order linked to this run, with the order's internal number and the supplier number. If no order was linked, an
INFOrow is returned.
Notes
- The actual creation of supplier orders happens in
pixi.SupplierOrderSuggestionPrepareDataandpixi.SupplierOrderSuggestionConfirmData. Their definitions are not attached, so the tables they write and their exact rules are not documented here. Both are called with@ShowOutputSet = 0, which presumably suppresses their own result sets. - All work runs in a transaction. If the caller already has an open transaction, a savepoint is used instead. On an exception the work is rolled back and an
ERRORrow is returned instead of a SQL error. - The user
APImust exist inUCS_USERS. There is no fallback to another user. - The run number is derived from the current time to the second. Two calls started in the same second may get the same number and mix up their results.
- Values in the profile that do not match the listed texts leave the defaults in place. An unknown
OrderMethodleaves the order methodNULL. - Without any tags in a tag list,
NULL(not an empty string) is passed for that list. - Profile and result reads use
NOLOCK.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
ProfileId
|
smallint int |
NULL |
Id of the supplier order suggestion profile in Example: |
Result set 1 · If ProfileId is missing, the user API does not exist or the profile is not found
Status row with the validation error.
| Column | Type | Description |
|---|---|---|
Status
|
varchar(5) string |
Always |
Message
|
varchar(53) string |
Error text. |
Result set 2 · On success, if at least one supplier order is linked to the suggestion run
One row per supplier order created or extended by this run.
| Column | Type | Description |
|---|---|---|
SupplOrderNr
Nullable |
string |
Internal number of the supplier order ( |
SupplNr
Nullable |
string |
Supplier number ( |
Result set 3 · If no supplier order was created, or if an exception occurs
Status row with INFO (nothing created) or ERROR (exception, changes rolled back).
| Column | Type | Description |
|---|---|---|
Status
|
varchar(5) string |
|
Message
|
nvarchar(4000) string |
Info text or error text including the SQL error message. |
Response example
<SqlRowSet1>
<row>
<SupplOrderNr>BE-2024-00125</SupplOrderNr>
<SupplNr>L1001</SupplNr>
</row>
<row>
<SupplOrderNr>BE-2024-00126</SupplOrderNr>
<SupplNr>L1017</SupplNr>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| ERROR | Profile Id is a mandatory parameter. | `ProfileId` was not sent or is NULL. Always pass the profile id. |
| ERROR | UserName "API" does not exist. | There is no Pixi user named `API` in `UCS_USERS`. Create this user before using the call. |
| ERROR | Supplier/purchase order suggestion profile not found. | No profile with this id exists, or its `Data` is empty. Check the profile id. |
| INFO | No supplier/purchase orders created. | The suggestion run produced no supplier orders, e.g. because no item needs to be ordered with the profile settings. |
| ERROR | Unhandled exception occured: {error} | A SQL error occurred while preparing or confirming the suggestion. All changes are rolled back; `{error}` contains the original SQL message. |
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:pixiCreateSupplierOrderFromProfile>
<!-- <ProfileId>3</ProfileId> -->
</ns1:pixiCreateSupplierOrderFromProfile>
</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:pixiCreateSupplierOrderFromProfile>
<!-- <ProfileId>3</ProfileId> -->
</ns1:pixiCreateSupplierOrderFromProfile>
</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 = [
// 'ProfileId' => '3',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiCreateSupplierOrderFromProfile', $soapArguments);
- SQL object:
- dbo.pipiCreateSupplierOrderFromProfile