View previous topic :: View next topic
|
Author |
Message |
t_ctaram
New User
Joined: 15 May 2007 Posts: 20 Location: mumbai
|
|
|
|
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 |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
t_ctaram
New User
Joined: 15 May 2007 Posts: 20 Location: mumbai
|
|
|
|
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 |
|
|
rajesh-amigos Currently Banned New User
Joined: 03 Aug 2007 Posts: 25 Location: India
|
|
|
|
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 |
|
|
t_ctaram
New User
Joined: 15 May 2007 Posts: 20 Location: mumbai
|
|
|
|
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 |
|
|
rajesh-amigos Currently Banned New User
Joined: 03 Aug 2007 Posts: 25 Location: India
|
|
|
|
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. : |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
QUERYENQ is a standard ISPF service. You can read more about it in the fine manual.
O. |
|
Back to top |
|
|
t_ctaram
New User
Joined: 15 May 2007 Posts: 20 Location: mumbai
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
If you can issue SYSCALL commands, have a look at the callable service sleep.
O. |
|
Back to top |
|
|
t_ctaram
New User
Joined: 15 May 2007 Posts: 20 Location: mumbai
|
|
|
|
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 |
|
|
shr_amar Warnings : 2 Active User
Joined: 02 May 2005 Posts: 128 Location: UK
|
|
|
|
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 |
|
|
t_ctaram
New User
Joined: 15 May 2007 Posts: 20 Location: mumbai
|
|
|
|
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 |
|
|
shr_amar Warnings : 2 Active User
Joined: 02 May 2005 Posts: 128 Location: UK
|
|
|
|
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 |
|
|
t_ctaram
New User
Joined: 15 May 2007 Posts: 20 Location: mumbai
|
|
|
|
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 |
|
|
shr_amar Warnings : 2 Active User
Joined: 02 May 2005 Posts: 128 Location: UK
|
|
|
|
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 |
|
|
t_ctaram
New User
Joined: 15 May 2007 Posts: 20 Location: mumbai
|
|
|
|
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 |
|
|
shr_amar Warnings : 2 Active User
Joined: 02 May 2005 Posts: 128 Location: UK
|
|
|
|
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 |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
shr_amar Warnings : 2 Active User
Joined: 02 May 2005 Posts: 128 Location: UK
|
|
|
|
WHOHAS Is working fine but data is nt not trapped in the output |
|
Back to top |
|
|
shr_amar Warnings : 2 Active User
Joined: 02 May 2005 Posts: 128 Location: UK
|
|
|
|
Any solution of the problem |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
|