Advice for printing UCC/EAN-128 bar codes

We have an easy to remember email address, especially for people that are new to the subject of printing UCC-128 and EAN-128 bar codes; help@UCC-128.com or help@EAN-128.com. DE Sie können auf Deutsch schreiben. ES Puede escribir en español. FR Vous pouvez écrire en Français. IT Può scrivere in Italiano. PT Você pode escrever em português.

The advice below should be all you need.

Note: If you have purchased our product, then our expert support staff are even willing to provide specific examples, solutions or advice for your application.

Here is a complete list of AI's; UCC/ EAN-128 Application Identifiers (AI) list current as of June, 1995

What is UCC/EAN-128?

UCC/EAN-128 is actually more of an application standard, than a bar code standard. UCC/EAN-128 governs the format of data messages, based on the principle of adding a known prefix to every type of meaningful piece of data.

For example, when the prefix 15 (which means Sell By Date) is followed by 031225, the complete message 15031225 means the Sell By Date is 25th December 2003. Any organisation, anywhere in the world, can read the UCC/EAN-128 bar code and decode its UCC/EAN-128 meaning.

What are UCC/EAN-128 bar codes?

UCC/EAN-128 bar code symbols are actually simply Code 128 bar code symbols that begin with the special Code 128 character FNC1. This initial FNC1 character allows hardware devices (bar code readers) to discriminate between regular Code 128 bar codes and UCC/EAN-128 bar codes.

Note: Do not use the CIAXCOM_CODE128 function to create UCC/EAN-128 bar code symbols, use CIAXCOM_UCC128 and CIAXCOM_EAN128 instead; because these functions will automatically add the FNC1 at the beginning.

When a UCC/EAN-128 bar code contains a single SSCC-18 there is a special function to handle this, see SSCC-18 below.

SSCC-18

Unique shipments are usually identified by an SSCC-18 number. An SSCC-18 number can be encoded using 00 as the AI (Application Identifier).

Worked example - a single AI (Application Identifier) field containing an SSCC-18 number

This example assumes a form contains an alpha field [Shipments]ShipmentNo, containing an SSCC-18 number.

Follow this example and substitute your application's table and field names.

To the form add a variable field with these properties;

Type Variable
Object Name Variable1
Variable Name Variable1
Variable Type Alpha
Object Method

Edit...

Click the Edit... button and set the Object Method to the following;

Variable1 := CIAXCOM_SSCC18 ( [Shipments]ShipmentNo )

Select the variable field, choose the menu Font | CIA Code 128. Then menu Style | 14 Points (if using font CIA Code 128 Shipping select 56 Points). Now variable field Variable1 automatically prints the SSCC-18 number as a bar code. 

To the form similarly add another variable field Variable2. Set the Object Method to the following;

Variable2 := CIAXCOM_SSCC18_H ( [Shipments]ShipmentNo )

Now variable field Variable2 prints the human readable text containing ShipmentNo. You would normally position field Variable2 below the bar code.

You can use your own variable names, instead of Variable1 and Variable2

UCC/EAN-128

UCC/EAN-128 bar code symbols are printed using the Code 128 symbology and one of the CIA Code 128 fonts.

This section is to be used in conjunction with the following sections;

See:

Printing bar codes in 4D Quick reports

See:

Printing bar codes in 4D forms

See:

Creating bar codes in 4D triggers

The UCC/EAN-128 bar code symbol and human readable text (that usually appears below the bar code) are printed using two separate form field objects; one form field to print the bar code symbol and one to print the formatted human readable text.

UCC/EAN-128 bar code symbols are created using functions CIAXCOM_UCC128 or CIAXCOM_EAN128.

Note: Functions CIAXCOM_UCC128 and CIAXCOM_EAN128 are exactly the same and encode UCC/EAN-128 bar code symbols.

When a UCC/EAN-128 bar code contains a single SSCC-18 there is a special function to handle this, see SSCC-18 below.

There many advantages of using two separate form field objects.

The human readable text can;

- be printed using any text font
- be formatted in a variety of ways
- be printed using any text font size or font colour
- be printed in any location (below or above the bar code)

We will be using only these functions;

UCC/EAN-128 bar code symbols that contain a single SSCC-18 / GTIN or SCC-14

CIAXCOM_BCP
CIAXCOM_EAN128
CIAXCOM_UCC128
CIAXCOM_ITF_A_H
CIAXCOM_POSTNET
CIAXCOM_SCC14
CIAXCOM_SCC14_H
CIAXCOM_SSCC18
CIAXCOM_SSCC18_H

SCC-14

CIAXCOM_SSCC18 ( "0012345678901234567" )

CIAXCOM_SSCC18_H ( "0012345678901234567" )

UCC/EAN-128 Application Identifiers

Here is a complete list of AI's; UCC/ EAN-128 Application Identifiers (AI) list current as of June, 1995

Printing a bar code that contains a single AI (Application Identifier) field is very simple.

When printing an AI that contains a date see Date fields formatted YYMMDD on this page, and when it contains a measurement see Measurement fields.

When printing fixed length AI fields, it is vital to print the correct number of characters. You should pad any short values with leading zeroes. When printing a variable length AI field, it is vital not to exceed the maximum number of characters.

Worked example - a single AI (Application Identifier) field

A Serial Number can be encoded using 21 as the AI (Application Identifier). If table called Goods contains a field called SerialNumber, which contains your serial numbers, then the following displays a UCC/EAN-128 bar code for your serial numbers.

CIAXCOM_EAN128 ( "21" + [Goods]SerialNumber )

and the human readable text to print below the bar code is calculated thus;

"(21) " + [Goods]SerialNumber

TIP: When serial numbers get longer, the bar code gets wider. Make sure you allow the bar code room for expansion. A good idea is to print a bar code that contains the largest serial number you plan to use. Alternatively, you can format all serial numbers with leading zeroes (if your systems allow it) to the largest length you plan to use;

CIAXCOM_EAN128 ( "21" + String ( [Goods]SerialNumber;"000000" ) )

this assumes your SerialNumber field is an Integer or a Long Integer.

If you add two variable fields called Variable1 and Variable2 to a form that contains the field SerialNumber, and set the Object Method of the Variable1 field to the following;

Variable1 := CIAXCOM_EAN128 ( "21" + String ( [Goods]SerialNumber;"000000" ) )

and set the Object Method of the Variable2 field to the following;

Variable2 := "(21) " + String ( [Goods]SerialNumber;"000000" )

Field Variable1 will automatically print the UCC/EAN-128 bar code containing field SerialNumber

Field Variable2 will print the human readable text containing SerialNumber. You would normally position field Variable2 below the bar code.

UCC/EAN-128, multiple AI's and FNC1

The simple rule for using the FNC1 character to terminate variable length fields is very simple indeed.

RULE: The FNC1 character is only required to terminate a variable length AI (Application Identifier) field that contains fewer than the maximum number of characters, only when the field is not the last field.

From the rule we can deduce; 

When a variable length AI field is the last AI field, a terminating FNC1 character is not required.

Whenever a variable length AI field is followed by any other field, a terminating FNC1 character is required.

If a variable length AI field is the maximum length, or is padded to the maximum length, a terminating FNC1 character is not required.

The UCC/EAN-128 application standard states: if a UCC/EAN-128 contains a single variable length AI (Application Identifier) field, it should be made the last field, if possible, thus avoiding the need any terminating FNC1 character at all.

If you must print a UCC/EAN-128 symbol that contains more than one AI (Application Identifier) field

Two or more fields - all fixed length fields

If all of the fields are fixed length a simple expression can be used to print all fields in one UCC/EAN-128 bar code.

An Serial Number can be encoded using 21 as the AI (Application Identifier). If table called Goods contains a field called SerialNumber, which contains your serial numbers, then the following displays a UCC/EAN-128 bar code for your serial numbers.

CIAXCOM_EAN128 ( "21" + [Goods]SerialNumber )

and the human readable text to print below the bar code is calculated thus;

"(21) " + [Goods]SerialNumber

Although an expression can be used, sometimes a custom function method can be used for further simplification and simpler dubugging.

For example, if we have fields 

 
Two or more fields - one variable length field

A Customer's Purchase Order Number can be encoded using 400 as the AI (Application Identifier). A Net Weight (kg) can be encoded using 310 as the AI (Application Identifier). 

This example assumes you have a table called Orders containing an Alpha field called PONum (which contains your customer's PO number) and an Integer field called NetWeight (which contains a weight in kg).

TIP: We used the Substring function to make sure that PONum number is not too long. In your application you may prefer to report an error if the PONum is longer that 20 characters (the maximum allowed by UCC/EAN-128 for this field). Instead of using 20 it would be wiser to define a constant value in your application.

CIAXCOM_EAN128 ( "3100" + String ( [Order]NetWeight;"0000000" ) + "400" + Substring ( [Order]SerialNumber; 1; 20 )

and the human readable text to print below the bar code is calculated thus;

"(3100) " + String ( [Order]NetWeight;"0000000" )  + "(400) " + Substring ( [Order]SerialNumber; 1; 20 )

We used a trick in the last example, we made the variable length Serial Number field the last field, this meant we did not need to add an FNC1 character to terminate it. If you are not able to do this is your application, then use the following method;

CIAXCOM_EAN128 ( "400" + Substring ( [Order]SerialNumber; 1; 20 ) + "3100" + String ( [Order]NetWeight;"0000000" )

and the human readable text to print below the bar code is calculated thus;

"(400) " + Substring ( [Order]SerialNumber; 1; 20 ) + "(3100) " + String ( [Order]NetWeight;"0000000" )

Although an expression can be used, sometimes a custom function method can be used for further simplification and simpler dubugging.

AI_400_310_KG_BARCODE
$SerialNumber := $1 ` Assign 1st and 2nd argument a meaningful variable name
$NetWeight := $2

$SerialNumberLen := Length ( $SerialNumber )

` Check if the bar code is possible given the data
If ( ( $SerialNumberLen <= 20 ) & ( $NetWeight <= 999999 ) )

    If ( $SerialNumberLen < 20 )
        $FNC1 := "%" ` FNC1 character needed to terminate short variable field
    Else

        $FNC1 := "" ` FNC1 character not needed, if variable field is full width
    End if

    $Data := "400" + $SerialNumber + $FNC1 + "3100" + String ( $NetWeight; "000000" )

    ` NOTE 1: When FNC1 is the '%' character, function CIAXCOM_UCC128 inserts an FNC1 character
    ` NOTE 2: 310 becomes 3100 because there are no decimal places, 0 indicates the decimal point is on the right

    %0 := CIAXCOM_UCC128 ( $Data )

Else

    ` No bar code will be printed
End if

and to print the human readable text below the bar code;

AI_400_310_KG_HUMAN
$SerialNumber := $1 ` Assign 1st and 2nd argument a meaningful variable name
$NetWeight := $2

$SerialNumberLen := Length ( $SerialNumber )

` Check if the bar code is possible given the data
If ( ( $SerialNumberLen <= 20 ) & ( $NetWeight <= 999999 ) )

    $0 := "(400) " + $SerialNumber + " (3100) " + String ( $NetWeight; "000000" )

    ` NOTE 2: 310 becomes 3100 because there are no decimal places, 0 indicates the decimal point is on the right

Else
    ` No bar code will be printed
End if

If you add two variable fields called Variable1 and Variable2 to a form that contains fields SerialNumber and NetWeight, and set the Object Method of the Variable1 field to the following;

Variable1 := AI_400_310_KG_BARCODE ( [Order]SerialNumber; [Order]NetWeight )

and set the Object Method of the Variable2 field to the following;

Variable2 := AI_400_310_KG_HUMAN ( [Order]SerialNumber; [Order]NetWeight )

Field Variable1 will print the UCC/EAN-128 bar code containing both fields SerialNumber and NetWeight (when you set the font for field Variable1 to CIA Code 128).

Field Variable2 will print the human readable text containing both fields SerialNumber and NetWeight. You would normally position field Variable2 below the bar code.

Two or more fields - two or more variable length field(s)

This is the same as the last example, except you do not have to option of swapping the fields to make the variable length field the last field.

Date fields formatted YYMMDD

Dates in UCC/EAN-128 bar code symbols are formatted YYMMDD (2 digit year, 2 digit month, 2 digit day), for example 22nd November 2000 becomes 001122.

Add this function method to your project to format dates correctly.

DATE_YYMMDD
$D := $1
$YY := Substring ( String ( Year of ( $D ) ); 3 )
$MM := String ( Month of ( $D ); "00" )
$DD := String ( Day of ( $D ); "00" )
$0 := $YY + $MM + $DD

The DATE_YYMMDD function is used like so;

DATE_YYMMDD ( [Table 1]SellByDate )

The UCC/EAN-128 standard tells you to prefix a date with the fixed application identifier (15), to identify the date as a Sell By Date. The following prints a UCC/EAN-128 bar code containing (15) 030706

CIAXCOM_UCC128 ( "15" + DATE_YYMMDD ( [Table 1]SellByDate ) )

and to print the human readable text below the bar code; 

"(15) " + DATE_YYMMDD ( [Table 1]SellByDate )

Measurement fields

Because numeric only data is more efficiently encoded (i.e. produces more compact bar code symbols) using UCC/EAN-128 (i.e. using Code 128) the UCC/EAN-128 standard has a special scheme for encoding measurements; without the need to encode a decimal point character.

Instead of encoding a decimal point character, only the position of the decimal point character is encoded. The position can be 0 to 9 character from the right of the data.

Examples:

Actual measurement UCC/EAN-128 measurement - the first step is to convert to units that UCC/EAN-128 accepts (m, m2, inches, kg, feet, yards, ...)   Decimal position appended to AI Data for AI field
12340 mm 12.24 m  2 001234
1000 mm 1 m   0 000001
15 cm .15 m   2 000015
23.49 mm .02349 m   5 002349
Worked example

UCC/EAN-128 defines the AI (Application Identifier) 311 as Length of 1st Dimension, Meters. If we want to encode a UCC/EAN-128 symbol with a 1234 mm as the length of the 1st dimension;

(a) The value 1234 mm is first converted to 1.234 m
(b) The decimal point position is noted, it is 3 places from the right
(c) The decimal point is removed 1234
(d) Finally the complete message is formed 31131234 (i.e. AI + decimal places + measurement)
(e) And the human readable text (3113) 1234

This procedure is quite complex, but it can be automated with some useful functions.

Simplified solutions for AI's that include measurements

Function CIAXCOM_DECIMAL_MEASURE() takes one real number argument (in the correct units for UCC/EAN-128) and converts it to a string. The above example can thus be simplified as;

"311" + CIAXCOM_DECIMAL_MEASURE(12340 / 1000)

resulting in;

31121234
Human readable AI's that include measurements

The following functions are designed to be used to produce the human readable text below the bar codes.

Function CIAXCOM_DECIMAL() takes one real number argument (in the correct units for UCC/EAN-128) and converts it to a string that represents the decimal places only. 

Function CIAXCOM_MEASURE() takes one real number argument (in the correct units for UCC/EAN-128) and converts it to a string that represents the measurement only.

The above example can thus be simplified as;

"(311" + CIAXCOM_DECIMAL ( 12340 / 1000 ) + ")" + CIAXCOM_MEASURE ( 12340 / 1000 )

resulting in;

(3112) 1234
Creating Project Methods to simplify further

Here is a general purpose function you can write, to simplify applications that repeatedly need to encode AI (Application Identifier) 311

AI_311_HUMAN
M := $1
$0 = "(311" + CIAXCOM_DECIMAL ( $M ) + ")" + CIAXCOM_MEASURE ( $M )

Function AI_311_HUMAN(12340 / 1000) produces (3112) 1234

AI_311_DATA
$M := $1
$0 = "311" + CIAXCOM_DECIMAL_MEASURE ( $M )

If all of your measurements are stored in mm you could even add the conversion in to the function;

AI_311_MM_HUMAN
$M := $1/1000
$0 = "(311" + CIAXCOM_DECIMAL ($M) + ")" + CIAXCOM_MEASURE ($M)

Function AI_311_MM_HUMAN(12340) produces string (3112) 1234

AI_311_MM_DATA
$M := $1/1000
$0 = "311" + CIAXCOM_DECIMAL_MEASURE( $M )

Function AI_311_MM_DATA(12340) produces 31121234 ready to be encoded as a bar code, like so;

CIAXCOM_UCC128 ( AI_311_MM_DATA ( 12340 ) )

If you add a variable field called Variable1 to a form that contains fields LengthMeters and set the Object Method of the Variable1 field to the following;

Variable1 := CIAXCOM_UCC128 ( AI_311_MM_DATA ( [Table]LengthMeters ) )

the result is a bar code (when you set the font to CIA Code 128).

 

 


Copyright © 2000 CIA (BAR CODES) UK. All rights reserved. Reproduction prohibited.