May the (AFP Overlay) Forms Be with You

Advanced Function Printing (AFP) overlays are a great alternative to preprinted forms. Here’s the concept. You create your form in any Windows application (Microsoft Word, for instance). Then, just output the form with the AFP printer driver included with AS/400 Client Access Express for Windows V4R4 and store the output on your AS/400. Next, you simply tell your printer file to use that form when outputting the data from your application
(e.g., invoicing). All of your previously preprinted forms are now generated “on the fly,” and, any time you need the form changed, you just modify the Word document and recreate the overlay on the AS/400. OK, I know you’re thinking, “There has to be more to it than that!” This article will take you step-by-step through the process.

Why Use Overlay Forms?

The reasons to use overlay forms are endless, and not least of all is cost. Using AFP overlays means no more buying all those different preprinted forms. Now, regular laser printer paper serves all of your form needs. And you won’t have to worry about running out of preprinted forms anymore. Additionally, if you need any changes made to a form—say, company address or logo changes—you won’t be waiting two weeks for the printer to get you the new forms. Overlays also give you the ability to go “paperless” by saving a copy of the output and using the AFP Viewer, which is included with Client Access V3R1 and higher, to view or print a copy of the document whenever needed.

Overlays are easy to create because you use applications you are already familiar with, such as your favorite word processor or spreadsheet program, and generate the overlay easily by printing a copy of it. Also, overlays reduce the amount of program modification required because you no longer have to modify the program to fit your form. Instead, you can create a form that conforms to the program’s printed output but is customized for your company to include your name and logo and any other specific information. This can be a great timesaver when going through a new software implementation.

Where Do I Sign Up?

More to the point, how do I get started, right? The first thing you need to do is make sure you have a printer configured to print overlays. Here, there are two options: either an IPDS printer configured as AFP “YES” or a PCL-compatible laser printer configured for Host

Printer Transform (HPT). Just check the device description and, if need be, change the TRANSFORM parameter to *YES. You should also make sure you have the latest PTFs installed on your system, especially any AFP-related PTFs.

The next thing you need to do on the AS/400 is create a new shared folder in which to store the overlay output. It’s also not a bad idea to store a copy of the document that the overlay is created from in this folder as well for later modifications. Use the following Create Folder command to create a new shared folder called overlays:

Now create a physical file with a record length of 1021 bytes that will be used to store and create the overlay resource later. To do this, type this Create Physical File command:

Next, you need to make sure your PC has everything it needs to create and generate the overlays. First, you need to be working with a PC running Client Access V3R1M0 or higher. After that, the most important component required on the PC is the AFP printer driver. This is included with all versions of Client Access Express for Windows or can be downloaded from the IBM AFP Printer Drivers site (www.printers.ibm.com/r5psc.nsf/Web/afpdr).

Once you have the printer driver on your system, go to the control panel and select the Printers icon. Double-click on Add Printer, select Local printer, and click Next. When the list of printers is displayed, click Have Disk and point the program to the directory containing the AFP printer driver. This should either be under the Client Access directory or wherever you decompressed the file downloaded from IBM’s Web site. When the list of drivers is presented, select the appropriate one. Figure 1 shows this list. If you are going to be using an IBM printer with AFP support, select that printer. Otherwise, select either the AFP 600 or AFP 300 based on your printer’s resolution (600 or 300 dpi).

After selecting the appropriate driver, click Next. When asked to specify a port for the new printer, select File; this allows you to save the AFP output to a file that will be used to create the overlay resource on the AS/400. After clicking Next, you will be asked to name the new printer; name it “AFP Overlay Printer” and click OK. Now right-click on the printer that you just created and select Properties from the menu. When the printer properties box is displayed, click on the Options tab. Figure 2 shows the screen that will come up. Under Output Type, select Overlay, click Apply, and then click OK. This tells the printer driver that you will be creating overlays. You will also need to have a network drive mapped to the QDLS folder on your AS/400.

That’s all of the setup required. Now you need to design your form.

Forming Your Form

To create your overlay form, you can use any Windows application that allows you to print to a Windows printer. For the purposes of my example, I will use Microsoft Word 97. Most likely, you will be designing a form to replace an existing preprinted form, or you will be creating a new form to fit the “vanilla” output from your applications software (in the case of implementing a new software package).

The process of designing forms in Word is a fairly basic one. Figure 3 shows an example form, a simple invoice format. Create a new blank document in Word by going to the File menu and selecting New. Select the Blank template, click OK, and then go to the File menu again and select Print. No, you aren’t actually ready to print anything yet, but you need to tell Word that you will be using your AFP printer driver so that the document

you create will be formatted for the AFP driver. When the Print dialog is displayed, drop down the list of printers and select AFP Overlay Printer. Click Close to close the dialog box, go to the File menu, and select Page Setup. Now reduce all of the margins to zero (0”). When you click OK, Word will tell you that your margins are set outside of the printable area of the page. Click Fix to have Word automatically adjust the page margins to the minimum required by the printer driver. This will allow you maximum area for your form.

Now you’ll start on the form itself. First, move your cursor to the top of the page and click on the Center button on the button bar. This is the icon that appears to have several lines of text centered on a page. Click the Format menu and select Font; choose Arial 28-point font in bold style and click OK. Now type the word Invoice. Using the point size selector on the button bar, reduce the font to 18 points and disable bold by clicking on the bold icon on the button bar. Finally, type the name and address of your company (ABC Corp., 123 Main Street, Anytown, US 99999, in this example).

Now you need to create a table. To do this, go to the Table menu and select Insert Table. When the Insert Table dialog is displayed, select two rows and two columns (which happens to be the default) and click OK. This will place the new table on your page with two columns, each half the width of the page, and two rows, each approximately one letter tall. Highlight the bottom two cells of the table by clicking on the left cell and dragging it over to the right cell. Now click on the Table menu and select Cell Height and Width. On the Rows tab, change the list box on the right from Auto to Exactly and change the cell height to 2 inches (2”). This table will be used for the ship to and bill to sections of the form. Click on the top left cell and type “Ship To” and click on the upper right cell and type “Bill To.”

Now you will create a second table that will be used to show your invoice detail lines. Go to the Table menu and select Insert Table again, but, this time, create a table with four columns and two rows. On the top row, type “Item,” “Quantity,” “Price,” and “Amount” in the cells from left to right. Again, highlight the second row and, this time, change the row height to 6 1/2 inches (6.5”).

At this point, go to the bottom of the page and, using Arial 12-point font, insert eight tabs and type “Invoice Total.” Save the document by going to the File menu and selecting Save As. It’s a good idea to save the Word document to the shared folder on your AS/400. To do this, click the Save in list box on the save dialog and select Network Neighborhood. Look for your AS/400 system name and double-click on it. Then, look for the Overlays folder you created earlier, give your document a name, and click Save. It’s not a requirement to save the Word document to this location, but it is a good idea because it will be easier to find later if and when you need to modify the form.

Now that you have saved the document, click on the File menu and select Print; make sure the AFP Overlay printer is still listed as the printer for the document and click OK. When you are prompted for the file name and location, select the Overlays folder the same way you did previously and type “Invoice.prn” for the file name. That’s all of the PC work. The rest of the work needs to be done on the AS/400.

Creating the Overlay

The process of creating the overlay from the file created by the AFP driver involves three separate AS/400 commands. First, you need to use the Copy from PC Document (CPYFRMPCD) command to copy the AFP printer output from the shared folder to the physical file you created earlier. From the command prompt, type the following:

CPYFRMPCD FROMFLR(OVERLAYS) TOFILE(QGPL/OVERLAYS) FROMDOC(INVOICE.PRN) TOMBR(INVOICE)
TRNTBL(*NONE) TRNFMT(*NOTEXT)

Next, you need take this physical file and create the overlay resource from it using the following command:

CRTOVL OVL(QGPL/INVOICE) FILE(QGPL/OVERLAYS)

Sample Program

Now that you have the overlay created, you are almost there. Figure 4 shows the RPG IV code you need to type in for INV001RP, and Figure 5 shows the DDS specs you need to type in for INV001P1. This program will create some sample output on your invoice form. There are three methods that you can use to attach the overlay to the printer file.

The first way is to add the overlay record-level keyword to the DDS source of the printer file. The format of the keyword is as follows:

OVERLAY([(library-name/overlay-name] position-down position-across (*ROTATION
rotation-field))

The unit of measure specified on the Create Printer File (CRTPRTF) command should match the unit of measure used for the position-down and position-across keywords. These two parameters allow you to specify the offset from the top corner of the page for the overlay. The optional *ROTATION parameter allows you to rotate the overlay relative to the page in 90 degree increments.

The second option is to add an Override Printer File (OVRPRTF) command to your program using the FRONTOVL and/or BACKOVL parameters. The FRONTOVL parameter identifies the overlay to be used for the front of the page. Subsequently, the BACKOVL parameter identifies the overlay to be used for the back of the page. These parameters are specified in the same format that you used on the overlay DDS keyword with the exception of the *ROTATION parameter.

An alternative to the previous two options is to specify the FRONT-OVL or BACKOVL parameter on the CRTPRTF command. These parameters are the same as those on the OVRPRTF command, and you can also do a Change Printer File (CHGPRTF) and specify the FRONT-OVL or BACKOVL parameter there.

Any one of these options will give you the same result. Which one you choose is entirely up to you. The thing to remember is that the first two options involve actual code changes, whereas the third solution does not. However, in the third example, if changes are made to the printer file, you will need to remember to specify the FRONT- OVL/BACKOVL parameter when recompiling. With any of these options, you need to specify DEVTYPE(*AFPDS) when you create the printer file. If you don’t, the overlay will not be generated when output is sent to the printer.

For this example, I used the third method. Compile the printer file using the following command:

CRTPRTF FILE(library/INV001P1) SRCFILE(library/QDDSSRC) DEVTYPE(*AFPDS) PAGRTT(0)
FRONTOVL(library/INVOICE) PAGESIZE(66 80)

Next, compile the ILE source by typing the following:

CRTBNDRPG PGM(libname/INV001RP) SRCFILE(libname/QRPGLESRC) SRCMBR(INV001RP)

When the compile is complete, run the sample program by typing CALL INV001RP from the command line. Figure 6 shows what the generated output should look like. This is a very basic sample, but you can see how easily you can create clean-looking finished output.

Once you’ve started working with overlays, you’ll be amazed at how easily you can make all of your preprinted form applications “overlay-compatible.” And you’ll never have to worry about running out of preprinted forms again.

References and Related Materials

IBM AFP Printer Drivers site: www.printers.ibm. com/r5psc.nsf/Web/afpdr

May_the_(AFP_Overlay)_Forms_Be_with_You05-00.png 397x290

Figure 1: Select the AFP driver to match the printer you will be using to print the overlay from your AS/400.

May_the_(AFP_Overlay)_Forms_Be_with_You06-00.png 402x476

Figure 2: Go into the AFP printer driver properties and change the Output Type to Overlay.

May_the_(AFP_Overlay)_Forms_Be_with_You07-00.png 400x519

Figure 3: This is an example of the Microsoft Word document that you will use to create an overlay.

* To Compile : CRTBNDRPG PGM(libname/INV001RP)