Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 492
  • Last Modified:

Is there way to release a range of pages of the spool file ?

Hello Friends Hope everybody is fine.

I would like to know is there way to release a range of pages of the spool file at a time based on some triggering action.
What is the way to find out the name/Latest the Spool file from RPG ?
TIA
MW
0
midwestexp
Asked:
midwestexp
  • 4
2 Solutions
 
tliottaCommented:
midwestexp:

Call the Retrieve Spooled File Attributes (QUSRSPLA) API.

I don't have a good example, but can show some basics. Basic call is like:

------ Begin paste
     H indent( '  ' )

      *--------------------------------------------------
      *  Used to receive splf attributes...
      *--------------------------------------------------
     D SplFADS         ds          1480
     d  SFABRtn                      10u 0
     d  SFABAvl                      10u 0
     d  SFAIntJob                    16
     d  SFAIntSpl                    16
     d  SFAJob                       10
     d  SFAUser                      10
     d  SFANbr                        6
     d  SFASplF                      10
     d  SFASplNbr                    10u 0
     d  SFAStatus            101    110
     d  SFAPages             141    144u 0
     d  SFAOpnDate           203    209
      *--------------------------------------------------
      *  Fields used in calculations
      *--------------------------------------------------
     D SplNbr          s              7p 0
     D SplFName        s             10

     D JobDS           ds
     d  Job                          10
     d  User                         10
     d  Nbr                           6
      *--------------------------------------------------
      *  Constants used in calculations
      *--------------------------------------------------
      *
      *  Constants used for indicator identification
      *
     D ERR             C                   const( 98 )
      *
      *  Constants used for general work
      *
     D ERRMSG          C                   const( 'Error detected (C G)' )
      *--------------------------------------------------
      /EJECT
      *--------------------------------------------------
      *  Procedure definition
      *--------------------------------------------------

     D SplfChsr        PR                  extpgm( 'SPLFCHSR' )
     D  QSpcNam                      20a
     D  PLib                         26a

      *--------------------------------------------------
      *  Procedure Interface
      *--------------------------------------------------

     D SplfChsr        pi
     d  QSpcNam                      20a
     d  PLib                         26a
      /eject
      *  Prototype for QUSRSPLA API
     D QUSRSplA        pr                  extpgm( 'QUSRSPLA' )
     D  SplRcvVar                  1480a   const
     D  LenRcvVar                    10i 0 const
     D  Format                        8    const
     D  QJob                         26    const
     D  IntJob                       16    const
     D  IntSplF                      16    const
     D  SplF                         10    const
     D  SplNbr                       10i 0 const
     D  QUSEC                     32783

      *--------------------------------------------------
      *  MAIN Section...
      *--------------------------------------------------
      *

     c                   exsr      SplFAttr

     C                   exsr      DONE

     C                   return

      *--------------------------------------------------
      /EJECT
      *--------------------------------------------------
      *  SplFAttr: Get spooled file attributes...
      *--------------------------------------------------

     C     SplFAttr      BegSr

      *
      * Get resolution of *INT values...
      *
     C                   eval      QUSBPRV = 52
     C                   eval      QUSBAVL = 0
     C                   eval      SFABAvl = 1480

     C                   CallP     QUSRSplA(
     c                                       SplFADS
     c                                     : %size( SplFADS )
     c                                     : 'SPLA0100'
     c                                     : '*'
     c                                     : ' '
     c                                     : ' '
     c                                     : SplFName
     c                                     : -1
     c                                     : QUSECDS
     c                                     )
      *
      * Check for errors on QUSRSPLA
      *
     C                   if        QUSBAVL > 0
     C                   movel     'QUSRSPLA'    APINAM           10
     C                   exsr      APIERR
     C                   end

     C                   EndSr
      *--------------------------------------------------
      /EJECT
      *****************************************************************
     C     APIERR        BegSr
      *
      * Log any error encountered, and exit the program
      *
     C     APINAM        dsply
     C     QUSEI         dsply

     C                   exsr      DONE

     C                   EndSr
      *****************************************************************
     C     DONE          BegSr
      *
      * Exit the program
      *
     C                   eval      *INLR = '1'
     C                   return
     C                   EndSr
      /EJECT
------ End paste

That's all torn out of a function that I use to list various spooled files and make selections. Nearly all of it is gone from what I pasted and some of what I pasted was also changed to be more relevant to you.

In short, you call QUSRSPLA with '*' for qualified-job-name, the name of the spooled file and a value of -1 for the spooled file number to indicate the last spooled file of that name from that job. (The '*' in the qualified-job-name parameter means "this current job". You can put a different qualified name in there if you have the authority to that job.)

As a copy/paste with major mods, the example code is purely for illustration. Maybe it's all you need, but ask more if you need more. Just don't expect it to compile and actually do anything 'cuz it ain't a whole program.

Tom
0
 
tliottaCommented:
One item I can see that might not make sense:

     C                   eval      QUSBPRV = 52
     C                   eval      QUSBAVL = 0

Those statements refer to the error-code data structure, QUSECDS. It's pretty much the standard IBM-supplied structure, just not shown in the code.

The comment just prior to those lines also won't make sense. It refers to some of the stuff that was cut out where I'm setting up to call the API using "internal" spooled file identifiers. All of that is cut out, and the example just uses the job name and spooled file name and number. No need to make the APAI more complex.

Retrieving and using "internal" job and spooled file identifiers can speed things up a little when you have to handle tens of thousands of entries. But that's beyond this example.

Tom
0
 
tliottaCommented:
...and now that I've gone back and looked things over, perhaps I misunderstood the whole question -- "...find out the name/Latest the Spool file from RPG"?

Are you asking if RPG can access info about the last spooled file it created? Or are you asking how to find out what the last spooled file was created in some other job? Or...?

Perhaps instead you need the List Spooled Files (QUSLSPL) API to create a list of spooled files that came out of a(nother) job? A bit more complex, but not too bad especially if you've used the list APIs and user spaces before.

Tom
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
daveslaterCommented:
Hi
why not simply muse the Infds go get the details.

FMYFILE O F 132 PRINTER INFDS(OPNFBK)

DOPNFBK DS
D FILE_NAME       83     92      * File name
D LIBRARY            93    102     * Library name
D SPOOL_FILE   103    112     * Spool file name
D SPOOL_LIB     113    122     * Spool file lib
D SPOOL_NUM   123    124I 0 * Spool file num

Ensure the spool file id held

Chrprtf SPOOL_FILE  Hold(*yes)

then issued the
CHGSPLFA FILE(&SPOOL_FILE) SPLNBR&SPOOL_NUM) PAGERANGE(1 5)  

and finally release it
rlssplf

Dave
0
 
tliottaCommented:
Minor note... 'page range' is ineffective for basic IP printers; it is generally ignored. Some setup and planning is required if page-range control is needed for simple LPR/LPD for example.

Tom
0
 
midwestexpAuthor Commented:
Thank You All , i am sorry for the later responce.

MW
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now