Pages

Wednesday, September 10, 2014

Barcodes and GS1 Application Identifiers

Recently I looked at the case study of Alice and Bob running a lemonade stand, and how their choice of product barcode was negatively impacting their stock management system.  In this post we'll look at a couple of barcodes that can be used to overcome this problem.

To fully understand the issues involved I suggest reading my previous post, but to sum things up, the barcode symbology they were using only encoded the price of the product and not the volume.  This caused errors in the stock management system because it inferred the volume by dividing the price by the price per volume.  It seems logical, but in a certain situations things can go wrong.

To solve their problem Alice and Bob came up with the idea of encoding the product volume in the barcode as well, and as it turns out other people have encountered this problem before and have already devised a solution.  GS1 have a released a standard defining a set of numerical application identifiers that refer to a specific product attribute and the format of the data that it refers to.  There are over a 100 different attributes that can be encoded.  When printed in human readable form, the application identifier is surrounded by brackets followed by data. For example, 10 is the application identifier for encoding a batch or lot number and can hold up to 20 alphanumeric characters.

(10)a0b1c2d3e4f5g6h7i8j9

Application identifiers can be chained together to create a GS1 element string which can then be encoded into a barcode.  The first thing that needs to be done is to decide what data will be recorded in the barcode.  Alice and Bob look at their existing labels to consider what to encode.

Product label
Old EAN-13 label

There are five different pieces of information on the label

1. Item type
2. Best Before Date
3. $/L
4. Volume (L)
5. Price

It's decided that encoding most of this information will be beneficial.  Everything but the $/L will be recorded as it can be derived from the other information and isn't needed for an accurate stock management system.  They go through the list of available application identifiers and choose 4 that will encode all of this data in a standardised way.

(01) Global Trade Item Number (GTIN)

The GTIN provides manufactures with a way to assign globally unique identifiers for their products.  This removes ambiguity between product identifiers.  The field for a GTIN is exactly 14 digits in length and is a unique reference to what the product, is and is made up of several components.

The first digit is an indicator digit.  There appears to be some confusion about what this digit should be for a variable measure trade item scanned at point of sale.  There are quite a few sources that say it should be 9, but the latest GS1 general specification released in January 2014 indicates that only applies to items not scanned at a point of sale.  For POS scannable items it should be zero.  I'm not 100% sure what it should be, but zero seems to be correct according to the latest standard.

The next 12 digits are the company prefix and the item reference.  The company prefix is assigned to your company when you apply for one, and the item reference is assigned by the company itself.  The length of each will depend on how the GS1 member organisation in a particular area assigns company prefixes.  For example, since 1996, Australian company prefixes are 9 digits long.  This leaves 3 digits for the item reference.

The first three digits of the company prefix are the country prefix, and identify the GS1 member organisation that assigned the company prefix.  In this case it's 930, indicating Australia, as it's responsible for country prefixes 930 to 939.

The last digit is a modulo 10 check digit.  In this case that's equal to 2.
GTIN-14
GTIN-14 breakdown

So the first part of the GS1 element string that Alice and Bob are going to use on their lemonade is

(01)09303141590012


(15) Best Before Date

Application identifier 15 encodes the best before date of the product, and although it isn't essential to have for a stock management system, it has other uses.  For example, when in use, a customer will never be able to buy an out of date product because it'll be flagged at the point of sale, the item can then be replaced with a newer one.  It could also allow automatic repricing of products for clearance and promotional purposes.  The format of this application identifier is basic, it holds 6 digits and is of the form YYMMDD.  So in this case the next part of the lemonade GS1 element string for the best before date 10/10/2014 will be

(15)141010


(315x) Net Volume Litres

This application identifier is a little different. 315x is the application identifier for encoding the number of litres in a product.  The last digit (x) of this application identifier indicates at what position to put a decimal place in the following data.  It's six digits long.  So for the lemonade label above with 1.521 L on it, the next part of the GS1 element string will be

(3153)001521


(392x)  Amount Payable For a Variable Measure Trade Item

Unlike the other application identifiers encountered so far, the length of the Amount Payable is variable and can be 1 to 15 digits long.  It also uses the last digit of the application identifier to encode where a decimal point is placed in the following data.  The price of this bottle is $3.02 and will be encoded in the GS1 element string as follows.

(3922)302


Encoding the GS1 Element String

Alice and Bob now have all the components of their GS1 element string, and when written it will look like this.

(01)09303141590012(15)141010(3153)001521(3922)302

That's all great, but it's not a barcode.  The next step is to pick a symbology to encode this data.  Alice and Bob look at three different symbologies to use on their labels.


GS1-Databar Expanded

Databar used to be known as reduced space symbology (RSS) but has since changed its name. It allows much more data to be stored, improving traceability and stock management.  There are few quirks to encoding the element string in a Databar-Expanded barcode, but all good software packages should mange this transparently without the user ever knowing.  For example, the above element string can be encoded using zint barcode software to give the following barcode.

barcode
GS1-Databar Expanded

If you're playing along at home you may or may not be able to read this barcode from the screen using a phone.  It all depends on your screen resolution.  It's a good starting point.  All the data is encoded in the barcode, but it is rather wide.  It would be great if there was another option.


GS1-Databar Expanded Stacked

Due to space limitations a stacked version of the previous version was needed.  It splits the barcode up into shorter pieces and stacks them on top of each other.  It's not as simple as just splitting the original into small pieces, the information is re-encoded in a different way.  The following barcode was made using an online generator from the site www.terryburton.co.uk/barcodewriter/generator/.  It was the only one that was able to reliably create a barcode that could be decoded.  Zint was able to produce a stacked barcode as was RSSENC from GS1, but there weren't any scanners that could reliably decode them.

barcode
GS1-Databar Expanded Stacked
The scanner app from zxing was able to reliably decode this type of symbology once the exposure control was altered.  Below is the result of scanning the barcode above.

scanned barcode
GS1-Databar Expanded Stacked scan result

Technically GS1-Databar Stacked Expanded is capable of being scanned by a 1D laser scanner, but the scan line has to be swept over the barcode to read all parts of it.  Not ideal but it works.  The key to reading this type of code is that all of the sub barcodes need to be read and reassembled by the scanner in software.  An omnidirectional scanner is fine for this, as is a high quality 2d scanner.  However If we need a 2D scanner why not go for a 2D barcode?


GS1 DataMatrix

This one is just purely theoretical because it's a 2D barcode.  The last two barcode symbologies are cleared for scanning at a point of sale according to the GS1 specification, this one isn't because it requires the use of a 2D imaging scanner.  It's included because in my opinion it's likely that it will be in the future (and it's such an elegant solution).

Retailers are starting to see the advantages a 2D imaging scanner has.  It allows dense bar codes to be read from phone screens or promotional material, and having an imaging scanner also allows identification to be scanned at point of sale when people are buying restricted products like mobile phones.  The technology is available right now.  The NCR Realscan 78 Hybrid scanner uses a combination of laser scanning and imaging techniques to scan 1D and 2D barcodes.  It's capable of scanning GS1-Databar and GS1-Datamatrix symbologies fast and reliably.

NCR Realscan 78


So what does a 2D datamatrix code look like.

barcode
GS1-Datamatrix

The above datamatrix encodes the GS1 element string that Alice and Bob are using to label their lemonade.  In addition to being easy to scan, datamatrix codes also carry error correction coding that make the code more resilient.

Now that they have a barcode it can be compared with the old label.

product label
Barcode comparison

The new datamatrix code has the GS1 element string under it in a human readable form, this allows it to be entered into a computer if the symbol is damaged.  Even that's less likely with a symbology like datamatrix.  A lot of bar codes for variable volume products are printed by an array of printer elements.  It's not uncommon for part of the printhead to fail or become covered in dirt leaving an unprinted stripe down the printout that makes traditional barcodes unreadable while datamatrix codes can still be read. The image below demonstrates this with a vertical white line through each label.  It's visible starting at the a in the word lemonade.

product label
Damaged barcodes

The printhead failure causes the first barcode to be unreadable, while depending on the quality of the reader used the Datamatrix code will be easily read.


Conclusions

Alice and Bob have some decisions to make, GS1 have been aiming for 2014 as the adoption goal for Databar, so it's likely that any recent POS equipment will be able to scan databar expanded and databar expanded stacked.  So their current equipment might be able to scan these symbologies.  By using either of these barcodes they'll be able to improve the integrity of their stock management system while taking advantage of the other features offered.  The food safety benefits of encoding the best before date in the barcode is a compelling reason to further investigate this option.  It also allows the system to monitor things like how well stock is being rotated.  Ideally stock should be sold on a first in first out (FIFO) basis.  The order that stock is sold can be recorded by monitoring the  use by dates that go through the point of sale.

Now that the volumes going through the registers are accurate, they can be used to calculate metrics, such as average bottle volume, this can be fed back into the stock management system to detect errors introduced through other means.  For example if the average bottle of lemonade is 1 Litre and the stock management system says there are 10 bottles with a total volume of 2 Litres you know there's something wrong and the counts need to be investigated.

The benefits are indisputable, it just comes down to how much the barcode migration and initial set-up will cost.  It may or may not be the right fit for their business at the current time, but Alice and Bob should keep it in mind as a long term goal when purchasing or investing in future infrastructure.


Note:

I should make it clear that all labels and barcodes generated for this post are just to illustrate a point.  If you were to actually design a label there are many more things to pay attention to.  Guard spaces, barcodes sizes, and font placement are a couple that spring to mind.

2 comments:

  1. Hi.

    Thanks for an excellent article and I'm glad that you found my online barcode generator to be accurate and useful.


    All the best,

    Terry Burton

    ReplyDelete

Note: Only a member of this blog may post a comment.