IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

REXX macro to get dataset/member name in Changeman


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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

PostPosted: Thu Aug 07, 2014 6:32 pm
Reply with quote

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
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Aug 07, 2014 6:40 pm
Reply with quote

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
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Aug 07, 2014 8:28 pm
Reply with quote

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
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu Aug 07, 2014 9:22 pm
Reply with quote

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
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Thu Aug 07, 2014 9:39 pm
Reply with quote

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
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Aug 08, 2014 10:42 am
Reply with quote

Thanks Pedro and Vasanth.

I will check the links.

The Author of the exec was Doug Nadel.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Fri Aug 08, 2014 2:09 pm
Reply with quote

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
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Aug 08, 2014 2:35 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top