pixiSetItemSupplier
Creates or updates the supplier assignment (AddItems row) of an item, including supplier price, supplier item number, EAN and order settings.
Maintains the supplier data of an item in AddItems for the supplier given in SupplNr.
Validation
ItemKey = 0and empty strings inEAN,ItemNrSupplandItemNrIntare treated as NULL.- If both
ItemKeyandItemNrIntare passed, they must belong to the same item initems. - The supplier
SupplNrmust exist inSuppliers. - At least one of
ItemKey,EAN,ItemNrSupplorItemNrIntmust be passed.
Identifying the item
The item is searched in the existing AddItems rows (joined with items). A row matches if any of these is true:
ItemRef = ItemKeyEANUPC = EANItemNrInt = ItemNrIntItemNrSuppl = ItemNrSupplandSupplNr = SupplNr
Exactly one distinct item must be found; otherwise an error row is returned.
- With
AddEAN = 0, it is an error if more than one matchingAddItemsrow exists for the given supplier. - With
AddEAN = 1, a warning is returned if a row with the sameEANand supplier already exists.
Writing
- If
PreferredSupplier = 1,PreferredSupplieris first reset to 0 on allAddItemsrows of the item, so only one row stays preferred. - If
AddEAN = 0and a matchingAddItemsrow of that supplier exists, the oldest one (lowestUpdateDate) is updated. Parameters that are not passed keep the existing values; for price, supplier item number and EAN the item master values are used as fallback. The call returnsRecord updated. - Otherwise (no row for this supplier yet, or
AddEAN = 1), a newAddItemsrow is inserted. Values come from the parameters, with fallback to the item master (EANUPC,ItemNrSuppl,SupplPrice).ItemNrInt,IntLinkNR1,IntLinkNRandPriceare copied from the item, andAutoPriceis set to 0. The call returnsNew record inserted.
The call always returns exactly one status row with Status and Message.
Notes
- The item must already have at least one
AddItemsrow. The lookup only searchesAddItems, so an item without any supplier row returnsNo items found with given parameters., even ifItemKeyis valid. - With
AddEAN = 1and a new EAN, the item can only be identified through an existing value. PassItemKeyorItemNrInt, because the new EAN cannot be found inAddItemsyet. - The search conditions are combined with OR. Passing several identifiers that point to different items leads to
More then one item was identified .... - When a new row is inserted,
MinOrderQtyandSupplDeliveryTimetake only the passed values (NULL if omitted).OrderOnlyPackageUnitsandPreferredSupplierdefault to 0. - In the success message, NULL values are not handled. If the resulting
ItemNrSupplorEANUPCis NULL,Messageis NULL. - Writes run in a transaction. If the caller already has an open transaction, a savepoint is used instead. On error the changes are rolled back, the error is logged via
log.InsertError(definition not attached) and anErrorrow with the SQL error text is returned. - Reads use
NOLOCK; updates useROWLOCK.
Tables used
| Parameter | Type | Default | Description |
|---|---|---|---|
ItemKey
|
int | NULL |
Internal key of the item ( Example: |
ItemNrInt
|
varchar(50) string |
NULL |
Internal item number. If Example: |
SupplNr
Required
|
varchar(4) string |
– |
Supplier number. It must exist in Example: |
SupplPrice
|
money decimal |
NULL |
Purchase price at the supplier. If omitted, the existing value is kept; for a new row the item master price is used. Example: |
EAN
|
varchar(13) string |
NULL |
EAN/UPC. It is used to find the item and is stored in Example: |
ItemNrSuppl
|
varchar(50) string |
NULL |
Supplier's item number. It is used for the lookup only together with Example: |
AddEAN
|
bit boolean |
0 |
If 1, a new Allowed values
Example: |
PreferredSupplier
|
smallint int |
NULL |
Preferred supplier flag. With 1, all other Allowed values
Example: |
MinOrderQty
|
int | NULL |
Minimum order quantity at the supplier. If omitted, the existing value is kept; a new row gets NULL. Example: |
OnlyPU
|
bit boolean |
NULL |
Order only in package units ( Example: |
ItemDeliveryTime
|
int | NULL |
Supplier delivery time ( Example: |
Result set 1 · Always; exactly one status row (error, warning, update or insert result).
Status row describing the outcome of the call.
| Column | Type | Description |
|---|---|---|
Status
|
varchar(19) string |
|
Message
Nullable |
varchar string |
Error text, or on success the stored values in the format |
Response example
<SqlRowSet1>
<row>
<Status>Record updated</Status>
<Message>SupplPrice:12.50 ItemNrSuppl:LF-4711 EANUPC:4006381333931</Message>
</row>
</SqlRowSet1>
| Status | Message | Cause |
|---|---|---|
| Error | ItemNrInt {ItemNrInt} not match to ItemKey {ItemKey} | `ItemKey` and `ItemNrInt` were both passed but do not belong to the same item. Pass only one of them or correct the values. |
| Error | Supplier with SupplNr:{SupplNr} does not exist. | No supplier with the given `SupplNr` exists in `Suppliers`. |
| Error | Please specify at least one parameter. | None of `ItemKey`, `EAN`, `ItemNrSuppl`, `ItemNrInt` was passed. |
| Error | More then one item was identified with the given parameters. | The identifiers match several items, or (with `AddEAN = 0`) several `AddItems` rows of the same supplier. Use a more specific identifier such as `ItemKey`. |
| Warning | Item with EANUPC: {EAN} and Supplier number "{SupplNr}" already exists. | With `AddEAN = 1`, an `AddItems` row with this EAN and supplier already exists, so nothing is inserted. |
| Error | No items found with given parameters. | No `AddItems` row matches the identifiers. This also happens if the item exists but has no `AddItems` row yet. |
| Error | {ERROR_MESSAGE()} | A SQL error occurred while updating or inserting. The transaction is rolled back and the error is logged. |
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:pixiSetItemSupplier>
<!-- <ItemKey>10452</ItemKey> -->
<!-- <ItemNrInt>ART-100245</ItemNrInt> -->
<SupplNr>L001</SupplNr>
<!-- <SupplPrice>12.50</SupplPrice> -->
<!-- <EAN>4006381333931</EAN> -->
<!-- <ItemNrSuppl>LF-4711</ItemNrSuppl> -->
<!-- <AddEAN>0</AddEAN> -->
<!-- <PreferredSupplier>1</PreferredSupplier> -->
<!-- <MinOrderQty>10</MinOrderQty> -->
<!-- <OnlyPU>0</OnlyPU> -->
<!-- <ItemDeliveryTime>5</ItemDeliveryTime> -->
</ns1:pixiSetItemSupplier>
</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:pixiSetItemSupplier>
<!-- <ItemKey>10452</ItemKey> -->
<!-- <ItemNrInt>ART-100245</ItemNrInt> -->
<SupplNr>L001</SupplNr>
<!-- <SupplPrice>12.50</SupplPrice> -->
<!-- <EAN>4006381333931</EAN> -->
<!-- <ItemNrSuppl>LF-4711</ItemNrSuppl> -->
<!-- <AddEAN>0</AddEAN> -->
<!-- <PreferredSupplier>1</PreferredSupplier> -->
<!-- <MinOrderQty>10</MinOrderQty> -->
<!-- <OnlyPU>0</OnlyPU> -->
<!-- <ItemDeliveryTime>5</ItemDeliveryTime> -->
</ns1:pixiSetItemSupplier>
</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 = [
// 'ItemKey' => '10452',
// 'ItemNrInt' => 'ART-100245',
'SupplNr' => 'L001',
// 'SupplPrice' => '12.50',
// 'EAN' => '4006381333931',
// 'ItemNrSuppl' => 'LF-4711',
// 'AddEAN' => '0',
// 'PreferredSupplier' => '1',
// 'MinOrderQty' => '10',
// 'OnlyPU' => '0',
// 'ItemDeliveryTime' => '5',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiSetItemSupplier', $soapArguments);
- SQL object:
- dbo.pipiSetItemSupplier