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 queue.
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 MONMSG
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 ignored:
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 (*)) +
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)
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 */