IBM has, for ages, provided a sample program to do this.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Vernon Hamberg
Sent: Wednesday, February 20, 2013 4:22 AM
To: Midrange Systems Technical Discussion
Subject: Re: Spool files

Hi John

You might not want to use a CL program, at least not ONLY a CL program.
Somewhere you'll need to process either a file or a user space.

Now in recent OS versions (at least V5R4) you can work with pointers in CL
and process a user space just fine.

You want to use the QUSLSPL API - list spooled files - you can specify a
certain OUTQ, then walk through the entries, then check the create date and
delete with DLTSPLF.

A Google of QUSLSPL reveals several example code sites -
(links to other examples)

In CL you can define a variable that is like a data structure, with *DEFINED
and variables based on a pointer, with *BASED. With these and integer
variable types, you can read the user space easily and use the information
to decide which ones to delete.


On 2/20/2013 4:32 AM, John Mathew wrote:


How to delete the spool files which are older than 7 days from a
particular queue.
Can some one please send me some sample CL program code which would help
me to achieve this.

Thanks in advance.


From: CRPence <CRPbottle@xxxxxxxxx>
To: midrange-l@xxxxxxxxxxxx
Sent: Tuesday, 19 February 2013 10:46 PM
Subject: Re: MONMSG issues

On 19 Feb 2013 13:01, ADriver@xxxxxxxxxxxx wrote:
I'm running into an issue with a program. Amongst other things I'm
trying to GRTOBJAUT to a bunch commands and it keeps dumping with
CPF2204 (User profile doesn't exist).
The dump is presumably for CPA0701 [or the CLLE equivalent] due to
an unmonitored exception message. The CPF2204 is a diagnostic
message, and that will not be the origin for the /dumping/ for the
error; i.e. the diagnostic is merely /logged/ to the program message

I want this to be a generic program I run on different systems, and
there will be some profiles that exist on some but not others.
Apparently then the Grant Object Authority request will not be
built dynamically for the system on which the request will be run, but
hard-coded and compiled static into a CLP or CLLE. In that case just
monitor for the exception, and in response to that error, as the coded
handler, verify that the only diagnostic messages are the CPF2204 for
user profile names that are acceptable to be ignored.

I'd rather not code IF this system DO... or IF EXIST ... for each
statement if I can avoid it.
Even if not coded fully dynamic, a list of only existing user
profiles as obtained from a list [effective array] could be specified
as elements on the USER parameter; replacing any missing *USRPRF
object with a mandatory user profile name. So for example if the list
of users to assign authority is (APPLUSER OPTIONAL) [coded as USER(&U1
&U2)] where user APPLUSER is mandatory and user OPTIONAL is optional
and does not exist, then the request coded as GRTOBJAUT USER(&U1 &U2)
could be modified so &U2 is changed from 'OPTIONAL' to 'APPLUSER' so
the request resolves to the redundant yet acceptable request:
GRTOBJAUT USER(APPLUSER APPLUSER). Another option is to ignore the
CPF2204 for optional users... described in code later below.

I tried MONMSG CPF2204 after the GRTOBJAUT statements in the CL, but
it keeps dumping on this message.
As described earlier, the CPF2204 is not the exception, so the
CPF2204 is not doing anything. More specifically, the exception is
CPF2227 but because that is not being monitored, the CL default
exception handler is presumably being called to send an inquiry
message which is replied to with 'D'=Dump in response.

Looking at the help text for GRTOBJAUT (and TAATOOLS DSPMONMSG),
CPF2204 is not listed as one of the messages that can be monitored
for with GRTOBJAUT. There are other MONMSG statements in this CL that
do work, although the one thing that stands out is that CPF2204 is a
DIAG message, not and ESC. Am I correct in assuming that's why the
MONMSG doesn't work?
Correct. The CPF2204 can not be monitored because that message is
not one of the messages issued as an exception message; thus why the
message is not listed in the help text for the command.

The following algorithm should suffice for ignoring some cases of
CPF2204 for a chosen user profile name, though easily expanded to
ignore multiple user profiles; noting effectively the same is done for
one [or more if expanded] mandatory user profiles that must not be


dcl &mk *char 04
dcl &mi *char 07
dcl &md *char 100/* cpf2204 &1 *char 10 UsrPrf name */
/* the length 100 covers most other possible diags */
dcl &up *char 10
dcl &xk *char 04 /* cpf2227 exception msg key; for resend */
?grtobjaut (mylib/uln*) *file aut(*all) ??user(bogus appUser myUsr)
monmsg cpf2227 exec(do)
rcvmsg pgmq(*same) msgq(*pgmq) msgtype(*excp) rmv(*no) +
rcvmsg pgmq(*same) msgq(*pgmq) msgtype(*diag) rmv(*no) +
keyvar(&mk) msgdta(&md) msgid(&mi)
if cond(&mi *eq ' ') then(goto NoMoreDiag)
if cond(&mi *eq 'CPF2204') then(do)
chgvar &up %sst(&md 1 10)
/* if &up in list_of_mandatory then bad_thing: */
if (&up *eq 'APPUSER ') then(do)
/* mandatory user can not be ignored; send diag as escape */
sndpgmmsg *n cpf2204 qcpfmsg tomsgq(*topgmq) topgmq(*prv (*)) +
msgdta(&md) msgtype(*escape)
enddo /* escape message terminates this pgm */
/* if &up in list_of_optional then(do) */
if (&up *eq 'BOGUS ') then(do)
/* remove any cases that are ignored */
rmvmsg pgmq(*same (*)) msgq(*pgmq) msgkey(&mk) clear(*bykey)
goto Next2204
else do /* only cpf2204 is processed by this pgm */
/* leave whatever is the unprocessed diag(s) */
/* resignal CPF2227 exception using the saved key */
call qmhrsnem (&xk x'0000000000000000')
enddo /* end-monmsg cpf2227 */


This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at

Return to Archive home page | Return to MIDRANGE.COM home page