26
Fri, Apr
1 New Articles

May the (AFP Overlay) Forms Be with You

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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:

CRTFLR FLR(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:

CRTPF FILE(QGPL/OVERLAYS) +

RCDLEN(1021) LVLCHK(*NO) +

MAXMBRS(*NOMAX).

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)

* SRCFILE(libname/QRPGLESRC)

* SRCMBR(INV001RP)

*

***************************************************************************

*

FINV001P1 O E PRINTER OFLIND(*IN01)

C*

C* WRITE INVOICE HEADER

C EVAL SHIP1=*ALL'X'

C EVAL BILL1=*ALL'X'

C EVAL SHIP2=*ALL'X'

C EVAL BILL2=*ALL'X'

C EVAL SHIP3=*ALL'X'

C EVAL BILL3=*ALL'X'

C EVAL SHIP4=*ALL'X'

C EVAL BILL4=*ALL'X'

C EVAL SHIP5=*ALL'X'

C EVAL BILL5=*ALL'X'

C WRITE HEADER

C*

C* WRITE DETAIL LINES

C DO 34 X 2 0

C MOVEL *BLANKS XA 2

C EVAL XA=%EDITC(X:'4')

C 'ITEM' CAT XA ITEM

C EVAL QTY=X

C EVAL PRICE=X/34

C QTY MULT PRICE AMOUNT

C WRITE DETAIL

C ADD AMOUNT TOTAMT

C ENDDO

C*

C* OUTPUT TOTAL LINE AND END

C*

C WRITE TOTAL

C MOVEL *ON *INLR

A***********************************************************

A*

A* Printer File for AFP Overlay Sample

A*

A* To Compile: CRTPRTF FILE(library/INV001P1)

A* SRCFILE(library/QDDSSRC)

A* DEVTYPE(*AFPDS)

A* PAGRTT(0)

A* FRONTOVL(library/INVOICE)

A* PAGESIZE(66 80)

A***********************************************************

A*

A R HEADER

A SHIP1 30 3SKIPB(7)

A BILL1 30 43SPACEA(1)

A SHIP2 30 3

A BILL2 30 43SPACEA(1)

A SHIP3 30 3

A BILL3 30 43SPACEA(1)

A SHIP4 30 3

A BILL4 30 43SPACEA(1)

A SHIP5 30 3

A BILL5 30 43SKIPA(23)

A R DETAIL

A ITEM 10 3

A QTY 10 0 20EDTCDE(4)

A PRICE 13 5 45EDTCDE(M)

A AMOUNT 13 2 65EDTCDE(M)

A SPACEA(1)

A R TOTAL SKIPB(62)

A TOTAMT 15 2 63EDTCDE(M)

Figure 4: This RPG code will be used to generate sample output to test the overlay.

Figure 5: This is the DDS source for the printer file for the sample program.


 

May_the_(AFP_Overlay)_Forms_Be_with_You09-00.png 405x526

 

Figure 6: Here is the final output created by the sample program.


Mike Faust

Mike Faust is a senior consultant/analyst for Retail Technologies Corporation in Orlando, Florida. Mike is also the author of the books Active Server Pages Primer, The iSeries and AS/400 Programmer's Guide to Cool Things, JavaScript for the Business Developer, and SQL Built-in Functions and Stored Procedures. You can contact Mike at This email address is being protected from spambots. You need JavaScript enabled to view it..


MC Press books written by Mike Faust available now on the MC Press Bookstore.

Active Server Pages Primer Active Server Pages Primer
Learn how to make the most of ASP while creating a fully functional ASP "shopping cart" application.
List Price $79.00

Now On Sale

JavaScript for the Business Developer JavaScript for the Business Developer
Learn how JavaScript can help you create dynamic business applications with Web browser interfaces.
List Price $44.95

Now On Sale

SQL Built-in Functions and Stored Procedures SQL Built-in Functions and Stored Procedures
Unleash the full power of SQL with these highly useful tools.
List Price $49.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

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: