Consultor Eletrônico



Kbase 15575: Printing Bar Codes from Report Builder
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
Printing Bar Codes from Report Builder

Printing Bar Codes from Report Builder:

To include bar codes on a report, you first need to
determine what type of bar codes you want. There are many
different types of bar code fonts. The type that you use
depends on the purpose for which you are bar coding
something and the type of scanner that will be used to read
the bar code.

For example, for postal bar codes you need a special bar
code font, called POSTNET, which is readable by the bar code
scanners used by the Post Office.

Once you have determined the type of bar code you want, you
need to obtain a font for that bar code. This could be a
built-in font in your printer, a PostScript font, or a
Windows True Type font.

Once you have obtained and installed the appropriate font,
you use bar codes in your report as follows:

1. Create a calculated field that formats the data in your
database appropriately for the type of bar code you are
using. For example, you might need to convert from a
numeric to a character value, or pre-pend or append certain
characters to the value you want to print as a bar code.

2. Place the calculated field on the report layout.

3. Apply the bar code font to the calculated field.

4. If necessary adjust the width of the field so that the
complete bar code can be printed.

Following are two detailed examples for using bar code 3 of
9 and POSTNET bar codes.

Bar code 3 of 9:

1. Create a calculated field that pre-pends and appends an
asterisk to the data field you want printed as a bar code.

If the data field is a character field called prod_code, use
the following expression:

"*" + prod_code + "*"

2. Place the calculated field on the report and apply the
bar code 3 of 9 font to it.

POSTNET bar codes:

POSTNET bar codes require more complex formatting, including
a checksum calculated from the digits of the zip code. In
order to make it easier to use POSTNET bar codes in
different reports, you can create user-defined functions
to do some of the formatting. The formatted string should
contain:

`!'
5, 9 or 11 digit zip code
check digit
`!'

If you have purchased a POSTNET font, this should be
explained in more detail with the documentation that comes
with the font, however, the following steps should provide
all the information you need to use the font with Report
Builder.

1. Create a user-defined function, called CheckSum, to
compute the check digit, which is calculated from the digits
in the zip code. It should have one character parameter
called ZipCode and its expression should be:

SUBSTRING(STRING(10 -
((NUMERIC(SUBSTRING(ZipCode,1,1)) +
NUMERIC(SUBSTRING(ZipCode,2,1)) +
NUMERIC(SUBSTRING(ZipCode,3,1))
+ NUMERIC(SUBSTRING(ZipCode,4,1)) +
NUMERIC(SUBSTRING(ZipCode,5,1)) +
NUMERIC(SUBSTRING(ZipCode,6,1))
+ NUMERIC(SUBSTRING(ZipCode,7,1)) +
NUMERIC(SUBSTRING(ZipCode,8,1)) +
NUMERIC(SUBSTRING(ZipCode,9,1))) Modulo 10 )),1,1)

This expression calculates the sum of the digits in a nine-
digit zip code, then subtracts that number from 10 and takes
the last digit of the result. If you use 5- or 11-digit zip
codes, the expression should be modified to add the correct
number of digits.

2. Create a second user-defined function, called
PostNetFormat, to build the string that will be displayed as
a bar code. It should have one character parameter called
ZipCode, and its expression should be:

"!" + ZipCode + CheckSum(ZipCode) + "!"

3. Create a calculated field that calls the user-defined
function, and specifies as its parameter the character field
containing the zip code you want to print as a bar code.
For example, if your database contains a field called
Postal-Code which stores a 9-digit zip code as a character
string, use the calculated field expression:

PostNetFormat(Postal-Code)

4. Place the calculated field on the report layout, and
apply the POSTNET font.

5. Since POSTNET fonts are very wide, increase the width of
the field on the layout so that the whole bar code will be
printed. (About 3 inches should be sufficient).

Once you have created the user-defined functions in steps 1
and 2, if you want to include bar codes on other reports,
you need to repeat only steps 3 through 5.


Progress Software Technical Support Note # 15575