Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Jan 14, 2004 9:07 am Post subject:
bauer,
Following is the cobol code written by gilber saint-flour which will give you the desired results.
Code:
CBL NOLIB,APOST,NODECK,OBJECT,NOSEQ,BUF(10000),NONAME
CBL NOMAP,NOLIST,NOOFFSET,NOXREF
IDENTIFICATION DIVISION.
PROGRAM-ID. COB2JOB.
AUTHOR. GILBERT SAINT-FLOUR <GSF@POBOX.COM>.
*----------------------------------------------------------------*
* *
* THIS PROGRAM RETRIEVES SPECIFIC JOB-RELATED DATA FROM MVS *
* CONTROL BLOCKS AND MOVES IT TO WORKING-STORAGE. *
* *
* THE NAME OF THE CONTROL-BLOCK IS INDICATED IN POS 1-6 OF *
* THE PROCEDURE DIVISION LINES. *
* THE LAYOUT OF THE MVS CONTROL BLOCKS IS DESCRIBED IN THE *
* MVS DATA AREAS MANUALS, WHICH CAN BE FOUND ON ANY MVS OR *
* OS/390 CD COLLECTION OR VIEWED ON-LINE BY GOING TO: *
* HTTP://WWW.S390.IBM.COM/BOOKMGR-CGI/BOOKMGR.CMD/LIBRARY *
* AND SEARCHING FOR: *
* MVS DATA AREAS *
*----------------------------------------------------------------*
DATA DIVISION.
WORKING-STORAGE SECTION.
01 RESULTS.
05 JOB-NAME PIC X(8).
05 PROC-STEP PIC X(8).
05 STEP-NAME PIC X(8).
05 PROGRAM-NAME PIC X(8).
05 PROGRAM-NAME2 PIC X(8).
05 JOB-NUMBER PIC X(8).
05 JOB-CLASS PIC X.
05 MSG-CLASS PIC X.
05 PROGRAMMER-NAME PIC X(20).
05 USER-ID PIC X(8).
05 GROUP-NAME PIC X(8).
05 USER-NAME PIC X(20).
05 BATCH-OR-CICS PIC X(5).
88 BATCH VALUE 'BATCH'.
88 CICS VALUE 'CICS '.
05 MICRO-SECONDS PIC S9(15) COMP-3.
01 FOUR-BYTES.
05 FULL-WORD PIC S9(8) COMP.
05 PTR4 REDEFINES FULL-WORD POINTER.
LINKAGE SECTION.
01 CB1. 05 PTR1 POINTER OCCURS 256.
01 CB2. 05 PTR2 POINTER OCCURS 256.
PROCEDURE DIVISION.
PSA SET ADDRESS OF CB1 TO NULL
TCB SET ADDRESS OF CB1 TO PTR1(136)
SET PTR4 TO PTR1(83)
COMPUTE MICRO-SECONDS = FULL-WORD * 1048576
SET PTR4 TO PTR1(84)
COMPUTE MICRO-SECONDS = MICRO-SECONDS + (FULL-WORD / 1024)
TIOT SET ADDRESS OF CB2 TO PTR1(4)
MOVE CB2(1:8) TO JOB-NAME
MOVE CB2(9:8) TO PROC-STEP
MOVE CB2(17:8) TO STEP-NAME
JSCB SET ADDRESS OF CB2 TO PTR1(46)
MOVE CB2(361:8) TO PROGRAM-NAME
SSIB SET ADDRESS OF CB2 TO PTR2(80)
MOVE CB2(13:8) TO JOB-NUMBER
PRB SET ADDRESS OF CB2 TO PTR1(1)
MOVE CB2(97:8) TO PROGRAM-NAME2
JSCB SET ADDRESS OF CB2 TO PTR1(46)
JCT SET ADDRESS OF CB2 TO PTR2(66)
MOVE CB2(48:1) TO JOB-CLASS
MOVE CB2(23:1) TO MSG-CLASS
ACT MOVE ZERO TO FULL-WORD
MOVE CB2(57:3) TO FOUR-BYTES(2:3)
SET ADDRESS OF CB2 TO PTR4
MOVE CB2(25:20) TO PROGRAMMER-NAME
EXT2 SET ADDRESS OF CB2 TO PTR1(53)
CAUF IF CB2(21:4) = LOW-VALUES THEN
SET BATCH TO TRUE
ELSE
SET CICS TO TRUE
END-IF
PSA SET ADDRESS OF CB1 TO NULL
ASCB SET ADDRESS OF CB1 TO PTR1(138)
ASXB SET ADDRESS OF CB2 TO PTR1(28)
MOVE CB2(193:8 ) TO USER-ID
ACEE SET ADDRESS OF CB2 TO PTR2(51)
MOVE CB2(31:8 ) TO GROUP-NAME
UNAM SET ADDRESS OF CB1 TO PTR2(26)
MOVE ZERO TO FULL-WORD
MOVE CB1(1:1) TO FOUR-BYTES(4:1)
MOVE CB1(2:FULL-WORD) TO USER-NAME
DISPLAY 'THE JOB NAME : ' JOB-NAME
DISPLAY 'THE JOB NUMBER : ' JOB-NUMBER
DISPLAY 'THE JOB CLASS IS: ' JOB-CLASS
DISPLAY 'THE MSG CLASS IS: ' MSG-CLASS
DISPLAY 'THE USER ID IS : ' USER-ID
DISPLAY 'THE USER NAME IS: ' USER-NAME
BTW, does merely coding the LINKAGE SECTION bring in the control block information? I am not sure, how this program works. _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Mon Sep 20, 2004 2:33 pm Post subject:
Actually, I tried the PL/I solution. Fewer lines to code.
Bauer,
Is there any place where I can get the address of new PSW? Basically, I want the address of the would-be instruction. I tried the PSA map; but, I am not sure. _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Mon Nov 29, 2004 5:32 am Post subject:
Vak255,
When counted from PSA, ASCB is located at offset 544. ((138 - 1) * 4 = 544). When you refer it using COBOL Pointers, each pointer variable occupies 4 bytes. So 138 * 4 gives 548 but since the addressing starts from ZERO you need subtract another 4 from the result which is equivalent to (138 - 1) * 4.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum