AFPRSC this unknown (keyword)

Starting from V7R1 IBM has released the keyword AFPRSC usable at record leve
l. It is useful in case you want to insert images, pdf and AFPDS objects natively in spools without the need to use spool transformation sw licenses and offers the possibility, for example, to generate pdf documents in color directly from our rpg programs.

Some examples of use: logos, layout of graphic modules (invoices, sales / purchase contracts, …), written in transparency (eg pro-forma, fac-simile, …) but also catalogs with product images and so on and so forth.

Implementation

Implementing this keyword is quite simple, so much so that only a few variables are needed to manage it:

  • resource name: character field that can have a maximum length 250
  • resource type: character field of length 10
  • top position: numeric field of 5 integers with 3 decimals
  • position from the margin: numeric field of 5 integers with 3 decimals
  • rotation (optional): numeric field of 3 integers with 0 decimals
  • path (optional): character field that can have a maximum length of 2000

All the variables that are inserted in the DDS of the printer file must be defined as use P (data transfer from the program to the system).

If the * PATH attribute is not specified, the operating system will search for the resource in the path specified in the QIBM_AFP_RESOURCES_PATH environment variable and as the last default in the IFS / QIBM / UserData / OS400 / AFPresources folder.

Here is the list of supported types (resource type):

TypeDescriptionNote
* JFIF Image jpg
* PDFSPO Single page pdf object It must be smaller than a page
* PDFSPOTR Like the previous one but it is printed in transparency Everything that is written later is superimposed on it
* PCLPO PCL object
* BCOCA AFPDS barcode object
* GOCA Graphic object AFPDS
* IOCA AFPDS image object
* TIFFTIFF image

Example

Here is a simple example of how to implement the DDS keyword of the printer file to print a logo saved in pdf on IFS:

 A R RESOURCE AFPRSC (& RESNAME & RESTYPE & POSDOWN +  
 A & POSACROSS +  
 A (* ROTATION & ROTATION) +  
 A (* PATH & PATH))                      
 TO RESNAME 125A P                                          
 A RESTYPE 10A P                                          
 A POSDOWN 5S 3P                                          
 A POSACROSS 5S 3P                                          
 A ROTATION 3S 0P                                          
 A PATH 640A P                                        

and below the corresponding rpg code block

   // directory containing the pdf file to include in the print
   PATH = '/ home / resources /';                   
   // pdf file name 
   RESNAME = 'fac-simile.pdf';                   
   // guy 
   RESTYPE = '* PDFSPOTR';                 
   // position down
   POSDOWN = 0.5;    
   // position across               
   POSACROSS = 0.5;       
   // degrees of rotation            
   ROTATION = 0;        
   // print record           
   Write RESOURCE;                 

Limitations

This keyword opens up new horizons for the production of graphic prints with little effort. In any case, like any other sw component, it has limits, although in my opinion not stringent:

  • allows you to include up to 10 resources on a single page
  • each record can include the keyword AFPRSC at most once
  • does not allow combination with the following other keywords:
    • SPACEA / SPACEB
    • SKIPA / SKIPB

References

For more information, the official IBM documentation is available (https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzakd/rzakdpdf.pdf)

Related Posts
DB2 for i SQL – String Manipulation – POSSTR-LOCATE-LOCATE_IN_STRING (EN)

Introduction Often, in our applications, we need to work with text strings, and DB2 SQL can come in very useful Read more

DB2 for i – FAQ & Howtos (EN)

DB2 Database and SQL ... maybe the most important things on IBM i platform: here's a collection of FAQs, tips Read more

IBM i 7.4 Announcement (En)

Comes directly with the Easter egg this IBM announcement for the news of the IBM i 7.4 version, iNext version Read more

Generated Always Columns (EN)

Introduction "Generated Always Column": are columns, table fields, filled by DB2 engine: something like columns with a default value but Read more

View Comments

  • This is a good informative article. I am trying to use AFPRSC with *PDFSPO but it is not working for me. I am getting no errors however the blank report.

Recent Posts

How to Configure SFTP on IBM i (with Public Key or Password)

Following a recent discussion on IBM TechXchange, I’d like to share a very useful guide by Anna Niederschulte about configuring…

6 days ago

IBM i & SQL Tips #2: Reading IFS Files

I want to highlight the second post by Massimo Duca in his SQL Tips series. In this installment, we see…

7 days ago

SQL and compare tables, IFS Files, directories

Today I’d like to share an interesting article written by Marco Riva on his blog Markonetools: “Non è bello far…

7 days ago

IBM i & SQL Tips: Finding Unused Objects with QSYS2.OBJECT_STATISTICS

I’d like to share with you this interesting post by Massimo Duca, the first in a series of articles dedicated…

7 days ago

Remove old spool files to keep track of the number of jobs in the system (SQL procedure version)

In my last article “Remove old spooled files to keep track of the number of jobs in the system” I…

7 days ago

Remove old spooled files to keep track of the number of jobs in the system

The system value QMAXJOB (valid range: 32,000 - 970,000; default = 163,520) defines the maximum number of jobs that can…

1 month ago