ZPL - How to embed GS1 application identifiers into GS1 QR code

3.1k views Asked by At

I'm trying to code a GS1-compliant QR Code in ZPL which will include a number of application identifiers:

VAR. COUNT     (30) 18099999
CUST. PART NO. (241) 1184174
BATCH/LOT      (10) MFATA00001
INTERNAL       (91) EA

I don't understand how to embed the FNC1 character within the ^FD string when using ^BQ to create a QR Code.

Below is my first attempt. When creating a GS1-128 barcode, I would use the >8 character to denote variable-length fields.

^FX Test^FS
^XA^MCY^XZ
^XA^LH0,65
^LH0,0^FS
^BQN,2,10^FD>;>83018099999>82411184174>810MFATA00001>891EA^FS
^PQ1,0,0,N
^XZ

This creates a QR Code that returns the following string when scanned, but is not recognised as GS1 compliant: 11611193018099999>82411184174>810MFATA00001>891EA

How do I configure the ^FD field to enable the FNC1 character?

3

There are 3 answers

0
mhub On

EdHayes3's answer is just great.

As specified by Zebra in a ^BX the escape character is the underscore and the subsequent number defines what kind of FNC is used.

    _1 - > FNC1
    _2 - > FNC2
    _3 - > FNC3

FNC4 is not supported according to how I understand the Zebra documentation.

The only thing I do not entirely agree with is escaping every GS1 AI since the most common ones except Lot/Batch number have a fixed length. In other words, I do not think that it is necessary to escape for example the GTIN. Though, you probably have to keep in mind to pad it up with leading zeros in case of GTIN-12 or GTIN-13.

5
EdHayes3 On

QR ZPL Issues

See a recent answer I had for QR codes here: Print ZPLII QR to open url

You are missing some of the parameters for the ^BQ and ^FD commands.

GS1 QR Issues

Research I've done indicates that the GS1 QR code is quite proprietary, and does not seem to be easily generated with ZPL. However, you can use a Data Matrix barcode quite easily.

Looks like you are trying to create a code with the following Application Identifiers and values:

30: Variable Count of Items: 18099999
241: Variable Customer Part Number: 1184174
10: Variable Batch/Lot Number: MFATA00001
91: Variable Company Internal: EA

GTIN 01 seems to be required and is missing. I've added a temporary GTIN string. Customer part number 241 seems to be local only, and may not validate in some applications which validate global requirements.

Full Barcode String.

^FD_10112345678901234_110MFATA00001_13018099999_12411184174_191EA^FS

Full ZPL for sample label

^XA
^FO10,10
^BXN,9,200,40,40,,_
^FD_10112345678901234_110MFATA00001_13018099999_12411184174_191EA^FS
^XZ

Hope that helps.

https://www.gs1.org/docs/barcodes/GSCN_16_477_FNC1.pdf https://www.zebra.com/us/en/support-downloads/knowledge-articles/creating-gs1-barcodes-with-zebra-printers-for-data-matrix-and-code-128-using-zpl.html

0
Terry Burton On

Per this document, you require ZPL firmware version 6.6 or later along with ZPL such as the following:

^XA
^FO10,10
^BQN,2,5
^FD>83018099999>82411184174>810MFATA00001>891EA^FS
^XZ

However there are reports that this fails and that it is currently impossible to reliably encode GS1 Application Identifier syntax data in ZPL...

With recent firmware, >8 appears to be sufficient to set the "FNC1 implied in first position" mode indicator in the encoded bitstream, which flags that GS1 AI syntax is in effect by modifying the Symbology Identifier to "]Q3" when the barcode is read. However, the same >8 character combination does not result in an FNC1 non-data character being encoded in the role of a separator following an AI that does not have a predefined length. (Neither does the escape sequence _1 which is used in a similar context with Datamatrix.)

Generic detail about FNC1 in QR Code

The internal encoding of QR Code does not have a distinct codeword (bit sequence) to represent the FNC1 non-data character. Instead, if (and only if) "FNC1 in first" mode is in effect, when in Alphanumeric Encodation the % character is hijacked to represent the FNC1 (with a data "%" character being escaped as %%), and in Byte mode a literal GS control character (ASCII value 29) is used to represent the FNC1:

"Where the UCC/EAN [former name for GS1] specifications call for the FNC1 character (in other symbologies which use this special character) to be used as a data field separator (i.e. at the end of a variable-length data field), QR Code symbols shall use the % character in Alphanumeric mode or character GS (byte value 1DHEX) in Byte mode to perform this function. If the % character occurs as part of the data it shall be encoded as %%. Decoders encountering % in these symbols shall transmit it as ASCII/JIS8 value 1DHEX, and if %% is encountered it shall be transmitted as a single % character." — ISO/IEC 18004:2015 §6.4.8.1

There isn't even a way to represent FNC1 in Numeric encodation (the most common encodation in effect at the end of most GS1 AI values) so it is necessary to switch encodations just to terminate the AI value. (QR Code is not an efficient carrier for GS1 AI syntax data!)

I suspect that the ZPL implementers have tied themselves in knots here because the actual bit sequence that must be inserted into the bitstream to encode FNC1 is entirely dependant on the encoding mode that is in effect at the time that a separator must be inserted, and to optimise the symbol size it is necessary to segment the message into a number of encodation sequences that are efficient for the data that they encode. (The optimal sequence depends on the data to encode, yet the data to encode depends on the current sequence.)