Advance Your Printing with AFP

Document Management
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

January 1, 2000, has come and gone, and, if your IT department was lucky, it experienced very few problems. With this major hurdle out of the way, you can finally focus your efforts on something other than looking for date-related problems and continually testing your applications. This would be a great time to examine the printed output generated by your applications.

Most IT shops no longer have a line printer sitting in the corner of the computer room cranking out an endless stream of reports that no one ever looks at after they are distributed. The use of the Internet has exploded, and a favorable result is that users are more comfortable viewing information online. They no longer require a hard copy of every detail “just in case they need to look it up.” People are now willing to perform these lookups online, which, in turn, reduces the number of reports the IT department has to produce and maintain. The downside to this is that the IT department is receiving more requests for specialized reports and the user would like to “dress up the reports a little.”

Most companies also use many different types of preprinted forms. Examples are invoices, purchase orders, and statements. Have you ever had to throw out boxes of these preprinted forms because a forms change was required? Your company may also have separately operating divisions running on the same system. This means you may have preprinted invoices for each of the several companies. The only difference in the form is the company name printed at the top. You may also work with customers who require a form made specifically for their needs. It is very expensive to have a pre-printed form created for one customer.

If you are experiencing any of these problems, maybe it’s time to see what your AS/400 and Advanced Function Printing (AFP) can do to help. Before I talk about AFP, let me take a quick look at the AS/400 and its normal method of creating and sending spool output to the printers. By default, the AS/400 print data stream is the SNA Character Stream, or SCS. The SCS data stream is a proprietary stream that consists of one byte of hexadecimal code preceding the data to be printed. The SCS data stream is used to control line printers and supports row and column functions as well as underscores, overstrikes, and emphasized text. If you have OfficeVision/400, you also have the ability to print superscript, subscript, symbols, and process font changes. Because SCS is a relatively simplistic data stream generated by the AS/400, it does not support any special print functions.


What Is AFP?


Beginning with V2R1, AFP was added as a component of OS/400. This means that the AS/400 has two printing subsystems inside the operating system. OS/400 print support continues to support line printers and a subset of intelligent printer data stream (IPDS) printers. Only printers created with AFP(*YES) in the device description are controlled by the AFP subsystem. With OS/400 Version 3, a new feature was added called Print Services Facility for AS/400 (PSF/400). The AFP printing subsystem is still integrated into the operating system but is now acti-vated by PSF/400.

AFP allows you to create your own forms in-house, providing you the flexibility to make changes whenever you desire. You can print barcodes as well as charts, logos, and graphics and scanned images. You can print postal barcodes on documents, which allows you to convert them into mailers and save time and money. You can also create electronic documents that can be viewed, faxed, or printed. The AS/400 can print to network printers with the same level of reliability as twinax-attached printers.

The AFP data stream includes data, text, and device-independent references to overlays, page segments, and font objects. The AFP data stream output is produced by a number of applications such as the AFP Toolbox, Advanced Print Utility, and DDS. The AFP data stream is a companion to the IPDS. The same family of printers is supported by both IPDS and AFP. The IPDS Data Stream is a host-to-printer data stream for Advanced Function Printing. It provides an interface to all-points-addressable (APA) printers that allows the presentation of pages containing a mixture of data types such as text, images, graphics, and bar codes. IPDS provides bidirectional communication between the AS/400 print writer and the printer. When a new print job is started, the print writer will query the printer to determine if any font, image, or overlay images are already in the printer memory. If the required resources are already contained in the printer’s memory, they are not resent. AFP simply takes advantage of this bidirectional communication between the printer and the AS/400.

AFP is page-mode printing, whereas SCS is line-mode printing. Line-mode printing usually consists of composing a line at a time from the top of the page to the bottom on continuous forms. There are many applications that you may have that work fine using SCS. If you are simply generating green bar reports such as sales reports or aging reports, there is really no need to look at converting these applications to use AFP. If you have reports that are sent to your customers such as invoices or statements, instead of using preprinted forms, you may consider using AFP with page overlays.

AFP composes the entire page prior to printing. Text, images, barcodes, and overlays may be specified in any order and any position within the page. It may be helpful to think of AFP more in terms of designing a display screen than designing a report. With AFP, you can use x and y coordinates to place an element anywhere on the page. As an example, you may specify all of the text fields for the document, specify a barcode to print at the top of the page, and then combine this with an overlay. The page does not need to be designed from the top down. Every AFP document is contained inside of a begin document (BDT) and an end document (EDT) structure. After the begin document, the resources to be used, such as overlays or fonts, are defined. Then, the default options for the entire page are defined, with the actual pages of the document specified last.

AFP also supports two external resources for page formatting called page and form definitions. Form definitions and page definitions are external to the application program and provide a subset of the functionality available with DDS and printer files. These two resources are optional and are normally used when the printing format needs to be independent from the application. A form definition performs many of the same functions as a printer file. A printer file is required, whereas form definitions and page definitions are not. The form definition contains the following printing controls:
• Page origin (the top left boundary for printing)

• Sheets that have overlays printed on them
• Number of copies to be printed
• Paper source (usually bin number)
• Simplex or duplex
• Page presentation (portrait or landscape)
• Print quality
• Horizontal adjustment in pixels or dots per inch

A page definition is the resource that specifies how data is to be formatted by PSF/400. A page definition contains many of the same functions that are available in the DDS keywords. The page definition contains the following items:
• Fonts to be used for printing the data
• Location where data from each input record is to be printed
• Constant data to be printed
• Data fields that can be suppressed
• Print positions for carriage controls
• List of page segments
• List of page overlays
• Conditional processing
• Color selection (for multicolor printers)
• Page size (height and width)
• Print direction
• Number of lines per inch

Figure 1 illustrates the PSF/400 printing subsystem work flow.


Is AFP a Good Fit for You?


Now that you have a basic idea of what AFP is, you should know how it can be of use to you. For one, you can use AFP to create and print page overlays. A page overlay can be combined with text data and sent through the print stream instead of using preprinted forms. By using page overlays, you do not need to stock preprinted forms. One disadvantage of preprinted pin-fed forms is that, before they can be mailed to the customer, the sides of the forms must be torn off and the forms must be separated. By using overlays, you can avoid these problems and use plain paper in your laser printers. You don’t have to worry about running out of preprinted forms, and, if a forms change is required, you don’t need to throw out boxes of preprinted forms. Using overlays also allows you to respond to customer or vendor requirements much more quickly.

Maybe your customers are asking you to fax them documents. If you are currently printing the document and then faxing the report to your customers, AFP can save you quite a bit of time. By creating an overlay and combining it with the report text, your users can fax the documents directly from their workstations, alleviating endless trips to the fax machine. The fax support software available on the AS/400 allows you to fax spool files by referencing the job and spool file number. The software manages any font changes required or any page rotation that may be necessary. Depending on how you design the application, the user can simply use a menu option that will generate and fax the report in one step. What could be easier? (For those of you using a Model 170 AS/400, the integrated PCI fax adapter is now available. The card contains eight phone line connections and uses a new version of the fax support software [5798TBY]. The new fax support software functions almost exactly like the older versions, with a few minor changes.)

There are several methods to produce overlays. One option is to use Advanced Function Printing Utilities/400 (AFP Utilities) from IBM. Using the overlay utility, you can design electronic forms using any AS/400 terminal. You build the overlay online using fonts and images contained in AS/400 libraries. Elements such as lines, boxes, text, page

segments, and barcodes are placed on the overlay by specifying row and column positions. I have used AFP Utilities in the past, and I found that is was not the easiest way to design overlays. In an effort to make AFP Utilities more user-friendly, IBM has added a feature to Client Access V3R1M3 and later to allow you to view the overlay as you are designing it. You need to install the AFP Workbench Viewer on your PC and use the *VIEW option on the design overlay screen.

I think an easier alternative is to use the IBM AFP printer driver for Windows. The print driver can be used to create page segments and overlays from any Windows application. The printer driver is part of Client Access and is contained on the Client Access for Windows CD-ROM. The driver uses Windows’ graphical data interface and maps fonts, lines, and boxes to AFP. Where images are required, the driver uses compressed images to create more efficient overlays. To create the overlay, you can use an application such as Microsoft Word. Just scan in any graphic images and draw any lines, boxes, and shaded areas you would like to appear on your overlay. For more information, see “May the (AFP Overlay) Forms Be with You” on page 53.


It Keeps Getting Better


For those of you who have used AFP in the past and are concerned about performance, you should know that several enhancements have been made to AFP to address the performance issues. Overlays and page segments are now retained at the printer. Prior to V3R1, overlays and page segments were downloaded for every job regardless of whether

they were already at the printer. Starting with V2R2, the system value QPFRADJ automatically modifies the *SPOOL storage to provide increased throughput for AFP. Improvements in PSF/400 such as font capture, cut-sheet emulation, and improved memory utilization have also helped.

In addition, those of you using OS/400 release V3R7 or higher have the ability to create a device description for your TCP/IP printers. Prior releases only allowed you to create an OUTQ. This limited the degree of printer control such as detecting when the printer was out of paper, offline, or allowing you to print page ranges instead of the entire report.


References and Related Materials


• AFP Utilities for AS/400 User’s Guide (S544-5349-01, CD-ROM C5PA1M00)
• AS/400 Guide to AFP and PSF (S544-5319-03, CD-ROM C5PU3M00)

Application Programs Printer File

Output Queue

Spool File

Spool File




•Page Definitions
•Form Definitions
•Page Segments

Device Description IPDS, AFP(*yes)

Figure 1: The PSF/400 printing subsystem work flow can be represented visually.