Learn more ways to use exit programs for the Watch for Event exit point.
This is the third in a series of articles on watching for certain messages on your system and then making processing decisions based on those messages. The underlying technology being used is known as "watch" support and became available with V5R4.
The first article, "One Approach to System Automation," introduced the Start Watch (STRWCH) command and provided the source for a user exit program to run when the local system time changed due to Daylight Saving Time transitions. The second article, "Handling System Changes Automatically," discussed how the user exit program worked. If you have not read those two articles, you should do so before reading this article.
In this article, we will look at how to automate the re-enabling of a specific *USRPRF when the *USRPRF has been disabled because of too many invalid password attempts--that is, the number of signon attempts has exceeded the QMAXSIGN system value. In this situation, the system will send the message CPF1393 to the QSYSOPR and QHST message queues.
One watch-based approach to handle this situation is shown in the following user exit program, WCHCPF1393. The intent of this program is to determine whether the disabled user profile is 'GLAND' (George Land if you will) and, if so, to automatically re-enable the *USRPRF. If the *USRPRF is not 'GLAND', nothing is done--no message, no re-enablement, no anything.
dWchCPF1393 pr extpgm('WCHCPF1393')
d Type 10 const
d SsnID 10 const
d Error 10
d MsgDta likeds(ESCQWFM)
dWchCPF1393 pi
d Type 10 const
d SsnID 10 const
d Error 10
d MsgDta likeds(ESCQWFM)
dCmdExc pr extpgm('QCMDEXC')
d Command 65535 const
d LenCmd 15 5 const
d IGC 3 const options(*nopass)
/copy qsysinc/qrpglesrc,escwcht
dCPF1393 ds based(RplDtaPtr)
d qualified
d SbsD 10
d UsrPrf 10
d DevD 10
d NtwAddr 45
dRplDtaPtr s *
dCommand s 256
dRqdNbrParms c 4
dSessionName c 'ENB_GLAND '
/free
monitor;
// Check to make sure program environment is as expected
if %parms < RqdNbrParms;
dsply ('WCHCPF1393 received only ' + %char(%parms) + ' parms');
*inlr = *on;
return;
endif;
if Type <> '*MSGID';
dsply ('WCHCPF1393 received type ' + Type);
Error = '*ERROR';
*inlr = *on;
return;
endif;
if SsnID <> SessionName;
dsply ('WCHCPF1393 received SsnID ' + SsnID);
Error = '*ERROR';
*inlr = *on;
return;
endif;
if MsgDta.ESCMID00 <> 'CPF1393';
dsply ('WCHCPF1393 received message ' + MsgDta.ESCMID00);
Error = '*ERROR';
*inlr = *on;
return;
endif;
// Everything looks OK so get message replacement data
RplDtaPtr = %addr(MsgDta) + MsgDta.ESCORD;
// If *USRPRF is GLAND then re-enable
if CPF1393.UsrPrf = 'GLAND';
Command = 'CHGUSRPRF USRPRF(' + %trimr(CPF1393.UsrPrf) +
') STATUS(*ENABLED)';
CmdExc(Command :%len(%trimr(Command)));
endif;
// Set normal end of processing
Error = *blanks;
return;


Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.
IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn:
LATEST COMMENTS
MC Press Online