QPRTJOB

Use this board for starting discussions, asking questions, and giving advice on RPG programming for the IBM i platform (and predecessors.)
jmendes
New User
Posts: 18
Joined: Thu Mar 17, 2011 7:38 am
First Name: Joao
Last Name: Mendes
Company Name: Banco Credibom, SA
Country: Portugal
Contact:

QPRTJOB

Post by jmendes »

Hi,
I know that this is not a RPG Problem but I need some assistance, and I'll post it any way.

I have a IWS Service that calls a RPG program, this program as a specific "Current User".
In this program I call another one that generates a spool file, this spool file is generated in a QPRTJOB job onwed by the "current user" not in the QUSER job that is actually running.

I looked into some IBM docs and could not find a way to get this job information so I can have access to the spool file.

Doe any one know can I get this job information, I know the job name, job user, but not the job number.

Thanks
João Mendes
Thanks,
João Mendes
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: QPRTJOB

Post by Scott Klement »

Hi João,

You're welcome to post general discussions here in the forum, and if I know the answer and have time, I'll be happy to assist.

What you're referring to is the way IBM i names printouts in a job. For security reasons, when a job switches user profiles in the middle (as opposed when the job started) the spooled file does not go under the same 'job id' as the job name. Instead, it goes used a QPRTJOB jobid with the userid of the user you've swapped to. That way, the spooled file is not viewable by other users besides the 'current user profile', unless they have the needed special authorities to view all jobs spools, of course.

If you want to know what the job info is after you create the spooled file, there's an API named QSPRILSP that will return the details of the last spooled file that was created.

Code: Select all

     D QSPRILSP        pr                  extpgm('QSPRILSP')
     D   RcvVar                   32767A   options(*varsize)
     D   RcvVarLen                   10I 0 const
     D   Format                       8A   const
     D   ErrorCode                32767A   options(*varsize)

     D SPRL0100        ds
     D   bytesRtn                    10I 0
     D   bytesAvl                    10I 0
     D   splfName                    10A
     D   jobName                     10A
     D   userName                    10A
     D   jobNbr                       6A
     D   SplfNbr                     10I 0
     D   SystemName                   8A
     D   CreateDate                   7A
     D                                1A
     D   CreateTime                   6A

     D ErrorCode       ds
     D   BytesProv                   10I 0 inz(%size(ErrorCode))
     D   BytesAvail                  10I 0 inz(0)
     D   MsgID                        7A
     D                                1A
     D   MsgData                   1000A

      /free

            QSPRILSP( SPRL0100
                    : %size(SPRL0100)
                    : 'SPRL0100'
                    : ErrorCode );

            if (BytesAvl > 0);
                // an error occurred.  Look at the data in
                // the ErrCode data structure for more
                // info.
            endif;

            // the SPRL0100 data structure now has
            //  all of the spooled file info

            *inlr = *on;

      /end-free 
jmendes
New User
Posts: 18
Joined: Thu Mar 17, 2011 7:38 am
First Name: Joao
Last Name: Mendes
Company Name: Banco Credibom, SA
Country: Portugal
Contact:

Re: QPRTJOB

Post by jmendes »

Scott,
Thanks for the solution, we've tested it and it works perfectly.

Thanks again,
João Mendes
Thanks,
João Mendes
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests