pixiCreateItemSupplier
Creates a new supplier assignment (AddItems record) for an existing item, optionally with its own EAN and as preferred supplier.
Adds a supplier to an item by inserting a row into AddItems. The call returns exactly one status row (Status, Message).
Steps:
- Supplier check:
SupplNris mandatory. An empty string counts as missing. The supplier must exist inSuppliers. - Item identification: the item is resolved from
ItemKey,EAN(barcode, code type 1) and/orItemNrInt(shop item number, code type 2) throughpixi.ItemCode. At least one of them is required. If several are given, all of them must point to the same item. Each given value must be found. - NewEAN check: if
NewEANis given, it must not exist as a code of a scannable code type on any other item. - EAN of the new record: the EAN stored on the new supplier record is
NewEAN. If that is empty,EANis used. If both are empty, the item'sEANUPCfromitemsis used.ItemNrInt(if not given),IntLinkNR1,IntLinkNRand the salesPriceare taken from the item. - Duplicate check: if the item already has a barcode entry in
pixi.ItemCodewith this EAN for this supplier, the call stops with an error. - Preferred supplier: if
PreferredSupplier= 1, the item's current preferred supplier record (one record,TOP (1)) is reset toPreferredSupplier= 0 first. - Insert: a new
AddItemsrow is created. It getsSupplPrice,ItemNrSuppl,SupplDeliveryTime(=ItemDeliveryTime),MinOrderQty,OrderOnlyPackageUnits(=OnlyPU),Active(=IsActive) andPreferredSupplier.AutoPriceis set to 0 andCreateDateto the current time.
On success the status is New record inserted. The message lists the stored supplier price, supplier item number and EAN.
Notes
- All errors are returned as a normal row with
Status=Error; noRAISERRORis used. - The reset of the old preferred supplier and the insert run in a transaction. If the call is already inside a transaction, a savepoint is used instead.
- On an exception the transaction is rolled back and the error is logged via
log.InsertError. The SQL error text is then returned inMessage. - Lookups use
NOLOCK, so uncommitted data may be read. - The duplicate check reads
pixi.ItemCode, notAddItems. Whetherpixi.ItemCodeis kept in sync withAddItems(e.g. by triggers) is not visible in this code. - If no EAN can be determined at all (no
NewEAN, noEAN, item withoutEANUPC), the duplicate check never matches. The record is then inserted with an empty EAN. NewEANonly sets the EAN of the new supplier record. The item's main EAN initemsis not changed.ItemNrIntis not converted from an empty string to NULL. Sending an emptyItemNrInttogether with another identifier stores an emptyItemNrInton the new record.ItemDeliveryTimeis not replaced by 0 when NULL is sent explicitly.- Only one previously preferred record (
TOP (1)) is reset. Other records flagged as preferred remain unchanged.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
ItemKey
|
int | NULL |
Item key used to identify the item. 0 is treated as not given. Example: |
ItemNrInt
|
varchar(50) string |
NULL |
Shop item number used to identify the item (code type 2). If omitted, the item's own Example: |
EAN
|
varchar(13) string |
NULL |
Barcode used to identify the item (code type 1). It is also stored as the EAN of the new record if Example: |
NewEAN
|
varchar(13) string |
NULL |
EAN to store on the new supplier record. It must not exist as a scannable code on another item. Example: |
SupplNr
Required
|
varchar(4) string |
– |
Supplier number (mandatory). It must exist in Example: |
SupplPrice
|
money decimal |
0 |
Purchase price from this supplier. NULL becomes 0. Example: |
ItemNrSuppl
|
varchar(50) string |
NULL |
Supplier's item number. An empty string is stored as NULL. Example: |
PreferredSupplier
|
bit boolean |
0 |
Marks the new record as preferred supplier. The previous preferred supplier record is reset first. Allowed values
Example: |
MinOrderQty
|
int | 0 |
Minimum order quantity. NULL becomes 0. Example: |
OnlyPU
|
bit boolean |
0 |
Order only in package units. Stored in Allowed values
Example: |
ItemDeliveryTime
|
int | 0 |
Supplier delivery time. Stored in Example: |
IsActive
|
bit boolean |
1 |
Whether the supplier record is active. NULL becomes 1. Allowed values
Example: |
Response
Result set 1 · Always (exactly one row: success or error)
Status row of the call.
| Column | Type | Description |
|---|---|---|
Status
|
varchar(19) string |
|
Message
Nullable |
nvarchar(4000) string |
On success, the stored supplier price, supplier item number and EAN. Otherwise the error text. |
Response example
<SqlRowSet1>
<row>
<Status>New record inserted</Status>
<Message>SupplPrice:12.50, ItemNrSuppl:SUP-4711, EAN:4006381333931</Message>
</row>
</SqlRowSet1>
Error messages
| Status | Message | Cause |
|---|---|---|
| Error | Parameter @SupplNr is mandatory. | `SupplNr` was not sent or is empty. |
| Error | Supplier with SupplNr:{SupplNr} does not exist. | No supplier with this number exists in `Suppliers`. |
| Error | Please specify at least one parameter. | None of `ItemKey`, `EAN` or `ItemNrInt` was given. |
| Error | No items found with given parameters. ItemKey: {ItemKey} not found. | The given `ItemKey` has no entry in `pixi.ItemCode`. |
| Error | No items found with given parameters. EAN: {EAN} not found. | The given `EAN` is not a barcode (code type 1) of any item. |
| Error | No items found with given parameters. ItemNrInt: {ItemNrInt} not found. | The given `ItemNrInt` is not a shop item number (code type 2) of any item. |
| Error | More than one item was identified with the given parameters. | The given identifiers point to different items. Send identifiers that belong to the same item. |
| Error | The @NewEAN code {NewEAN} already exists on another scannable item. | `NewEAN` is already used as a scannable code on another item. |
| Error | Item with EANUPC: {EAN} and Supplier number "{SupplNr}" already exists. | The item already has this EAN registered for this supplier. |
| Error | {ERROR_MESSAGE()} | An SQL error occurred while updating or inserting `AddItems` (e.g. a constraint violation). The transaction is rolled back and the error is logged. |
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:pixiCreateItemSupplier>
<!-- <ItemKey>10452</ItemKey> -->
<!-- <ItemNrInt>SHOP-10452</ItemNrInt> -->
<!-- <EAN>4006381333931</EAN> -->
<!-- <NewEAN>4006381333948</NewEAN> -->
<SupplNr>L001</SupplNr>
<!-- <SupplPrice>12.50</SupplPrice> -->
<!-- <ItemNrSuppl>SUP-4711</ItemNrSuppl> -->
<!-- <PreferredSupplier>1</PreferredSupplier> -->
<!-- <MinOrderQty>10</MinOrderQty> -->
<!-- <OnlyPU>0</OnlyPU> -->
<!-- <ItemDeliveryTime>5</ItemDeliveryTime> -->
<!-- <IsActive>1</IsActive> -->
</ns1:pixiCreateItemSupplier>
</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:pixiCreateItemSupplier>
<!-- <ItemKey>10452</ItemKey> -->
<!-- <ItemNrInt>SHOP-10452</ItemNrInt> -->
<!-- <EAN>4006381333931</EAN> -->
<!-- <NewEAN>4006381333948</NewEAN> -->
<SupplNr>L001</SupplNr>
<!-- <SupplPrice>12.50</SupplPrice> -->
<!-- <ItemNrSuppl>SUP-4711</ItemNrSuppl> -->
<!-- <PreferredSupplier>1</PreferredSupplier> -->
<!-- <MinOrderQty>10</MinOrderQty> -->
<!-- <OnlyPU>0</OnlyPU> -->
<!-- <ItemDeliveryTime>5</ItemDeliveryTime> -->
<!-- <IsActive>1</IsActive> -->
</ns1:pixiCreateItemSupplier>
</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' => 'SHOP-10452',
// 'EAN' => '4006381333931',
// 'NewEAN' => '4006381333948',
'SupplNr' => 'L001',
// 'SupplPrice' => '12.50',
// 'ItemNrSuppl' => 'SUP-4711',
// 'PreferredSupplier' => '1',
// 'MinOrderQty' => '10',
// 'OnlyPU' => '0',
// 'ItemDeliveryTime' => '5',
// 'IsActive' => '1',
];
$soapArguments = [];
foreach ($arguments as $name => $value) {
$soapArguments[] = new SoapVar($value, XSD_STRING, '', '', $name);
}
$response = $soapClient->__soapCall('pixiCreateItemSupplier', $soapArguments);
Tables used
- SQL object:
- dbo.pipiCreateItemSupplier