pixiDeleteOrder
Deletes a complete order (Auftrag) if all orderlines are in status ANG, HAL or STO and none is on an active pick list.
Deletes the order identified by OrderNr together with its dependent data and returns one status row.
Checks (run before any change):
- The order header is looked up by
OrderNr, joined with its orderlines, bank matches, customer account events and pick list items. If no row is found, the result is404. - If any orderline has a status other than
ANG,HALorSTO, the result is409. - If any orderline is on a pick list whose expiry date (
PLHexpiryDate) lies in the future, the result is409with the pick list message. This check runs last, so its message wins if both 409 conditions apply.
If a check fails, nothing is changed.
Deletion steps (inside one transaction):
- An
OrderHistoryentry with statusNEWand employeeAPIis written for each orderline. - The orderlines are not physically deleted but detached and reset:
OrderNr,CustRef,AddrRef,ShipAdrRefbecome0,StatusbecomesNEW,UpdateEmpbecomesAPI, quantity, prices, amounts, discounts, tax and shipping cost are set to0, andItemRef,ShipRef,Order_Id,BundleOrderlineRefare set to NULL. - Bundle orderlines (
BundleOrderlines) referenced by the orderlines are deleted. - Order header attributes (
OrderHeaderAttribute) are deleted. - Stock reservations (
Reservation) of the orderlines are deleted. - The customer account event linked to the order's bank match is deleted via
Pixi_CA_DeleteEvent(this may also delete the related invoice, bank matches, customer account matches, DTAUS records or manual bookings). - Finally
Pixi_DeleteEmptyOrderdeletes pick list check entries, tag matches, remaining header attributes and the order header itself.
On success the status row contains 200 and a confirmation text. Unexpected SQL errors are logged and returned as 500 with the SQL error message.
Notes
- The candidate data is read with
NOLOCK; changes useROWLOCK.XACT_ABORTis on. If the caller already has an open transaction, a savepoint is used instead of a new transaction. CONTEXT_INFOis temporarily set to suppress the triggers onOrderlinesandReservation; trigger logic for these changes therefore does not run.- Pitfall: the procedure creates a unique index on the orderline key of the candidate data. If an orderline appears more than once in the joined data (e.g. several bank matches for the order, or the line is contained in several pick lists, including expired ones), the index creation fails and the call returns
500. - Only one customer account event is deleted (
TOP 1without sort order) even if several bank matches exist. Whether it may be deleted is decided byfPixi_CA_canIdeleteEvent, and invoices are removed byPixi_DeleteInvoice; both are not attached, so their exact behaviour is not documented here. Pixi_CA_DeleteEventrolls back the whole transaction on error and re-raises the message, which then comes back as status500.- Errors inside
Pixi_DeleteEmptyOrderare logged there vialog.InsertErrorand not re-raised. - A 404 or 409 result still opens and commits an empty transaction.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
OrderNr
Required
|
int | – |
Number of the order (Auftrag) to delete ( Example: |
Result set 1 · Always (exactly one row)
Status row with the outcome of the call.
| Column | Type | Description |
|---|---|---|
Status
|
varchar(3) string |
|
ErrorMsg
Nullable |
varchar(2000) string |
Confirmation or error text. |
Response example
<SqlRowSet1>
<row>
<Status>200</Status>
<ErrorMsg>Order with OrderNr: 100234 was deleted.</ErrorMsg>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| 404 | Order with OrderNr: {OrderNr} was not found. | No order header exists with the given `OrderNr`. Check the order number. |
| 409 | Order can only be deleted when all orderline statuses are in ("ANG","HAL","STO"). | At least one orderline has a status other than `ANG`, `HAL` or `STO`. Change the orderline statuses first. |
| 409 | Order is already on active picklist. | At least one orderline is on a pick list that has not expired yet. Remove the lines from the pick list first. |
| 500 | Pixi_CA_DeleteEvent: deleting of DTAUS record not allowed | The customer account event of the order belongs to a DTAUS record whose state does not allow deletion. The whole deletion is rolled back. |
| 500 | {ERROR_MESSAGE()} | Any other SQL error during deletion, e.g. a duplicate orderline key when creating the unique index on the candidate data. The error is logged and the transaction is rolled back. |
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:pixiDeleteOrder>
<OrderNr>100234</OrderNr>
</ns1:pixiDeleteOrder>
</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:pixiDeleteOrder>
<OrderNr>100234</OrderNr>
</ns1:pixiDeleteOrder>
</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',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiDeleteOrder', $soapArguments);
- SQL object:
- dbo.pipiDeleteOrder