?
Solved

Printing specific pages

Posted on 2005-03-15
12
Medium Priority
?
552 Views
Last Modified: 2012-06-21

Hi frnds ,
I have a query . I need to create a tool which prints a spool file with specific pages only..
As far as i know..this can be done using OVRDBF PAGERANGE option . I have read an article on Iseries network ( problem with remote queues ) http://www.iseriesnetwork.com/nwn/story.cfm?ID=10967
So..if this true then what things/issues i need to take care in my program ??
Pls explain in detail.
Your answers would be greatly appreciated.
Thanks and waiting for replies..

Raj
0
Comment
Question by:raj28
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
12 Comments
 

Author Comment

by:raj28
ID: 13552871
i.e this is a problem when spoolfiles are sent to a network printer - the full file is printed rather than the start/end pages that you requested.

raj.
0
 
LVL 9

Expert Comment

by:ShadowProgrammer
ID: 13553392
There are tools out there that will do this already.

But if you want to do your own,

You will need to create two physical files which are 1 character longer than the width of the spool file.
CRTPF FILE(TEMPLIB/PFILE1) RCDLEN(rcdlen+1)
CRTPF FILE(TEMPLIB/PFILE2) RCDLEN(rcdlen+1)

copy the spool file to first physical file...
CPYSPLF FILE(SPOOL) TOFILE(TEMPLIB/PFILE1) JOB(JOBNO/JOBUSER/JOBNAME)
SPLNBR(SPLFNBR) MBROPT(*REPLACE) CTLCHAR(*FCFC)

*FCFC (help from command CPYSPLF)            
    Specifies that the first character of every record    
    contains one of the ANSI forms control codes listed in
    the CL Reference manual.                    

Code Action before Printing a Line   (extract from CL refereence manual- CPYSPLF command)
’ ’      Space one line (blank code)
0       Space two lines
-       Space three lines
+       Suppress space
1       Skip to next channel 1
2       Skip to next channel 2
3       Skip to next channel 3
4       Skip to next channel 4
5       Skip to next channel 5
6       Skip to next channel 6
7       Skip to next channel 7
8       Skip to next channel 8
9       Skip to next channel 9
A       Skip to next channel 10
B       Skip to next channel 11
C       Skip to next channel 12

Write your program to copy the appropriate pages of information from PFILE1 to PFILE2,
you can look for control character 1..9,A,B,C as these indicate a new page and keep an internal count of page numbers.

Then copy this file back to a spool file with EXACTLY THE SAME attributes as your original spool file after applying the override
OVRPRTF FILE(QSYSPRT) TOFILE(SPLFLIB/SPOOLF) CTLCHAR(*FCFC)    <<tells it use the *FCFC ctrl chars>>
CPYF FROMFILE(TEMPLIB/PFILE2) TOFILE(*PRINT)

This should produce a spool file with just the pages you specified.

An Alternative approach would be to use *PRTCTL instead of *FCFC
*PRTCTL   (help from command CPYSPLF)                                                          
    Specifies that the first four characters of every record contains
    skip- and space-before values useful in high-level language
    programs.  This code can be viewed as SSSL, where SSS is the
    skip-before line value and L is the space-before value.    

As this uses 4 characters you will need to create one physical files which is 4 characters longer than the width of the spool file.
CRTPF FILE(TEMPLIB/PFILE1) RCDLEN(rcdlen+4)

copy the spool file to first physical file...
CPYSPLF FILE(SPOOL) TOFILE(TEMPLIB/PFILE1) JOB(JOBNO/JOBUSER/JOBNAME)
SPLNBR(SPLFNBR) MBROPT(*REPLACE) CTLCHAR(*PRTCTL)

Your program would need to read this file (internally defined to separate skip- space- splf data) and select the pages you want then print these out to a spool file with EXACTLY THE SAME attributes as the original spool file.  Your program would need to apply the skip- and space- before values as required.

Tony.
0
 
LVL 9

Expert Comment

by:ShadowProgrammer
ID: 13553464
Made a mistake..... In copying the data back to a print file for *FCFC..  you need the following commands..

Then copy this file back to a spool file with EXACTLY THE SAME attributes as your original spool file after applying the override
OVRPRTF FILE(SPLFLIB/SPOOLF) CTLCHAR(*FCFC)    <<tells it use the *FCFC ctrl chars>>
CPYF FROMFILE(TEMPLIB/PFILE2) TOFILE(SPLFLIB/SPOOLF)

nb. You could always amend the OVRPRTF to use QSYSPRT and override the attributes to match the original spool file + CTLCHAR(*FCFC), then CPYF FROMFILE(TEMPLIB/PFILE2) TOFILE(QSYSPRT)

Tony.
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:raj28
ID: 13553652
Hi tony,
Thx for quick reply. I want to confirm one thing - Will PAGERANGE option works in LAN i.e it gives problem only to remote queues ?  and other thing is how can i retreive the spool file width in program i.e rcdlen ??

thanx in advance,
Raj
0
 
LVL 9

Expert Comment

by:ShadowProgrammer
ID: 13554133
Raj,

easy one first... I don't believe page range will work in LAN either.

I am afraid I am a dinosaur and haven't got into APIs yet, but there are print APIs which will help unfortunately I can only point you in their direction - I can't help you to use them.
The link  http://publib.boulder.ibm.com/iseries/    links into the IBM Info centre, choose the appropriate country, language and os release - then you need to look for APIs under the programming section.
I have a problem getting the left hand navigation pane to show (JAVA problems I think) - but use the "site map" link from there or use the link  http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzahgicprinttoc.htm   which will take you to a list of downloadable PDFs - and the navigation pane is ok (for me) !!!

If you have the time - get into APIs to write commands for the 21st Century !!

My old fashioned approach would be long winded as you would have to work with splf attributes into "another" spool file [IBM won't allow an output file], which could be copied into "another" physical file and then read this file to identify the record length and any other attributes you want.

Tony.
0
 
LVL 9

Expert Comment

by:ShadowProgrammer
ID: 13554154
Raj,

Extra info - in the API examples V5R2 there is a "Delete Old Spool Files" command that may give you some ideas.

Tony.
0
 

Author Comment

by:raj28
ID: 13562742
Hi tony,
I copied the spool file to PF using *FCFC abut it appears '1' in PF as First character whenever new page starts . So how can i get specific pages  ?? Also one more thing - *FCFC doesn't work for externally described printer files .( CL reference manual ). any workaround for this ??

Raj..
0
 
LVL 9

Expert Comment

by:ShadowProgrammer
ID: 13563111
I am pretty sure the '1' is a skip to new page, line 1... some reports may start printing on line 2 or 3 - IBM go upto line 12 - probably to cater for special stationery (eg. invoices).

In the extract IBM say
          'n' skip to channel n
I think this translates to
           skip to next page, line n

As I said I think you will have to either
(a) pick up the Page Number from the data on first Line if you know the report you are dealing with
or
(b) if you want to be generic, then you will have to count the page numbers in the program, by looking for '1'..'9','A','B' or 'C' and incrementing page count.

You can't copy the new file back to an external printer file, which is why I said "Then copy this file back to a spool file with EXACTLY THE SAME attributes as your original spool file", it requires the same attributes but needs to be just an ordinary print file (sorry I didn't make that clear).
You could just use the over ride printer file to set up the right attributes after retrieving them from the spool file.

If you were making it a generic utility, you would need to identify the spool file, retreive the attributes incl record length. Create workfiles with rcdlen=spool len+1 and build an override print file command with the correct attributes then do all the copying about.

Maybe initially to get you up and running, create appropriate workfile(s) and print file(s) with the same attributes as the report(s) you are interested in at the moment and then work out later how to retrieve the attributes and make the utility more generic.

Tony.
0
 

Author Comment

by:raj28
ID: 13563420
Hi tony..
U mean to say..i have to update PF wth page number ?

Raj
0
 
LVL 9

Accepted Solution

by:
ShadowProgrammer earned 800 total points
ID: 13565182
Raj,

I am not explaining this very well... try this...

Lets say you have a 200 page report and you want to print pages 10 through 12.

After you have copied the 200 page report into file1, your program will need to read through data in file1 and "find" page 10, then start writing the data into file2 until you reach page 13 then exit; you can then copy file2 into a new spool file.  

Two ways you can "find" page 10
(a) manually count the codes which skip to new page (my recommended choice - see below)
(b) Page number is printed on the report and is therefore in the record somewhere - but this is not guaranteed to be on first line of each page because it depends on programmer and any programming standards.
eg.
line1:                                        COMPANY NAME
line2:   date  time                                                                 page xxxx
SO STICK WITH option (a) as described below....

NB. The printed page numbers in the new print will still show page 10, page 11 and page 12.  (Hope thats ok !!!)

Example...

Control program
- retrieve spool file attributes etc, create work files, copy spool file to File1
--- Call process program passing StartPage and EndPage
- Copy File2 to create new spool file

pseudo code for process program...

/* receive parameters for StartPage End Page */
StartPage = ParmStartPage
EndPage = ParmEndPage

PageCount = 0

/* Read Through File1 until reach Start Page */
Dou pagecount < StartPage
   Read    File1rcd
   Code = %substr(File1rcd,1,1)
   If Code in ('1','2','3','4','5','6','7','8','9','A','B','C') then
     PageCount=PageCount + 1
   Endif
EndDo

/* Now have first record of page 10 */
/* Copy File1 rcds to File 2 until reach page after EndPage */
Dou Pagecount > EndPage
   File2rcd = File1rcd
   Write File2 Rcd
   Read    File1rcd
   Code = %substr(File1rcd,1,1)
   If Code in ('1','2','3','4','5','6','7','8','9','A','B','C') then
     PageCount=PageCount + 1
   Endif
EndDo
/* Finished writing out File2 records */

EndProcessProgram

Does this make it clearer ?

Tony
0
 
LVL 27

Expert Comment

by:tliotta
ID: 13571454
raj28:

Page ranges can work fine with LAN printers as long as they're set up correctly in the first place. In general, page ranges are not easily supported by LPR/LPD. That's a problem with that protocol to begin with, but QUSRTOOL has a tool that helps. See it on your system as the tool named TSPRWPRI.

But for many systems, there's a far better way -- don't use LPR/LPD and remote outqs. Instead, create a remote printer device description and use it with a local outq.

E.g., create a printer device as a *LAN 3812 model 1. Assign LAN attachment as *IP and supply the proper IP address and port number. (For an HP LaserJet for PJL, the port is usually 9100.) The manufacturer type and model would be *HP4000 in our case. I usually use *HPPJLDRV as the system driver program. Other parms can be set as needed.

It'll have an outq when it's created and you'll handle the outq and its writer just like any direct-attached printer. The one in the next room over from me is attached to the LAN with an HP jetdirect printer server adapter in the back.

Hardly anything special about it.

Tom
0
 
LVL 27

Expert Comment

by:tliotta
ID: 13577487
I'm still unclear why any programming is needed at all. I just created a new LAN printer device description for an HP LaserJet 8150 that's plugged directly into our LAN over on the other side of our building. Took about 2 minutes. I now have full page range support from the AS/400.

In fact, the original question pointed to an article that described exactly how to do this. The question was "what things/issues i need to take care in my program ?"

The answer is "Nothing."

When you want to print, you simply specify the page range, e.g.:

 ==>  chgsplfa  pagerange( 5 10 )

...to print pages beginning at page 5 and ending at page 10. Release the spooled file and the page range prints. Simple.

Well, technically, I suppose the things to take care of in a program _could_ be making sure that the spooled file is created on HOLD or on an outq that doesn't have a writer active that will print the spooled file immediately; but that's standard stuff.

Tom
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introducing Priority Question, our latest feature.
The Summer 2017 Scholarship Winners have been announced!
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question