This is exactly what a routing entry does – gives control to the named program. Most subsytems have a default entry of sequence no 9999 which calls QCMD (or occasionally QCMDB or QCMDI for batch / interactive respectively) with a match value of *ANY on the routing data. There are frequently lower numbered entries which look for specific routing data and call other programs (e.g. QCL for system/38 environment programs).
An old trick was to change the 9999 sequence entry to call your program, which would then perform it’s own processing and then execute a RRTJOB (re-route job) with a specific value in the routing data. This would then be processed by another routing entry with a lower sequence number.
e.g. we had a special subsytem for compiles called COMPILES and rather than have it using up memory all day, the 9999 entry in COMPILES called a program to allocate memmory and reroute the job, and submit a job to the queue to de-allocate the memory.
COMPILES subsystem routing entries:
Seq Nbr Program Library Compare Value Pos
10 QCMD QSYS ‘POOL2’ 1
9999 DKMM001CL DKSBSP3 *ANY
program DKMM001CL did this:
DCL VAR(&ACTIVE) TYPE(*CHAR) LEN(1)
DCL VAR(&SIZE) TYPE(*CHAR) LEN(9)
RTVDTAARA DTAARA(QGPL/COMPILES (1 1)) RTNVAR(&ACTIVE)
RTVDTAARA DTAARA(QGPL/COMPILES (2 9)) RTNVAR(&SIZE)
IF COND(&ACTIVE *EQ ‘N’) THEN(DO)
CHGSHRPOOL POOL(*SHRPOOL1) SIZE(&SIZE)
CHGDTAARA DTAARA(QGPL/COMPILES (1 1)) VALUE(‘Y’)
SBMJOB CMD(CALL PGM(DKSBSP3/DKMM002CL)) +
JOB(DEALLOC) JOBQ(QGPL/COMPILES) +
JOBPTY(9) RTGDTA(‘POOL2’) MSGQ(*NONE)
The essence of the trick is that most jobs do not set their routing data to anything, so you will normally get away with this.
Also, if you had some sort of exit point program, it would apply to ALL subsystems on the the machine and you proabably don’t want the same things happening in QBATCH & QINTER etc.
Hope this helps