Make ‘System Request 3’ do WRKJOB instead of DSPJOB

  • Home
  • /
  • Blog
  • /
  • Make ‘System Request 3’ do WRKJOB instead of DSPJOB

December 24, 2022

Make ‘System Request 3’ do WRKJOB instead of DSPJOB

By NickLitten

December 24, 2022

system, DSPJOB, MoveAlongMoveAlong, NothingToSeeHere, request, sysrq3, WRKJOB

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.

IMPORTANT NOTE – the MSG string is broken up into 10 char strings so each command that is a 10 character command will be repeated like this MSG(123456789012345678901234567890etc)

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.
NOTE MOST IMPORTANT: Each of the commands is equally spaced by 10 characters. You must keep the spacing of these commands or you will blow everything up!

Make 'System Request 3' do WRKJOB instead of DSPJOB 1

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 🙂

  • 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

  • HTML breaks the above ADDMSGD command. That’s because the proper ADDMSGD command is padded with blanks, and, by default, HTML truncates multiple blanks into a single blank.

    The proper MSG() portion of the ADDMSGD command is composed of multiple 11-character commands. For example, ENDRQS is 6 characters, so the command needs 5 blanks between it and WRKJOB. SIGNOFF is 7 characters, so it needs 4 blanks between it and DSPMSG, etc., etc.

    One way to build the proper MSG() portion is to copy the value from QSYS/QCPFMSG, paste it into Notepad++, replace DSPJOB with WRKJOB in NP++, then build your ADDMSGD command using the NP++ value.

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips

    >