01 - Programming (EN)01e - Programming miscellanea (EN)

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)

About author

Head of Application development & Systems integration I have always worked on "i". Programmer, analyst, project manager, computer systems analyst, ... lots of hats but a single preferred platform. I collaborate with the FAQ400 community because I firmly believe in teamworking and I hope for a continuous and constant growth of the ecosystem of which I feel part.

Leave a Reply

%d bloggers like this: