Make ‘System Request 3’ do WRKJOB instead of DSPJOB

AS400

Dec 12

AKA Command Line Access from System Request 3

If you are an IBM I software developer or power user – then that headline will make sense. In fact, I can guarantee that’s the only reason you discovered and are reading this page. System Request 3 makes every RPG programmer twitch 3 fingers ready to reach those buttons on the keyboard.

If the phrase “sys req 3” means nothing to you then *cough* don’t read any further. #NothingToSeeHere #MoveAlongMoveAlong

Invoke WRKJOB from SYSRQ/3

By default IBM i shows you DSPJOB when you do a System Request 3 – sometimes its useful to get command line access from this (especially when debugging programs) and its simple to do by changing the system default from DSPJOB to a WRKJOB. Of course, limited capability users wont know the difference but users with command line access can now party.

The value that is invoked when you press the System Request function key (ie: SHIFT ESC) is stored in QCPFMSG

WRKMSGD MSGID(CPX2313) MSGF(QCPFMSG)

You COULD change this message description – not a good idea since it’s a system wide change and you need hefty authority to change a system supplied object – and it would immediately invoke the command defined at that position from the SysRq Menu.

But – much preferred solution is to create a new Message file in your library and use OVRMSGF during your login routine.

So try this:

CRTMSGF MSGF(YOURLIB/OVRMSGF) 
 TEXT('Message file with changed CPF messages') 

Now we need to add a duplicate of the message that we want to change. For this message (CPX2313) we could add it using the EDTMSGD tool from Projex4i like this:

PROJEX4I/EDTMSGD MSGID(CPX2313) 
 FILE(QCPFMSG) 
 COPY(*YES) 
 COPYFILE(OVRMSGF)

Or if you dont have Projex4i installed (and why not?) then you can try it manually like this:

ADDMSGD MSGID(CPX2313) 
MSGF(YOURLIB/OVRMSGF) 
MSG('ENDRQS WRKJOB DSPMSG SNDMSG SIGNOFF DSPMSG DSCJOB DSPWSUSR ENDRDBRQS') 
SEV(0) 
ALROPT('*NO')

NOTE: the second command option is sysrq/3 – changed from DSPJOB to WRKJOB

Next add a line to your signon program saying

OVRMSGF MSGF(QCPFMSG) TOMSGF(YOURLIB/OVRMSGF) SECURE(*YES)

Here is a super simple example of a signon program

/* - SIMPLE SIGNON PROGRAM ---------------------------------- */ 
/* Super Simple - Proof of Concept to show how easy it is to */ 
/* change system messages per user */ 
/* ---------------------------------------------------------- */ 
 PGM 
 
 MONMSG MSGID(CPF0000) /* Global monitor because we + 
 dont like to see error messages during signon */ 
 
 OVRMSGF MSGF(QCPFMSG) TOMSGF(LITTENN/OVRMSGF) SECURE(*YES) 
 
 CALL PGM(QCMD) 
 
 RETURN 
 ENDPGM

Obviously you will need to change your signon for your user to point at that:

CHGPRF INLPGM(YOURLIB/SIGNON)

Then when you signon you can edit your message file and see the result immediately. If you have it set to DSPJOB you will see a DSPJOB when you press SysRq/3, if you change it to WRKJOB you will that. Be careful to keep the equal distant spacing in the message.

Obviously – you could make these system request options call any other command if you wish.

#enjoy 🙂

 

Follow

About the Author

IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.

  • Alex Kuzyk says:

    When I press the System Request 3, then instead of WRKJOB action is carried out *SYSTEM/WRKJOB action.
    An error appears inside LOG:
    Object QGEXSTAT in library * LIBL not found.
    Unable to open panel group.
    Where is the problem?
    Thanks,
    Alex Kuzyk

  • Nick Litten says:

    When you say “error appears inside LOG” – do you mean your job log?

    I cannot see any reference to QGEXSTAT on my systems, so I think maybe you have corrupted your new message layout? This is a guess tho.

  • >