Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 2013-10-30
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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...
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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
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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
Simple Linear Regression
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 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