Barcode InfoPCL FontsHome


Printing Barcodes in SAP Using Downloadable PCL Fonts
Home > Barcode Basics > Application Notes > AppNote024

This article also available in Adobe Acrobat (.pdf) format

     Contents on this page
          [ Introduction ]
          [ Downloading fonts to the printer ]
          [ Defining printer control sequences in SAP ]
          [ Printing bar codes with ABAP or SAPSCRIPT ]

See also:
Printer Barcode Fonts:   Pricing, specifications, and demonstration software download


This paper describes how to print barcodes on SAP systems using downloadable fonts and standard laser printers. The process is relatively simple:

• Copy a barcode font file from the host system to the destination printer.

• Create an output file with formatted text strings and font selection commands

• Send the output file to the printer.

PCL (Printer Command Language) is a standard developed by Hewlett-Packard Corporation which

defines a wide range of commands that control the formatting of documents on laser printers. PCL is supported by virtually every laser printer manufactured. PCL includes specifications for "soft fonts" which, when downloaded to a printer, will be automatically stored in the printer's memory and be available for use.

Most laser printers do not include native barcode capability. Those that do often employ a variety of command syntaxes, making it difficult to mix printer brands within a single system. Plug-in barcode modules are available, but are often printer brand or model-specific, and the cost per printer stays relatively level (generally from $250 to $425 per printer depending on capabilities of the module).

Downloadable soft fonts work on any brand or model of printer with the same command syntax, simplifying programming in large installations and expanding the range of printers that can be used. Some high-capacity printers include programmable memory or hard disk drives and can store downloaded fonts permanently. Although downloadable fonts do not offer the automated formatting features found in the high-end hardware modules, the cost per printer is dramatically less.

The downloadable fonts described in this paper are available as pre-built kits or can be generated using the Barcode Font Generator from MEC Software. Sample fonts, demonstration programs, and pricing/licensing information are available through The Barcode Software Center, on the web at

The version of SAP used in preparing this paper was 4.6c.

top of page

Downloading Fonts to the Printer

Before barcodes can be printed, a barcode font must be available in the printer's memory.  MEC Software PCL-5 fonts include all of the required PCL commands and data; all that is required is to send the font file from the host computer to the printer. There are several methods for sending a font to your printer. Two that work well in the SAP/Windows environment are lpr and copy.


The lpr command can be an effective method for downloading fonts. Unix and Linux support lpr; Windows/NT, 2000, and XP also support lpr, but it may not be installed by default (lpr may be called Unix printing by the Windows setup process). The general form of the lpr command is:

# lpr -S<server> -P<printer> [-C<class>] [-J<job name>]

[-O<option>] <filename>

As an example, let's assume that the destination printer is available at IP address and the file BC_3of9_4pitch.dsf contains the downloadable PCL barcode font. We must use -O (option) followed by a lower case letter "L" to specify binary mode (Windows requires a lower case "o"):

# lpr -S192.168.100.40 -P192.168-100.40 -Ol myfont.dsf


You can simply Copy the font file to the printer port. In Windows, open a MS-DOS command line window. Use the /b (binary) command line option:

C:\> COPY /B myfont.dsf LPT1:

Note: If your system does not support long filenames you will need to rename the files. For example: C39_4PIT.DSF.

If you are in a MS-DOS command prompt under Windows and the destination printer is on the network, using the printer's network name may not work depending on your version of Windows. For example, this command should send the font to the printer under Windows/98 and Windows/2000, but may simply make a copy of the file on disk with Windows/95:

C:\> COPY /B myfont.dsf \\MAIN\LASER

You may first have to assign the printer to a local printer port with the NETUSE command. The port does not have to physically exist, and you should not use a port that actually has a local printer attached to it. For example, if you have local printers attached to LPT1 and LPT2 and a network printer named "\\Main\Laser," you could assign LPT3 to the network printer:


C:\> COPY /B myfont.dsf LPT3:

top of page

Defining Printer Control Sequences in SAP

We need to define a barcode prefix (a command string to turn on the barcode font) and a suffix (another command to switch back to a normal text font). First, we need to get to the right screen. Select SAP Transaction SPAD (Spool Administration) to display Spool Administration: Initial Screen. Then click the Full Administration button.

Select the Device Types tab and select the printer that will be printing the barcodes (HPLJ4, for example).

Select the green check mark after entry of the Device Type to display the Spool Administration: Device Type screen, then click on the Print Controls tab.

sap_wmf5.jpg (27304 bytes)

The Print Controls page displays a list of defined print control sequences, each identified by a name. You can create new sequences or modify existing sequences. Let's create a control sequence named BCPFX to define the prefix that will turn on the barcode. Each downloaded font is identified by a number which is built into the font. Assuming that the font we want is number 200, we will need the following characters:

Escape Code (hex 1B)

Opening (left) parenthesis character (hex 28)

Font ID 200 (hex 32 30 30)

An upper case X to mark the end of the command (hex 58)

All of these characters need to be entered as a single string (no spaces) in the Control Character Sequence column: 1B2832303058. We also need to define a sequence to turn off the barcode font and switch back to a normal text font. Let's create sequence BCSFX to switch to the printer's default font. The PCL command to do this requires the following characters:

Escape Code (hex 1B)

Opening (left) parenthesis character (hex 28)

The number 3 (hex 33)

An @ symbol (hex 40)

So the complete sequence would be written as: 1B283340. You might prefer to switch to a specific text font instead of the printer's default. Complete details can be found in the PCL Reference Manual, available from Hewlett-Packard.

top of page

Printing Barcodes with ABAP or SAPSCRIPT

We are now ready to print barcodes using an ABAP report program or a SAPSCRIPT form. In these examples we are using Code 39 barcodes which require very little formatting (all we have to do is add asterisks before and after the data).

Sample ABAP Program:

DATA: BAR_CODE1(16) VALUE `*ABC01230123A01*'



* If the barcode is the first element on the page, the following Write

* statement is needed (otherwise you get a date in the first print

* control.


* Turn on the barcode font, print the data, and switch back to the

* printer's default font. Be sure to use NO-GAP to avoid unwanted

* characters or CR/LF.




* Add a Write statement to prevent insertion of CR/LF into the barcode.



* Variable BAR_CODE1 contains the barcode data, including asterisks.

* The & is needed to avoid unwanted spaces or CR/LF characters





top of page

SAP is a trademark of SAP Aktiengesellschaft


(c) Copyright Measurement Equipment Corporation
All Rights Reserved