Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to see which user holds a dataset 1

Status
Not open for further replies.

Varin

Technical User
Dec 3, 2007
3
NL
Hi, I would like to know if there is a way to see which user is holding a dataset I want to allocate for my (TSO/)REXX program. Sometimes my program fails because the dataset is in use, so I would like to know who is causing this.
Regards,
Varin
 
Issuing the command:
D GRS,RES=(*,Dataset.Name)
should display who has the dataset
 
Hi acheait, the program runs in batch (IKJEFT01), so I need a command in Rexx to show me who held the dataset when the program failed.
 
Here is a routine that issues the D GRS,RES=(*,Dataset.Name)
command using the console interface.
You should be able to adapt it to Your needs.

/* REXX */
DSname = arg(1)
If DSname = '' then Do
say 'ENTER DATASET NAME (full or partial)'
Parse UPPER External DSname
End
If DSname = '' Then DSname = userid()
If DSname = '*' Then DSname = ''
If Pos('DSN',DSname) > 0 Then
Do
Parse var DSname 'DSN' DSname
DSname = strip(DSname)
End
Call Console 'D GRS,RES=(*,'DSname'*)'
Exit

Console:
ARG Cmd
"CONSPROF SOLDISP(NO) SOLNUM(256) UNSOLDISP(NO) UNSOLNUM(256)"
If rc <> 0 Then
Call Exit8 'Console Profile command failed'
"CONSOLE ACTIVATE NAME(myrexx)"
If rc > 4 Then
Do
"CONSOLE DEACTIVATE "
Call Exit8 'Console Activate command failed'
End
"CONSOLE SYSCMD("Cmd") CART(myrexx)"
getrc = getmsg(getmsg.,,myrexx,,10)
"CONSOLE DEACTIVATE "
If getrc <> 0 then
Call Exit8 'Error returned from getmsg'
If datatype(getmsg.0) <> 'NUM' Then
Call Exit8 'No message returned from' Cmd
say getmsg.1
say 'JOBNAME ASID TCBADDR TYPE STATUS MAJOR MINOR'
major='';minor='';jobname='';asid='';tcbaddr='';type='';status=''
Do i = 2 to getmsg.0
If POS('S=SYSTEMS',getmsg.i) > 0 Then
Do
major = word(getmsg.i,2);minor = word(getmsg.i,3)
iterate i
End
If POS('SYSNAME',getmsg.i) > 0 Then iterate i
jobname = word(getmsg.i,2);asid = word(getmsg.i,3)
tcbaddr = word(getmsg.i,4);type = word(getmsg.i,5)
status = word(getmsg.i,6);status=substr(status,1,7)
jobname = substr(jobname,1,9)
asid = substr(asid,1,5)
tcbaddr = substr(tcbaddr,1,10)
Select
When POS('SHARE',type) > 0 Then type = 'SHR '
When POS('EXCLU',type) > 0 Then type = 'EXC '
Otherwise type = substr(type,1,5)
End
major = substr(major,1,8)
say jobname asid tcbaddr type status major minor
End
Return
/* ********** Error Exit ********** */
Exit8:
Arg ErrMsg
Say Errmsg
Exit 08
/* */
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top