Zebra ZPL-II Code 128 barcode with 3 Application Identifiers, including Serial Number

Posted on 2013-10-30
Last Modified: 2013-12-11

I'm working on a label that goes on cases of our product, and the barcode needs to be Code 128 and have 3 elements:

  - GTIN (Application Identifier 01)
  - Batch Number (Application Identifier 10)
  - Serial Number (Application Identifier 21)

In particular, I'm having trouble with the Serial Number. We print thousands of these labels at a time, and the .prn files our software is generating are huge because it transmits multiple lines of code for each label.

I know the Zebra printers we use (140XiIII Plus) are capable of incrementing serial fields internally, which means that the software could send a tiny file with one copy of the label plus a quantity to print, and just let the printer increment the serial numbers. However, I can't figure out the correct syntax to make that work.

Here is a sample line in ZPL-II code that our software currently generates for the barcode:


I'm thinking that what I want is something like this (but this doesn't work):


Can anyone provide the correct syntax?
Question by:spice_guy
  • 4
  • 3

Expert Comment

ID: 39674483
maybe zint can help
LVL 19

Expert Comment

ID: 39697735
To initiate automatic serialization use combination of ^FD (Field Data) and ^SF (Serialization Field) commands and define fixed and variable parts of your serial number.

Referring to this please see page 250 in
ZPL II Programming Guide Volume One

Exercise 2. shows how to use ^FD and ^SF commands to define part of your barcode content which needs to be incremented...
LVL 19

Expert Comment

ID: 39697747
Which part of your barcode data ">;>80140012345012349101328>69C>5>82115300000>61" is the variable part that needs to be incremented?

To make this clear please break down your serial data string into its elements...

Author Comment

ID: 39699006
Thanks for the responses! The last 5 digits are what need to be incremented, starting with "00001" and increasing by 1 on every label.

Later today I will try the commands you mention in your first post and let you know the results.

Here's the breakdown you requested of all the different parts in my command string:

^BY                        Bar Code Field Default Instruction
2                            (Parameter) Narrow Bar width = 2 dots
^BC                        Bar Code 128
B,                           (Parameter)  Orientation = rotated 270 degrees
160,                       (Parameter) Height = 160 dots
N,                           (Parameter) Print Interpretation Line = no
N                            (Parameter) Inverted = no
^FD                        Field Data
>;                           Start Code 128 Subset C
>8                          FNC1
01                          Function Code 01 (Global Trade Item Number or GTIN)
40012345012349 Value for GTIN
10                          Function Code 10 (Lot ID)
1328>69C             Lot ID (note that only "13289C" prints - the ">6" changes to Subset B
                                    in order to handle the alpha character.)
>8                          FNC1
21                          Function Code 21 (Serial Number)
115300000>61    Serial number (the "115300" is static and "00001" is the part that
                                    increments. The ">6" changes to Subset B for the last digit
                                    because Subset C requires pairs of digits)
^FS                        Field Separator
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

LVL 19

Expert Comment

ID: 39700306
Is it a four-digit or five-digit counter????

Something seems to be wrong with your above serial number description!

According to your description the serial number should be 1153000000>61, but your serial number example preceded by FNC1 and function code 21 says ">82115300000>1" with one missing digit for the static part and one for the variable part...

And what about the >5 in your example preceding the second FNC1?
LVL 19

Accepted Solution

Thommy earned 500 total points
ID: 39700409
According to your serial number data breakdown with a five-digit counter, your ^FD/^SF  commands should look like that...


Author Comment

ID: 39702517

I apologise for multiple errors that I made in my example, and I want to thank you for all the time you are taking to look at this in great detail.

  - The serial number should really have 4 static digits ("1153") and 5 variable digits ("00001").
     I'm afraid I got that wrong everywhere (and in different ways in different places).

  - The ">5" that I accidentally excluded from my breakdown would have forced a change to Subset C.

I still have not had time to try the commands you have provided, but I will get to them as quickly as I can and post the results.

Thanks again for all your time!

Author Comment

ID: 39713020

Your final suggestion worked! I had to tweak it a little bit for a couple of reasons.

First, my printer would not accept the lower-case "d" but was willing to accept the mask when I changed those to the upper-case "D".

Second, apparently it is important to make sure the length of the mask you provide in the ^SF string is EXACTLY the same length as your ^FD string. Your example had one extra "%". Note that you do need to include mask characters for the non-printable information such as the ">8" FNC1 characters.

Third, you need to put the ^FS (Field Separator) command at the end of the "^SF" string.

Here are my final strings (the ^SF one is so long it may wrap to another line):

Thanks, and I will award full points to your final answer!

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When I recently replaced my image transfer kit on my office HP color laserjet 5550dn printer, I had a slight problem.  The left bracket that holds the transfer kit got stuck in the upright locked position instead of being at a 45 degree angle facing…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now