Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

REXX macro to get dataset/member name in Changeman

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
mistah kurtz

Active User


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

PostPosted: Thu Aug 07, 2014 6:32 pm    Post subject: REXX macro to get dataset/member name in Changeman
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Aug 07, 2014 6:40 pm    Post subject:
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Aug 07, 2014 8:28 pm    Post subject:
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

Senior Member


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

PostPosted: Thu Aug 07, 2014 9:22 pm    Post subject: Reply to: REXX macro to get dataset/member name in Changeman
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: 1445
Location: Azeroth

PostPosted: Thu Aug 07, 2014 9:39 pm    Post subject:
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
http://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 --> http://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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Aug 08, 2014 10:42 am    Post subject:
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

Senior Member


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

PostPosted: Fri Aug 08, 2014 2:09 pm    Post subject: Reply to: REXX macro to get dataset/member name in Changeman
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Aug 08, 2014 2:35 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us