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
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
/* */
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.