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

How to get the No of users using the PDS


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
t_ctaram

New User


Joined: 15 May 2007
Posts: 20
Location: mumbai

PostPosted: Fri Aug 17, 2007 5:06 pm
Reply with quote

I've written a sample rexx to get the no of persons who are using a particular PDS.

Code:

/* REXX */                                               
'ISREDIT MACRO'                                 
ADDRESS ISREDIT                                 
X = OUTTRAP('USERIDS.')                         
"TSO WHOHAS 'myid.REXX.EXEC'"                 
Y = OUTTRAP('OFF')                             
SAY 'No of users using this PDS' USERIDS.0                           
EXIT     


Is this code correct? I'm not getting anything in the output.

Ctaram
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Fri Aug 17, 2007 5:42 pm
Reply with quote

WHOHAS is not an ISPF or TSO command, so I can't tell you why it's not working.

You can use the ISPF service QUERYENQ to get that information.

O.
Back to top
View user's profile Send private message
t_ctaram

New User


Joined: 15 May 2007
Posts: 20
Location: mumbai

PostPosted: Fri Aug 17, 2007 6:00 pm
Reply with quote

hi ofer71,

QUERYENQ is not present in my shop. Iam not aware of how to use it to get the info of no of persons using my PDS.

if i use TSO WHOHAS 'myid.rexx.exec'. iam getting the persons who are using my PDS.

i have doubt in the way iam trapping the output of this command.

is outtrap correctly used in my code or is there any other way to get the data.

thanks
Ctaram.
Back to top
View user's profile Send private message
rajesh-amigos
Currently Banned

New User


Joined: 03 Aug 2007
Posts: 25
Location: India

PostPosted: Fri Aug 17, 2007 6:41 pm
Reply with quote

Hi CTARAM,

I am not very sure how Whohas runs, and i am new to Rexx.
But just a thought...you are displaying Userids.0 which is the length of the array. So if the command Whohas returns a number, then Userids.0 wouldnt show you teh correct number.

Moreover if you run this exec with Trace All, you will get a +++RC (20) +++.

I am not sure whether this will help you, just my 2 pieces of thoughts
Back to top
View user's profile Send private message
t_ctaram

New User


Joined: 15 May 2007
Posts: 20
Location: mumbai

PostPosted: Fri Aug 17, 2007 7:19 pm
Reply with quote

Correct rajesh,

iam getting +++RC (20) +++. when iam using Trace.

But thats the thing i want to know. Why iam getting RC(20) ??

if we use TSO WHOHAS 'myid.rexx.exec' in my TSO command line. It will display who is using the PDS like:

ZTSO001I ALLOCATED SHR TO USER Z100192
ZTSO001I ALLOCATED OLD TO USER Z100230
ZTSO001I ALLOCATED SHR TO USER Z100219
ZTSO001I ALLOCATED SHR TO USER Z100311

How to trap this output ??? Is the Outtrap iam using is correct???

Is there any other way to know who and how many users are using my PDS.

Please suggest.
Back to top
View user's profile Send private message
rajesh-amigos
Currently Banned

New User


Joined: 03 Aug 2007
Posts: 25
Location: India

PostPosted: Fri Aug 17, 2007 7:24 pm
Reply with quote

The Trap is correct.
I am not sure whether Whohas command is a ISPF command or not.
The problem is not with your OUTTRAP. Its with the way you are trying to execute the macro.

Can you tell me What is the significance of 'ISREDIT MACRO' in your code.

Once again, I am telling you, I am a newbie to Rexx. : icon_rolleyes.gif
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Fri Aug 17, 2007 8:55 pm
Reply with quote

QUERYENQ is a standard ISPF service. You can read more about it in the fine manual.

O.
Back to top
View user's profile Send private message
t_ctaram

New User


Joined: 15 May 2007
Posts: 20
Location: mumbai

PostPosted: Fri Aug 17, 2007 9:37 pm
Reply with quote

hi all,

Thanks for your help,

My actual need was to know who is using my PDS and need to tell them to come out of my PDS so that i can perform some specific task on the PDS.

My shop uses WHOHAS to know who is using the PDS. for others it may vary. I think there is also some thing as WHOGOT which is used for the same purpose.

Here is the new code which i have written.

SAY 'PLEASE ENTER THE PDS NAME'
PARSE PULL DSN
X = OUTTRAP('USERIDS.')
"WHOHAS '"DSN"'"
Y = OUTTRAP('OFF')
DO A=1 TO USERIDS.0
USER_ID = WORD(USERIDS.A,6)
SAY 'THE USER WHO IS USING MYPDS IS ' USER_ID
"SEND 'PLEASE COME OUT OF THE PDS" DSN " ' U("USER_ID")"
"SEND 'THIS PDS NEED TO BE EDITED ' U("USER_ID")"
END
EXIT


Now i have a new requirement where the REXX should check whether all the users who are using my PDS came out of PDS ???

for that it need to execute the same code after some duration of time and check USERIDS.0 for confirmation.

Is there some thing in rexx where we can provide some delay ???

Thanks in Advance.

Ctaram
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Fri Aug 17, 2007 9:43 pm
Reply with quote

t_ctaram wrote:
Is there some thing in rexx where we can provide some delay?


Yes. Look at the TIME(R) (Reset) and TIME(E) (Elapsed) functions.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Fri Aug 17, 2007 11:16 pm
Reply with quote

If you can issue SYSCALL commands, have a look at the callable service sleep.

O.
Back to top
View user's profile Send private message
t_ctaram

New User


Joined: 15 May 2007
Posts: 20
Location: mumbai

PostPosted: Sun Aug 19, 2007 4:35 pm
Reply with quote

Hi all,

i have tried something like this and its working fine.

PRESENT_TIME = TIME(S)
SAY PRESENT_TIME
CHECK_TIME = PRESENT_TIME+30
SAY CHECK_TIME
DO FOREVER
NEW_TIME = TIME(S)
IF CHECK_TIME = NEW_TIME THEN LEAVE
END

the above code will wait for 30 secs then do a recheck whether any one accessing my PDS.

if no one accessing then it comes out of the program telling the PDS is free now.

Thanks for your help and support.
CTARAM
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Tue Aug 21, 2007 5:59 pm
Reply with quote

Hi ,


I have tried the above given code but nothing is coming out in outtrap.

if i am using TSO WHOHAS 'myid.rexx.exec' in my TSO command line. It will display who is using the PDS like:

SHR - TSU=DEVLUSE

How to trap this output ??? Is the Outtrap iam using is correct???
Here is the COde


SAY 'PLEASE ENTER THE PDS NAME'
PARSE PULL DSN
X = OUTTRAP('USERIDS.')
"WHOHAS '"DSN"'"
Y = OUTTRAP('OFF')
DO A=1 TO USERIDS.0
USER_ID = WORD(USERIDS.A,6)
SAY 'THE USER WHO IS USING MYPDS IS ' USER_ID
"SEND 'PLEASE COME OUT OF THE PDS" DSN " ' U("USER_ID")"
"SEND 'THIS PDS NEED TO BE EDITED ' U("USER_ID")"
END
EXIT

If there is any other way to trap userid pleae let me know
Thanks In advance
Back to top
View user's profile Send private message
t_ctaram

New User


Joined: 15 May 2007
Posts: 20
Location: mumbai

PostPosted: Tue Aug 21, 2007 7:04 pm
Reply with quote

hi Amar,

what is the userid in the phrase SHR - TSU=DEVLUSE .is it DEVLUSE ??? .

Please tell me the exact out put you get and the Userid in the output phrase.

Thanks
Ctaram.
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Tue Aug 21, 2007 10:34 pm
Reply with quote

Hi Ctaram ,

USER ID is DEVLUSE And the exact output coming is

SHR - TSU=DEVLUSE

Infact when you are submitting tso whohas 'Pdsname' in my TSO command line. It will display who is using the PDS like:

SHR - TSU=DEVLUSE

The problem is that outtrap is not able to trap the output for some reason .
USERIDS.1 is coming as spaces .


Let me know if you need any other information

Thanks
Amar
Back to top
View user's profile Send private message
t_ctaram

New User


Joined: 15 May 2007
Posts: 20
Location: mumbai

PostPosted: Wed Aug 22, 2007 12:04 pm
Reply with quote

hi Amar,

try the below code. hope this will work at your site.

SAY 'PLEASE ENTER THE PDS NAME'
PARSE PULL DSN
X = OUTTRAP('USERIDS.')
"WHOHAS '"DSN"'"
Y = OUTTRAP('OFF')
DO A=1 TO USERIDS.0
THIRD = WORD(DATA,3)
NUMBER=LENGTH(THIRD)
USER_ID= SUBSTR(THIRD,5,NUMBER)
SAY 'THE USER WHO IS USING MYPDS IS ' USER_ID
"SEND 'PLEASE COME OUT OF THE PDS" DSN " ' U("USER_ID")"
"SEND 'THIS PDS NEED TO BE EDITED ' U("USER_ID")"
END
EXIT

Note that you should not give codes for the PDS name which you provide as input.

Ctaram
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Wed Aug 22, 2007 2:24 pm
Reply with quote

Hello CTARAM ,

I think you do not undersatnd the problem . The changes you have made will work when there is data in the USERIDS.1 . I have displayed the value which is coming as spaces.

The problem is in OUTTRAP STEP
X = OUTTRAP('USERIDS.')
"WHOHAS '"DSN"'"
Y = OUTTRAP('OFF')


As data from TSO WHOHAS is not trapped for any reason .

please let me know if you have any querry

Many Thansk & Regards
Amar
Back to top
View user's profile Send private message
t_ctaram

New User


Joined: 15 May 2007
Posts: 20
Location: mumbai

PostPosted: Wed Aug 22, 2007 3:00 pm
Reply with quote

Hi,

As far as i know the outtrap used is working fine.

Use TRACE for finding out the flow.

note that this REXX is not an ISREDIT Macro.

Ctaram
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Wed Aug 22, 2007 3:22 pm
Reply with quote

I have used TRACE and found the same thing that OUTTRAP is not able to trap the out from TSO WHOHAS.

As when i have changed the Code to TSO HRECALL it properly TRAPED the output .

Is there is any constrain on OUTTRAP to capture output of TSO WHOHAS at my shop .

Is there any other way to trap the output of TSO WHOHAS or to get USER ID directly .


Regards
Amar
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Wed Aug 22, 2007 4:26 pm
Reply with quote

As was previously explained - WHOHAS is not a TSO or ISPF command, so you can't expect it to behave as a regular command. You should ask the WHOHAS's developer.

O.
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Wed Aug 22, 2007 5:08 pm
Reply with quote

WHOHAS Is working fine but data is nt not trapped in the output
Back to top
View user's profile Send private message
shr_amar
Warnings : 2

Active User


Joined: 02 May 2005
Posts: 128
Location: UK

PostPosted: Wed Aug 22, 2007 10:06 pm
Reply with quote

Any solution of the problem
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Sat Aug 25, 2007 7:49 pm
Reply with quote

This is what I posted on the similar thread that got moved to "OFF TOPICS"

To get the number of users you will need to count the occurences of JOBNAME, as WHOHAS may return multiple lines for each user.

Code:

/* REXX ***/                                                 
SAY 'PLEASE ENTER THE PDS NAME'                             
PARSE PULL DSN                                               
X = OUTTRAP('USERIDS.')                                     
"WHOHAS '"STRIP(DSN)"'"                                     
Y = OUTTRAP('OFF')                                           
DO A=1 TO USERIDS.0                                         
  PARSE UPPER VAR USERIDS.A PART1 .                         
  IF INDEX(PART1,'JOBNAME') THEN DO                         
    USER_ID = SUBSTR(PART1,INDEX(PART1,'JOBNAME=')+9,7)   
    SAY 'THE USER WHO IS USING MYPDS IS ' USER_ID           
  END                                                       
END                                                   
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 IBM OnDemand Folders displaying to al... IBM Tools 6
No new posts VAGen Users IBM Tools 0
No new posts Copy a DS Member to multiple users at... TSO/ISPF 8
No new posts User key common area users - How to r... All Other Mainframe Topics 0
No new posts Free FILE not working for specific users CLIST & REXX 12
Search our Forums:

Back to Top