Quantity and unit: what a QTY segment says
The QTY segment carries a quantity. But "480" on its own means nothing: 480 pieces, 480 cartons, or 480 kilograms? The answer is in the segment's other two parts.
The structure
QTY+21:480:PCE'
| Part | Value | Meaning |
|---|---|---|
| Qualifier | 21 | This is the ordered quantity |
| Value | 480 | The quantity itself |
| Unit | PCE | Pieces |
Using the quantity without reading all three leads to real inventory errors.
The qualifier: which quantity?
A file can contain several QTY segments, each answering a different question:
| Code | Meaning |
|---|---|
21 | Ordered quantity |
12 | Despatched quantity |
47 | Invoiced quantity |
194 | Received quantity |
152 | Quantity sold (in a sales report) |
59 | Number of units per pack |
Along an order chain these codes follow one another: 21 is ordered, 12 is despatched, 194 is received, 47 is invoiced. The differences between them are where most commercial disputes begin.
In a receiving advice, for instance, two lines sit side by side:
QTY+12:100:PCE'
QTY+194:96:PCE'
One hundred were despatched, ninety-six accepted. The gap of four means damage or a short delivery, and is usually explained in an FTX line.
Unit codes
Units come from UN/ECE Recommendation 20. The common ones:
| Code | Meaning |
|---|---|
PCE | Piece |
KGM | Kilogram |
LTR | Litre |
MTR | Metre |
CT | Carton |
PA | Pack |
CS | Case |
One thing to watch: the same product can appear in different units on different lines. An order may be placed in CT (cartons) and invoiced in PCE (pieces). The conversion factor lives in your product master data, not in the EDI file.
The decimal separator trap
If a quantity has decimals, the UNA segment says which character is the decimal mark. The default is .:
QTY+21:12.5:KGM'
But if UNA set the third character to ,, the file will contain 12,5. Code that assumes a fixed decimal mark will either crash or misread the number.
EDIFACT also uses no thousands separator. 1.234 is not one thousand two hundred and thirty-four; it is one point two three four.
Negative quantities
A quantity can be negative, which is normal on returns and correction documents:
QTY+21:-12:PCE'
The minus sign precedes the value. Systems that store quantities as unsigned integers silently record the wrong figure here.
Checklist
1. Read the qualifier — 21 and 12 are very different things 2. Carry the unit with the value; never separate them 3. Take the decimal mark from UNA 4. Allow negative values
To see what each quantity in a file means, the quickest route is a viewer that translates the qualifier and unit code into plain text.