Now we know enough to modify our SRB routine to allow us to actually access data in another address space. We just need to make a few simple modifications to our existing code. For our initial test we will retrieve the Job Step program name contained in the JSCB. We can locate the JSCB by following a chain of control blocks beginning with the ASCB. The ASCB resides in common storage it can be accessed from any address space. The ASCB points to the ASXB which resides in private storage. The ASXB has a pointer to a TCB and the TCB points to the JSCB. The JSCB contains the program name we are looking for. We will add code to our SRB routine to follow the control block chain to locate the JSCB and then copy the program name into common storage before posting the ECB.
WKAREA DSECT , PARMLIST DS 0F PARAMETER LIST FOR SRB ROUTINE WAITECB DS A ADDRESS OF LOCAL ECB WAITASCB DS A ADDRESS OF WAITING ASCB XMASCB DS A CROSS MEM - ASCB ADDRESS XMPGM DS CL8 PROGRAM NAME RETURN AREA * SRBAREA DS CL(44) SRBCODE DS CL(ENDSRTN-SRBRTN) * * WKLEN EQU *-WKAREA
We begin by adding two additional fields to our SRB parameters in our CSA storage. First we pass the address of the ASCB of the address space we dispatched our SRB into (XMASCB). We also provide an area to return the program name (XMPGM).
ST R9,XMASCB SAVE TARGET ASCB ADDRESS IN PARMS
We need to place the target ASCB address into the parameter list prior to scheduling the SRB. We already have the ASCB address so we just need to add one line of code.
LA R3,FRREXIT ADDRESS OF FRR SETFRR A,FRRAD=(R3),WRKREGS=(R7,R8),RELATED=(DELETE) * LA R10,X'41' POST SLL R10,24 COMPLETION CODE * L R1,XMASCB GET XM ASCB ADDRESS L R1,ASCBASXB-ASCB(,R1) GET ASXB ADDRESS L R1,ASXBLTCB-ASXB(,R1) GET TCB ADDRESS L R1,TCBJSCB-TCB(,R1) GET JSCB ADDRESS LA R1,JSCBPGMN-IEZJSCB(,R1) POINT TO PGM NAME MVC XMPGM,0(R1) * LA R10,X'7F' POST SLL R10,24 COMPLETION CODE * RTRYRTN DS 0H SETFRR D,WRKREGS=(R7,R8),RELATED=(ADD)
We insert our new SRB code in the FRR protected section. This way if an error occurs (like a SOC4), the error will be trapped and reported back to the caller with a post code. The fail post code is initially placed into register 10. It will be updated if the program name is successfully copied. Next we get the pointer to the ASCB. From there we chain down to the JSCB and point to the program name field. We can then copy the program name into our parameter area in CSA. Once the name is successfully copied we can update the post code to indicate success and then continue on to the cross memory post.
SUCCESS DS 0H WTO '*** SUCCESS POST CODE ***',ROUTCDE=(1,11) * MVC WTOMSG+12(8),XMPGM WTOMSG WTO '>>> ******** <<<',ROUTCDE=(1,11) B CLEANUP
If the ECB is posted with the success code we can copy the program name from the CSA area into our private storage. In this case we copy it into a WTO message. This will cause the program name to be displayed on the operator console.
IHAASXB , IKJTCB DSECT=YES,LIST=NO IEZJSCB ,
We need to add the mapping macros for the ASXB, TCB, and JSCB.
JOB 6806 $HASP100 SRB05 ON INTRDR RUN TEST PGM JOB 6806 $HASP373 SRB05 STARTED - INIT 12 - CLASS A - SYS TCS3 JOB 6806 *** SUCCESS POST CODE *** JOB 6806 >>> HASJES20 <<< JOB 6806 20.46.41 0.00.00 0.00.00 0000 SRB05 MVSSP JOB 6806 20.46.41 0.00.00 0.00.00 0000 SRB05 ######## JOB 6806 $HASP395 SRB05 ENDED
Now we assemble, link edit, and run our program. Everything looks good – since we scheduled our SRB into the address space for JES2 we should expect to find HASJES20 as the job step program. We have successfully accessed storage in the private area of another address space.