View previous topic :: View next topic
|
Author |
Message |
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
For a REXX program, I needed to get the Dataset & Member name. Initially I was using ISPF variables, but this was not working in Changeman. In changeman, if opened a dataset in edit mode the name would be displayed in the below format and hence REXX macro was throwing an error.
Code: |
HLQ1.HLQ2.TSOID.#somerandomnumber.#somerandomnumber.ComponentType |
I searched on Google and came across this piece of code to get the dataset and member name and it's working fine in changeman as well.
But I could not understand it. Can somebody please break it down for me. How it's capturing the dataset and member name?
Code: |
'ISREDIT (MEM) = MEMBER'
MY_FILE= FINDMEM(MEM) |
Code: |
FINDMEM: PROCEDURE
'ISREDIT (DATAID) = DATAID'
ZDSN.=''
TFDP = 140+PTR(76+PTR(640+PTR(PTR(24+PTR(112+PTR(132+PTR(540)))))))
DO A=1 TO 4
PARSE VALUE STORAGE(D2X(PTR((A-1)*4+TFDP)),46) WITH D 3 N
IF D>'0000'X THEN ZDSN.A="'"STRIP(N)
END
ZLLIB=1;CORG = 'PS'
'LMOPEN DATAID('DATAID') ORG(CORG)' /* FIND CURRENT DATA SET */
IF ARG(1) /='' & CORG='PO' THEN
'LMMFIND DATAID('DATAID') MEMBER('ARG(1)') STATS(YES)'
'LMCLOSE DATAID('DATAID')'
RETURN_DSN=ZDSN.ZLLIB
IF ARG(1)='' THEN RETURN_DSN=RETURN_DSN"'" /* NO MEMBER NAME */
ELSE RETURN_DSN=RETURN_DSN'('ARG(1)")'"
RETURN_DSN=TRANSLATE(RETURN_DSN)
RETURN RETURN_DSN |
Code: |
PTR: RETURN C2D(BITAND(STORAGE(D2X(ARG(1)),4),'7FFFFFFF'X))
RETURN |
|
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
To be precise, I didn't understand the below part:
Code: |
TFDP = 140+PTR(76+PTR(640+PTR(PTR(24+PTR(112+PTR(132+PTR(540)))))))
DO A=1 TO 4
PARSE VALUE STORAGE(D2X(PTR((A-1)*4+TFDP)),46) WITH D 3 N
IF D>'0000'X THEN ZDSN.A="'"STRIP(N)
END |
|
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Just realized my mistake. This code was not returning dataset and member name either. So I have reverted back to ISPF variables and changed the program to avoid the error.
However, I would still like to understand the PTR,STORAGE calculation part. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Quote: |
I would still like to understand the PTR,STORAGE calculation part. |
Programs on z/OS keep track of various things in control blocks. For example, an assembler program might issue a GETMAIN macro then store stuff in the gotten storage.
Apparently, the author of the exec knew various control block structures in order to retrieve some values from the control blocks. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hello,
Code: |
TFDP = 140+PTR(76+PTR(640+PTR(PTR(24+PTR(112+PTR(132+PTR(540)))))))
DO A=1 TO 4
PARSE VALUE STORAGE(D2X(PTR((A-1)*4+TFDP)),46) WITH D 3 N
IF D>'0000'X THEN ZDSN.A="'"STRIP(N)
END |
As said by Pedro, This reads control blocks.
PTR(540) points to PSATOLD
PTR(132+PTR(540)) --> from the PSATOLD location TCB location is fetched.
(112+PTR(132+PTR(540))) --> first save area control block.
And so on..
If you need information on where each control blocks are located, you can refer
www-03.ibm.com/systems/z/os/zos/library/bkserv/v2r1pdf/
GA32-0935-01 - z/OS MVS Data Areas, Vol 1
GA32-0936-01 - z/OS MVS Data Areas, Vol 2
GA32-0937-01 - z/OS MVS Data Areas, Vol 3
GA32-0938-01 - z/OS MVS Data Areas, Vol 4
GA32-0939-01 - z/OS MVS Data Areas, Vol 5
GA76-0440-01 - z/OS MVS Data Areas, Vol 6
Usually chasing the control blocks begins with CVT, then TCB and others from there..
More information --> www.longpelaexpertise.com/ezine/CtBlksBeginners1.php
Hope it helps, |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Thanks Pedro and Vasanth.
I will check the links.
The Author of the exec was Doug Nadel. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Quote: |
The Author of the exec was Doug Nadel. |
He has access to the source code for ISPF. It is not something a regular person can do (without inside knowledge). |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Ok. I did a search and found that he is retired.
Quote: |
The MVS related content on this site is unavailable.
--------------------------------------------------------------------------------
I have retired from IBM and much of the MVS related content on this site was developed as part of my tenure there. It was published here with the permission of IBM during my employment. I was diligent about assigning copyright to IBM and I intend to respect that same copyright.
I would be happy to answer questions on MVS, ISPF, Rexx, etc, but will no longer be distributing any software that was created before my departure from IBM.
Note also that I no longer have any access to a mainframe or any z/OS installations so I can not test, try, prototype or verify any answers I give. Nonetheless, questions are welcome.
‐ Doug Nadel |
Am I violating any copyright by posting his code here? I found the above code in Google search. |
|
Back to top |
|
|
|