Mon, Dec
0 New Articles

Advance Your Printing with AFP

  • 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.



Support MC Press Online

$0.00 Raised:

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: