MSS enables you to access MVS control blocks from a COBOL program. The following sample program shows how you can access the job, step, and program names for the currently running program.
IDENTIFICATION DIVISION. PROGRAM-ID. JOBINFO. DATA DIVISION. WORKING-STORAGE SECTION. 01 JOB-NAME PIC X(8). 01 PROGRAM-NAME PIC X(8). 01 STEP-NAME PIC X(8). LINKAGE SECTION. 01 PSA. 05 FILLER PIC X(540). 05 PSATOLD POINTER. 01 TCB. 05 FILLER PIC X(12). 05 TCBTIO POINTER. 05 FILLER PIC X(164). 05 TCBJSCBB POINTER. 01 TIOT. 05 TIOCNJOB PIC X(8). 05 TIOCSTPN PIC X(8). 01 JSCB. 05 FILLER PIC X(360). 05 JSCBPGMN PIC X(8). PROCEDURE DIVISION. * Address PSA SET ADDRESS OF PSA TO NULL * Address TCB SET ADDRESS OF TCB TO PSATOLD * Address TIOT SET ADDRESS OF TIOT TO TCBTIO MOVE TIOCNJOB TO JOB-NAME MOVE TIOCSTPN TO STEP-NAME * Address JSCB SET ADDRESS OF JSCB TO TCBJSCBB MOVE JSCBPGMN TO PROGRAM-NAME DISPLAY 'JOB NAME = ' JOB-NAME DISPLAY 'STEP NAME = ' STEP-NAME DISPLAY 'PROGRAM NAME = ' PROGRAM-NAME GOBACK .