51
286
iSeries Printing VI: Delivering the Output of e-business
14.3 Planning for the index function
For more information on the index function of the CRTAFPDTA command, see
Chapter 5, “Infoprint Server for iSeries: CRTAFPDTA” on page 149.
Super Sun Seeds invoices are produced using the INVSCS program. A copy of
this program is shipped with the Infoprint Designer for iSeries product. You can
find it in the IPDATA library. See
Infoprint Designer for iSeries: Getting Started
,
G544-5773, for information on the IPDATA library and using the programs in it.
14.3.1 Why CRTAFPDTA is used
To send individual invoices within a single spooled file to different addresses, you
must add index records to the spooled data. Chapter 4, “Using the Infoprint
Server for iSeries PDF transform” on page 103, and the
Infoprint Server for
iSeries User’s Guide
, G544-5775, describe how to use the DDS keywords
STRPAGGRP and ENDPAGGRP to add index records. However, these keywords
require that the file be generated with DEVTYPE(*AFPDS), and cannot be used
with a printer file that uses page definitions and is generated with
DEVTYPE(*LINE).
Super Sun Seeds is using Infoprint Designer for iSeries to develop this
application. The layout component of Infoprint Designer produces page
definitions that must be used with line data. Consequently they need to find an
alternative to those DDS keywords. The CRTAFPDTA command, which is also
part of Infoprint Server for iSeries, has the ability to generate index records for a
spooled file that contains line data.
14.3.2 Setting up a target file for CRTAFPDTA
The CRTAFPDTA command generates AFPDS files in an Integrated File System
(IFS) directory. The index entries generated within the spooled file are used by
the PDF generator to separate the one large spooled file to individual files for
each customer and to look up the e-mail address based on the customer number.
The CRTAFPDTA command directs its output to any directory in the IFS that you
specify. However, in the next step of this process, PRTAFPDTA expects the data
to be in a physical file. Before you run the CRTAFPDTA command, you must
create the physical file that is to receive the output. You can create the file once,
and then clear it out each time. Or, you can create a new file each time with a
different name that identifies the run date or some other meaningful information.
This example shows how to create the file called AFPOUT in library MYLIB. The
record length is not critical, but it must be specified. You must specify
LVLCHK(*NO) to prevent getting a Level Check error when you run the
PRTAFPDTA command. You must allow for at least four new members to be
added to the file:
CRTPF FILE(MYLIB/AFPOUT)
RCDLEN(80)
LVLCHK(*NO)
MAXMBRS(*NOMAX)
You can enter the IFS path to this physical file in each of the TOIDXSTMS,
TOMRGSTMF, TORSCSTMF, and TOSTMF parameters in the CRTAFPDTA
command. However, you may find it easier to make the AFPOUT file accessible
45
Chapter 14. End-to-end example
287
as your current directory and then indicate in each of those four parameters that
you want the output to go to *DFT. This is done using CHGCURDIR. You can
reference the file by its path in the IFS:
CHGCURDIR DIR(‘/QSYS.LIB/MYLIB.LIB/AFPOUT.FILE’)
This step is included in the job that is run each time you want to perform the
e-mail function.
14.3.3 Requirements of the CRTAFPDTA index function
The indexing function essentially looks for two types of information: the trigger
fields and the index fields.
The combination of fields defined as the trigger tell the indexing function where
each new customer invoice should begin. This allows for a different number of
pages per invoice. The first of the trigger fields defined has a second role of being
an
anchor point
. This means that all other trigger fields and index fields are
defined by their relative location with respect to the first trigger field, or anchor
point.
The index fields are used to identify a distinct piece of data in each separate
invoice. The combinations of fields used for the index are used by the e-mail exit
program to look up the actual e-mail address of the recipient of the invoice. In this
example, you use only one index field (the customer number).
14.3.4 Changing the invoicing program to accommodate the index requirements
In the case of Super Sun Seeds, one identifying feature to start each new invoice
is the fact that “Page 1” prints on the bottom of the first page of each invoice,
always on line 63. You may think that this would be the ideal trigger point or
anchor. However, depending on how many of the invoice detail lines actually have
data on them, there may be a different number of “records” in the spooled file
before the record that has the page number on it.
Consequently, CRTAFPDTA cannot use this field as the index trigger. This is a
common occurrence when the application uses DDS keywords SKIPA or SKIPB,
or other similar language instructions, to skip over an unknown or variable
number of lines.
To work around this problem, the application program and associated DDS are
modified slightly to output the word “NEW” on the same line as the company
name on the first page of a new invoice. This record line is always in the same
relative position on the page, and the customer number is always four records
after it.
You did not map the word “NEW” when you redesigned the Infoprint Designer
project as described in 14.2.1, “Creating a new Infoprint Designer project for
These programming changes may not be necessary for all applications. If the
trigger fields and index fields are always in the same relative positions to each
other in your application, you do not have to modify the program.
Note
62
288
iSeries Printing VI: Delivering the Output of e-business
e-mail” on page 285. Therefore, it does not show on the final document that is
delivered to the customer.
When planning for the index function, you may find it helpful to copy the spooled
file to a physical file using the Copy Spooled File (CPYSPLF) command and
specifying CTLCHAR(*FCFC). Create the physical file with a record length one
record longer than that of the spooled file, for example 81 or 133 record length for
original spooled files that have used the common length of 80 or 132. The
commands you use to do this are:
CRTPF FILE(mylib/CPYSPLF) RCDLEN(133) MAXMBRS(*NOMAX)
CPYSPLF FILE(INVSCS) TOFILE(mylib/CPYSPLF) JOB(number/user/name) SPLNBR(1)
TOMBR(INVSCS) CTLCHAR(*FCFC)
If you do not know the job information for your spooled file, use the F11 key from
either a WRKSPLF or WRKOUTQ display.
If you view the file with the Display Physical File Member (DSPPFM) command,
you see a good representation of how the spooled data is presented to the
CRTAFPDTA process. Figure 183 shows the first page of the Super Sun Seeds
invoice after the modification to add the word “NEW” at the beginning of each
invoice. This becomes the first trigger field and is represented in the CRTAFPDTA
command as
IDXTRG((* 3 ‘NEW’))
. This tells the indexing program to look in any
record, starting in position 3 for the string “NEW”. Note that the carriage control
byte in column 1 is included in the position count. Note also that you must specify
an asterisk
(*)
for the record number value of the first trigger field.
Figure 183. Sample spooled file after CPYSPLF with CTLCHAR(*FCFC)
The customer number appears four records below the trigger field. It is
represented in the CRTAFPDTA command as
IDXTAGFLD((4 15 6))
. This tells the
indexing program to look four records
after
the anchor point set by the first trigger
field. Then, starting in position 15, the program uses the next six characters as
Display Physical File Member
File . . . . . . : CPYSPLF
Library . . . . : MSHNIER
Member . . . . . : INVSCS Record . . . . . : 1
Control . . . . . Column . . . . . : 1
Find . . . . . . .
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8.
1
-
-
-
0 NEW IMPROVED PRINTING CORP SAME
PERFORMANCE BOULEVARD
PRINTERSVILLE
CO 45789-2637
- 100 31300 3/28/01 4/28/01
0 BEST WAY 3/28/01 NET 30 YOUR PRINTER REP
-
1 CT 00000300 HIGH ALTITUDE WATERMELON 1.01 1.01
1 PK 01100517 SPARTAN SEEDS 2.39 2.39
9 PK 04569870 NORTHERN LITE BLUE SPRUCE 858.32 7,724.88
12 BX 11005004 BUSH GREEN SEEDS 2.50 30.00
12 CT 11005011 LASSO RED SEEDS 892.23 10,706.76
26 PK 11005018 EARLY BANTAM SEEDS .38 9.88
5 BX 11057893 AFRICAN DAISY, SEEDS 2.35 11.75
How to C#: Special Effects Erase. Set the image to current background color, the background color can be set by:ImageProcess.BackgroundColor = Color.Red. Encipher.
how to edit and delete text in pdf file online; how to copy text out of a pdf
50
Chapter 14. End-to-end example
289
the first index. The customer number, as shown in the example, appears to be
only three characters long. However, by inspecting the DDS for the application,
you can see that it can have up to six characters. If you set the index based only
on the three characters visible in the one example, you may have problems at a
future time. This shows where it is important to have the original application
documentation available.
Be aware of the fact that CRTAFPDTA looks at the relative positions of the
records
in the spooled file, not the relative lines that they may end up printing.
The word “NEW” and the customer number are four records apart in the file, but
print 6 lines apart, on lines 12 and 18 respectively. This is because there is a
carriage control character “-” in position 1 of the record containing the customer
number, which inserts a triple space at print time.
This step, if necessary, is done as part of the one-time setup.
14.3.5 Running the CRTAFPDTA command
Now that you have set up a destination for the output of the CRTAFPDTA
command, and have identified the trigger fields and index fields, you are ready to
run the CRTAFPDTA command as shown below. The four files that are generated
by this command are placed in the default directory, which is set up to be
AFPOUT, as described in 14.3.2, “Setting up a target file for CRTAFPDTA” on
page 286:
CRTAFPDTA FROMSPLF(INVOICE)
TOSTMF(*DFT)
JOB(number/user/name)
SPLNBR(*LAST)
FORMDF(QGPL/EMAIL)
PAGDFN(QGPL/EMAIL)
TOIDXSTMF(*DFT)
TORSCSTMF(*DFT)
IDXTRG((* 3 ‘NEW’))
IDXTAGFLD((4 15 6))
IDXTAG((‘Customer Number’ (*IDXTAGFLD1)))
RSCDTA(*FORMDF)
TOMRGSTMF(*DFT)
After the command is run, there are four members in the physical file AFPOUT:
• OUTPUTAFP: The resolved AFPDS document
• OUTPUTIDX: The index records
• OUTPUTRSC: The external resources
• OUTPUTMRG: Merged output; this contains the information from the other
three members
These names are automatically assigned by CRTAFPDTA because a value of
*DFT was specified for each of the TOxxxSTMF variables. It is possible to specify
different names for these files. See Chapter 5, “Infoprint Server for iSeries:
CRTAFPDTA” on page 149, for more information.
You use the member OUTPUTMRG. It contains the AFPDS data, along with the
form definition resource and the index records. The form definition is needed
inline to view the spooled file using the AFP Viewer, as shown in 14.4.2,
“Checking your file with the AFP Viewer” on page 291.
46
290
iSeries Printing VI: Delivering the Output of e-business
This step must be included in the job that runs for each e-mail.
14.4 Respooling the file using PRTAFPDTA
You cannot use the output of the CRTAFPDTA command directly by the PDF
conversion process until you regenerate it back as a spooled file. The system
command, Print AFP Data (PRTAFPDTA), is included with OS/400 that you use to
do this:
PRTAFPDTA FILE(AFPOUT)
MBR(OUTPUTMRG)
DEV(MYOUTQ)
FORMDF(*INLINE)
FIDELITY(*CONTENT)
The prompt for the parameter DEV implies that a physical device must be named
as the destination for this command. An unqualified name of an output queue
works just as well and may be preferred.
The form definition that was captured in the OUTPUTRSC member is included
inline with this command. This facilitates using it with the AFP Viewer. See 14.4.2,
“Checking your file with the AFP Viewer” on page 291.
The spooled file that is generated from the PRTAFPDTA command has the same
name as the member used to create it (in this case, OUTPUTMRG). This same
name is ultimately used in the subject line of the e-mail. You may choose to
rename the member prior to running the PRTAFPDTA command:
RNMM FILE(AFPOUT)
MBR(OUTPUTMRG)
NEWMBR(EINVOICE)
This step must be included in the job that runs for each e-mail.
14.4.1 Directing the output of PRTAFPDTA
You may choose to direct the output of the PRTAFPDTA step directly to the output
queue being used by the PDF process. However, it may be prudent to direct it to a
temporary output queue and change the attribute to SAVE(*YES) as you move it
to the PDF output queue.
14.4.1.1 Changing the USRDTA parameter
You may also add some information to the User Data (USRDTA) attribute this
time. The USRDTA parameter is picked up in the e-mail exit program and you may
find a use for it there. For example, you may use this field to look up a greeting
message to include in the body of the email. In doing so, the program does not
have to be changed if the message changes.
To move the spooled file to the PDF output queue and to set other parameters as
described in this section, use the Change Spooled File Attributes (CHGSPLFA)
command.
CHGSPLFA
FILE(EINVOICE)
JOB(jobno/user/jobname)
SPLNBR(n)
OUTQ(*LIBL/PDF)
28
Chapter 14. End-to-end example
291
SAVE(*YES)
USRDTA('HelloWorld')
This step must be included in the job that runs for each e-mail.
14.4.2 Checking your file with the AFP Viewer
This may be a good time, especially while the application is under development,
to verify that your index selection is correct. You can do this using the AFP
Viewer. Start Operations Navigator from Client Access or Client Access Express.
If you do not already have a session with your iSeries server, start the connection
and log on. Select Basic Operations and then click Printer Output. Select your
new spooled file from the list.
The index function is illustrated when by selecting Search-> Find group. The
complete index generated by the CRTAFPDTA is a combination of the customer
number and a document sequence number. Figure 184 shows an example of
what should appear.
Figure 184. Using the AFP Viewer with an indexed spooled file
This step is helpful during the initial setup and testing of the e-mail process. It
may also be used at any time with the production files.
14.4.2.1 Font mapping with AFP Viewer
When using the AFP Viewer, you may find you see messages indicating that it
cannot find the requested fonts. This is because Infoprint Designer references
fonts by what is known as the
Alternate Coded Font Identifier
, where the AFP
Viewer only maps the standard Coded Font names. To rectify the situation, the
font mappings for the missing fonts must be appended to the bottom of the
ICODED.FNT file that is used by the AFP Viewer.
52
292
iSeries Printing VI: Delivering the Output of e-business
For the Super Sun Seeds case study, add the following entries to the table:
XZ4010=CZ4200,T1V10037
XZH0F0=CZH400,T1V10500
XZH0E0=CZH300,T1V10500
XZH010=CZH200,T1V10037
XZ5010=CZ5200,T1V10037
XZN0E0=CZN300,T1V10500
If you find that you are missing entries for other coded fonts, you can determine
the corresponding character set and code page by using the Work with Font
Resources (WRKFNTRSC) command and looking at the description of the
iSeries coded font object as shown in Figure 185.
Figure 185. Displaying the description of a coded font object
This step is done as part of the one-time setup.
14.5 Converting the spooled file to PDF and sending it as an e-mail
There are a number of steps to do when preparing to convert a spooled file to a
PDF file and send it to the appropriate destination via e-mail.
14.5.1 Enabling OS/400 to send e-mail
There are some system tasks the must be done to enable the iSeries server to
send e-mail. These are described in Appendix A of the
Infoprint Server for iSeries
User’s Guide
, G544-5775.
If your iSeries server is not already set up for e-mail, you must do this step as part
of the one-time setup.
14.5.2 Configuring a PDF device and PSF configuration object
As described in 4.3, “Setting up your PDF virtual printer” on page 108, the PDF
creation function depends on a Printer Device Description with the appropriate
PSF configuration object being configured. Refer to that section for additional
details on the parameters.
For the Super Sun Seeds e-mail function, the Device Description and PSF
configuration object are created as follows:
CRTDEVPRT DEVD(PDF)
DEVCLS(*LAN)
TYPE(*IPDS)
MODEL(0)
LANATTACH(*IP)
AFP(*YES)
PORT(5013)
Change Object Description (CHGOBJD)
Object . . . . . . . > XZN0E0 Name, generic*, *ALL
Library . . . . . > QFNTCF Name, *LIBL, *USRLIBL...
Object type . . . . > *FNTRSC *ALL, *ALRTBL, *AUTL...
Text 'description' . > 'Charset CZN300 and Codepage T1V10500 at
10-pt’screen.
Display Font Resource Attributes
System: BLDASL1
Font Resource . . . : XZN0E0
Library . . . . . : QFNT10
Object attribute . . : CDEFNT
Text . . . . . . . . : Charset CZN300 and Codepage T1V10500 at 10-pt
Documents you may be interested
Documents you may be interested