Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

REXX Source Dataset from within REXX

57 views
Skip to first unread message

Andy Styles

unread,
Feb 8, 2000, 3:00:00 AM2/8/00
to
Hi folks,

I've asked this before, but I haven't had a definitive answer:

I'm trying to write a REXX function that when called, will be able to log
details of the exec name, the user executing the exec and the dataset from
where the exec was loaded.

The first two are simple, but I haven't had any success with the third.

Can anyone tell me how to (definitively) get the name of the dataset from
where the exec was loaded ?

Andy Styles
andy....@natwest.com

---------------------------------------------------------------------------
The contents of this e-mail may be privileged and are confidential. It may not be disclosed to or used by anyone other than the addressee(s), nor copied in any way. If received in error, please advise the sender, then delete it from your system.
National Westminster Bank Plc is regulated by the Personal Investment Authority and IMRO for investment business. A member of the NatWest and Gartmore Marketing Group advising on the life assurance, pensions and unit trust products only of that Marketing Group.
Registered Office: 41 Lothbury London EC2P 2BP
Registered Number: 929027 England
---------------------------------------------------------------------------

John Dexter

unread,
Feb 8, 2000, 3:00:00 AM2/8/00
to
In article <B0001...@gemo2cs06e.gemo2cs06e.natwest.com> posted to
bit.listserv.tsorexx at 08:47:18 on Tue, 8 Feb 2000, Andy Styles
<Andy....@NATWEST.COM> wrote

>Hi folks,
>
>I've asked this before, but I haven't had a definitive answer:
>
>I'm trying to write a REXX function that when called, will be able to log
>details of the exec name, the user executing the exec and the dataset from
>where the exec was loaded.
>
>The first two are simple, but I haven't had any success with the third.
>
>Can anyone tell me how to (definitively) get the name of the dataset from
>where the exec was loaded ?

PARSE SOURCE should return it (in the 5th token)

--
John Dexter
Westfarthing Ltd; IT Consultants

JB Peterson

unread,
Feb 8, 2000, 3:00:00 AM2/8/00
to
Parse Source Tokens /* Get source variables */
Parse Var Tokens tsocmd , /* Start command */
cmdfunc , /* Command function */
ename , /* EXEC name */
execdd , /* EXEC lib DDNAME */
execdsn , /* EXEC lib DSNAME */
junk /* Everything else */

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU]On Behalf
Of Andy Styles
Sent: Tuesday, February 08, 2000 9:44 AM
To: TSO-...@VM.MARIST.EDU
Subject: REXX Source Dataset from within REXX
Importance: Low


Hi folks,

I've asked this before, but I haven't had a definitive answer:

I'm trying to write a REXX function that when called, will be able to log
details of the exec name, the user executing the exec and the dataset from
where the exec was loaded.

The first two are simple, but I haven't had any success with the third.

Can anyone tell me how to (definitively) get the name of the dataset from
where the exec was loaded ?

Andy Styles

John Dexter

unread,
Feb 8, 2000, 3:00:00 AM2/8/00
to
In article <2dO90WAP...@westfarthing.demon.co.uk> posted to
bit.listserv.tsorexx at 20:18:23 on Tue, 8 Feb 2000, John Dexter
<{News0001}@Westfarthing.demon.co.uk> wrote

>In article <B0001...@gemo2cs06e.gemo2cs06e.natwest.com> posted to
>bit.listserv.tsorexx at 08:47:18 on Tue, 8 Feb 2000, Andy Styles
><Andy....@NATWEST.COM> wrote
>>Hi folks,
>>
>>I've asked this before, but I haven't had a definitive answer:
>>
>>I'm trying to write a REXX function that when called, will be able to log
>>details of the exec name, the user executing the exec and the dataset from
>>where the exec was loaded.
>>
>>The first two are simple, but I haven't had any success with the third.
>>
>>Can anyone tell me how to (definitively) get the name of the dataset from
>>where the exec was loaded ?
>
>PARSE SOURCE should return it (in the 5th token)
>
... but, of course, if this is to be in a utility function it will
probably return the name of the PDS where the utility Rexx exec resides,
which may or may not be the same library from which the calling exec was
loaded ...

O. E. Jordan

unread,
Feb 8, 2000, 3:00:00 AM2/8/00
to
This works only on some systems. In our system if the REXX exec is run under
ISPF or as a command either with EXEC or % under TSO, the file name is not
passed. If the REXX exec is run by specifying the dataset and member on the
command line, then dataset name is passed. I too would be interested in
solutions.

O. E.


JB Peterson <JB_Pe...@bmc.com> on 02/08/2000 12:19:48 PM

Please respond to JB_Pe...@bmc.com

To: TSO-...@VM.MARIST.EDU
cc: (bcc: O E Jordan/TPC/SA/HARCOURT)

Subject: Re: REXX Source Dataset from within REXX


Parse Source Tokens /* Get source variables */
Parse Var Tokens tsocmd , /* Start command */
cmdfunc , /* Command function */
ename , /* EXEC name */
execdd , /* EXEC lib DDNAME */
execdsn , /* EXEC lib DSNAME */
junk /* Everything else */

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU]On Behalf
Of Andy Styles
Sent: Tuesday, February 08, 2000 9:44 AM
To: TSO-...@VM.MARIST.EDU
Subject: REXX Source Dataset from within REXX
Importance: Low


Hi folks,

I've asked this before, but I haven't had a definitive answer:

I'm trying to write a REXX function that when called, will be able to log
details of the exec name, the user executing the exec and the dataset from
where the exec was loaded.

The first two are simple, but I haven't had any success with the third.

Can anyone tell me how to (definitively) get the name of the dataset from
where the exec was loaded ?

Andy Styles

Mark Zelden

unread,
Feb 8, 2000, 3:00:00 AM2/8/00
to
John Dexter wrote:
>
> In article <B0001...@gemo2cs06e.gemo2cs06e.natwest.com> posted to
> bit.listserv.tsorexx at 08:47:18 on Tue, 8 Feb 2000, Andy Styles
> <Andy....@NATWEST.COM> wrote
> >Hi folks,
> >
> >I've asked this before, but I haven't had a definitive answer:
> >
> >I'm trying to write a REXX function that when called, will be able to log
> >details of the exec name, the user executing the exec and the dataset from
> >where the exec was loaded.
> >
> >The first two are simple, but I haven't had any success with the third.
> >
> >Can anyone tell me how to (definitively) get the name of the dataset from
> >where the exec was loaded ?
>
> PARSE SOURCE should return it (in the 5th token)
>

PARSE SOURCE will only return the name of the data set if the exec
was explicitly invoked, for example, TSO EX 'MY.REXXLIB(PGMA)'. If the
program was invoked implicitly, for example, TSO %PGMA, it will
show a question mark (?).

Mark
--
+--------------------------------+--------------------------------+
| Mark Zelden | OS/390 Consultant |
| http://www.flash.net/~mzelden/ | 3D Business Solutions |
| mailto:mze...@flash.net | mailto:mze...@3dsolutions.com |
+--------------------------------+--------------------------------+

Check out my MVS utilities page at:
http://www.flash.net/~mzelden/mvsutil.html

Frank Clarke

unread,
Feb 8, 2000, 3:00:00 AM2/8/00
to
On 8 Feb 2000 15:18:54 -0800, mze...@FLASH.NET (Mark Zelden) wrote:

>PARSE SOURCE will only return the name of the data set if the exec
>was explicitly invoked, for example, TSO EX 'MY.REXXLIB(PGMA)'. If the
>program was invoked implicitly, for example, TSO %PGMA, it will
>show a question mark (?).

...and at that point you are reduced to "LISTA ST" to find out which
datasets are allocated to SYSEXEC and SYSPROC (don't forget about
ALTLIB), walking the lists looking for the first occurrence of the
execname. If done carefully this can deliver the dataset name, but
it's a lot of work for a return of only 44 bytes...

And the code has to be embedded in whatever exec/clist because if it
calls an external routine...

Actually, I'm surprised that MarkZ doesn't have some pro forma code on
his excellent website. If I write it will you post it?

Frank Clarke
Member of the REXX Language Association
Join us at http://www.rexxla.org

Doug Nadel

unread,
Feb 8, 2000, 3:00:00 AM2/8/00
to

On Tue, 8 Feb 2000 15:43:30 -0000, you wrote:

>Can anyone tell me how to (definitively) get the name of the dataset from
>where the exec was loaded ?

Definitively? No, but here is my best guess. I haven't tried it as an
external function or with altlib. Thanks, as always, to Gilbert
Saint-flour for the swareq subroutine.


/* REXX - example to find where code was run from. */
/* It assumes cataloged data sets. Not well tested either. */
/* */
/* Doug Nadel */
/* With SWA code lifted from Gilbert Saint-flour's SWAREQ exec */
/* */
Say find_origin() /* say where this was executed
from */
Exit
find_origin:
Procedure
answer='* UNKNOWN *' /* assume disaster */
Parse Source . . name dd ds . /* get known info */
Call listdsi(dd 'FILE') /* get 1st ddname from file */
Numeric digits 10 /* allow up to 7FFFFFFF */
If name = '?' Then /* if sequential exec */
answer=''''ds'''' /* use info from parse source */
Else /* now test for members */
If sysdsn(''''sysdsname'('name')''')='OK' Then /* if in 1st ds */
answer=''''sysdsname'('name')''' /* go no further */
Else /* hooboy! Lets have some fun!*/
Do /* scan tiot for the ddname */
tiotptr=24+ptr(12+ptr(ptr(ptr(16)))) /* get ddname array */
tioelngh=c2d(stg(tiotptr,1)) /* nength of 1st entry */
Do Until tioelngh=0 | tioeddnm = dd /* scan until dd found */
tioeddnm=strip(stg(tiotptr+4,8)) /* get ddname from tiot */
If tioeddnm <> dd Then /* if not a match */
tiotptr=tiotptr+tioelngh /* advance to next entry */
tioelngh=c2d(stg(tiotptr,1)) /* length of next entry */
End
If dd=tioeddnm Then /* if we found it, loop through
the data sets doing an swareq
for each one to get the
dsname */
Do Until tioelngh=0 | stg(4+tiotptr,1)<> " "
tioejfcb=stg(tiotptr+12,3)
jfcb=swareq(tioejfcb) /* convert SVA to 31-bit addr */
dsn=strip(stg(jfcb,44)) /* dsname JFCBDSNM */
vol=storage(d2x(jfcb+118),6) /* volser JFCBVOLS (not used) */
If sysdsn(''''dsn'('name')''')='OK' Then /* found it? */
Leave /* we is some happy campers! */
tiotptr=tiotptr+tioelngh /* get next entry */
tioelngh=c2d(stg(tiotptr,1)) /* get entry length */
End
answer=''''dsn'('name')''' /* assume we found it */
End
Return answer

ptr: Return c2d(storage(d2x(Arg(1)),4))
stg: Return storage(d2x(Arg(1)),Arg(2))

swareq:
Procedure
If right(c2x(Arg(1)),1) \= 'F' Then /* SWA=BELOW ? */
Return c2d(Arg(1))+16 /* yes, return sva+16 */
sva = c2d(Arg(1)) /* convert to decimal */
tcb = c2d(storage(21c,4)) /* TCB PSATOLD */
tcb = ptr(540) /* TCB PSATOLD */
jscb = ptr(tcb+180) /* JSCB TCBJSCB */
qmpl = ptr(jscb+244) /* QMPL JSCBQMPI */
qmat = ptr(qmpl+24) /* QMAT QMADD */
Do While sva>65536
qmat = ptr(qmat+12) /* next QMAT QMAT+12 */
sva=sva-65536 /* 010006F -> 000006F */
End
Return ptr(qmat+sva+1)+16

Doug Nadel
----------------------------------------
ISPF and OS/390 Tools & Toys page:
http://somebody.home.mindspring.com/

W. Jensen

unread,
Feb 8, 2000, 3:00:00 AM2/8/00
to
This is as definite as I can make it, and it works for 'activated' libs as
well. It is crude and rather inefficient as it uses LISTA, but it is simple
to use.
In this case I know that my program is called WRCMAIN, but I could get the
program name from 'parse source'. Actually I suppose that I should include a
parse source in front and only execute the rest of the routine if the
retuned value for the datasetname is '?'.

Here goes:

.
.
wrcalib = FindMe()
.

FindMe:
x=outtrap('l.')
address tso "lista"
x=outtrap('off')
do i=l.0 to 1 by -1
if pos(".",l.i)=0 then iterate
d="'"l.i"(WRCMAIN)'"
if sysdsn(d)="OK" then return l.i
end
return ""


rgds
Willy

Frank Lindenblatt

unread,
Feb 9, 2000, 3:00:00 AM2/9/00
to
W.Jensen wrote:

> .
> .
> wrcalib = FindMe()
> .
>
> FindMe:
> x=outtrap('l.')
> address tso "lista"
> x=outtrap('off')
> do i=l.0 to 1 by -1
> if pos(".",l.i)=0 then iterate
> d="'"l.i"(WRCMAIN)'"
> if sysdsn(d)="OK" then return l.i
> end
> return ""

This is really a very easy to use example,
but in some circumstances a problem might occur:

If the dataset's allocated to ISPPLIB are listed
prior to the SYSPROC, SYSEXEC or altlib'ed dataset's
AND there is a panel with the REXX's name the function
returns the name of the panel-dataset...


regards
Frank

Ron MacRae

unread,
Feb 9, 2000, 3:00:00 AM2/9/00
to
If the DSN, in Parm 5 is "?" then P4 should be the DDNAME the exec was
loaded from.

Ron MacRae, Amdahl UK.

5 *-* parse source p1 p2 p3 p4 p5 p6 p7
>>> "TSO"
>>> "COMMAND"
>>> "ANEXEC"
>>> "SYSEXEC"
>>> "?"
>>> "?"
>>> "TSO ISPF ?"


Frank Lindenblatt wrote in message ...

W. Jensen

unread,
Feb 9, 2000, 3:00:00 AM2/9/00
to
Actually you can se that I scan from the end of the LISTA list. Reason being
that I use 'activate' a lot and those libs are found at the end of the list.
But it is a good idea to check the ddname and bypass it if can be recognized
as a non-sysproc/rexx lib. I will put that into my code asap.

rgds
Willy

Mark Zelden

unread,
Feb 9, 2000, 3:00:00 AM2/9/00
to
I kind of have something like it already. FINDMOD - it searches the
LPA/LNKLST by default, or a PDS member that contains a list of
libraries to search. It could easily be modified to look at the
output of LISTA STATUS and find where the module lives. But there
are lots of possibilities to code for - SYSEXEC, SYSPROC, SYSUEXEC,
SYSUPROC..etc

When I need to look for CLISTS/EXEC locations now, I always
use ISRDDN. I haven't needed this functionality in any programs that
I've written (yet). If I did, I probably would put some kind of code
to ensure that the REXX was executed explicitly, so PARSE SOURCE
could be used reliably - like checking for the ?, and if it was
exit the exec with an error msg.

Doug Nadel

unread,
Feb 9, 2000, 3:00:00 AM2/9/00
to
On Thu, 10 Feb 2000 00:02:59 GMT, rob...@gte.net (Robert Ngan) wrote:

>There is one other situation I've encountered, if the EXEC resides in a
>function package, then the DD name is '?' as well!
>

I tested the code I put up yesterday as an external function. It
works there too. I haven't tried it from load module yet, but it
should work OK there too unless it is LINKLIST or LPA if that is
possible. That would just be another ELSE condition to search the
LPDEs and LINKLIST libs though, I guess. I just hate the idea of
parsing output meant for human reading (if you can call LISTA ST that
- it has to be one of the most unreadable listings I've ever seen).
I've written several of those execs over the years, but Thanks to
Gilbert's SWAREQ code, those days are over! Whheeee!!!!!

(By the way, using the same TIOT logic, I threw together an edit macro
that generates JCL for running ISPF in batch based on your current
allocations. Kind of neat. Not totally polished yet...
ftp://www.mindspring.com/pub/users/somebody/batchpdf.txt
I'll put a note on ispf-l and a link on my page when it I think it is
done, though it probably just needs a prologue and better attribution)

Robert Ngan

unread,
Feb 10, 2000, 3:00:00 AM2/10/00
to
There is one other situation I've encountered, if the EXEC resides in a
function package, then the DD name is '?' as well!

In article <87s47f$r...@chronicle.concentric.net>, Ron_M...@amdahl.com
says...


> If the DSN, in Parm 5 is "?" then P4 should be the DDNAME the exec was
> loaded from.
>
> Ron MacRae, Amdahl UK.
>

--
Robert Ngan
CSC Financial Services Group


Metz, Seymour

unread,
Feb 10, 2000, 3:00:00 AM2/10/00
to
The term "function packages" implies multiple functions associated with a
single member name. Would parse source return the name of the function or
the name of the package?

Shmuel (Seymour J.) Metz

> -----Original Message-----
> From: Doug Nadel [SMTP:some...@MINDSPRING.COM]
> Sent: Wednesday, February 09, 2000 11:24 PM
>
> On Thu, 10 Feb 2000 00:02:59 GMT, rob...@gte.net (Robert Ngan) wrote:
>

> >There is one other situation I've encountered, if the EXEC resides in a
> >function package, then the DD name is '?' as well!
> >
>

Robert Ngan

unread,
Feb 10, 2000, 3:00:00 AM2/10/00
to
If the exec is in a function package (I was experimenting with IRXFUSER,
[with statically linked in functions] which resides in my STEPLIB) then
you would need to determine what function packages are defined to REXX,
determine their associated load module names, and then search each
specific load module (from STEPLIB, LINKLIST or LPA) for a CSECT name
matching your exec name!

I thought it was nice that you could write function routines in REXX and
putting the commonly referenced ones there would really improve
performance (for search/load operations anyway) but it really makes
finding the source dataset convoluted.

In article <vie4asorp6p8do4k1...@4ax.com>,
some...@mindspring.com says...


> On Thu, 10 Feb 2000 00:02:59 GMT, rob...@gte.net (Robert Ngan) wrote:
>
> >There is one other situation I've encountered, if the EXEC resides in a
> >function package, then the DD name is '?' as well!
> >
>
> I tested the code I put up yesterday as an external function. It
> works there too. I haven't tried it from load module yet, but it
> should work OK there too unless it is LINKLIST or LPA if that is

> possible. That would just be another ELSE condition to search the
> LPDEs and LINKLIST libs though, I guess. I just hate the idea of
> parsing output meant for human reading (if you can call LISTA ST that
> - it has to be one of the most unreadable listings I've ever seen).
> I've written several of those execs over the years, but Thanks to
> Gilbert's SWAREQ code, those days are over! Whheeee!!!!!
>
> (By the way, using the same TIOT logic, I threw together an edit macro
> that generates JCL for running ISPF in batch based on your current
> allocations. Kind of neat. Not totally polished yet...
> ftp://www.mindspring.com/pub/users/somebody/batchpdf.txt
> I'll put a note on ispf-l and a link on my page when it I think it is
> done, though it probably just needs a prologue and better attribution)
>
> Doug Nadel
> ----------------------------------------
> ISPF and OS/390 Tools & Toys page:
> http://somebody.home.mindspring.com/
>

--

Robert Ngan

unread,
Feb 10, 2000, 3:00:00 AM2/10/00
to
I just ran a test with a function package routine, the returned exec name
is '?' so you don't know the exec name, ddname or dataset name!

In article <0D93FE5CA0BED11194CB...@nsfmail01.nsf.gov>,
sm...@NSF.GOV says...


> The term "function packages" implies multiple functions associated with a
> single member name. Would parse source return the name of the function or
> the name of the package?
>
> Shmuel (Seymour J.) Metz
>
> > -----Original Message-----
> > From: Doug Nadel [SMTP:some...@MINDSPRING.COM]
> > Sent: Wednesday, February 09, 2000 11:24 PM
> >

> > On Thu, 10 Feb 2000 00:02:59 GMT, rob...@gte.net (Robert Ngan) wrote:
> >
> > >There is one other situation I've encountered, if the EXEC resides in a
> > >function package, then the DD name is '?' as well!
> > >
> >
> > I tested the code I put up yesterday as an external function. It
> > works there too. I haven't tried it from load module yet, but it
> > should work OK there too unless it is LINKLIST or LPA if that is
> > possible.
>

--

Doug Nadel

unread,
Feb 10, 2000, 3:00:00 AM2/10/00
to
On Thu, 10 Feb 2000 19:09:01 GMT, rob...@gte.net (Robert Ngan) wrote:

>I just ran a test with a function package routine, the returned exec name
>is '?' so you don't know the exec name, ddname or dataset name!

What do you get for the other values? eg: parse source xx;say xx

Robert Ngan

unread,
Feb 10, 2000, 3:00:00 AM2/10/00
to
Complete result from PARSE SOURCE was: TSO SUBROUTINE ? ? ? ? TSO ISPF ?

In article <pra6asstod7p3kp6p...@4ax.com>,
some...@mindspring.com says...

--

Metz, Seymour

unread,
Feb 10, 2000, 3:00:00 AM2/10/00
to
There might not be a CSECT with the same name as the function.

Shmuel (Seymour J.) Metz

Robert Ngan

unread,
Feb 11, 2000, 3:00:00 AM2/11/00
to
Since we're discussing PARSE SOURCE, I assumed the function routine was
written in REXX. The REXX compiler produces a load module with a CSECT
name from the source member name. However, since you can associate any
ADCON with the function name, you are right.

However, this is all moot since PARSE SOURCE does not tell you the name
of the exec (i.e. function) when the exec is in a function package. So
what are we going to look for?

--

Metz, Seymour

unread,
Feb 11, 2000, 3:00:00 AM2/11/00
to
Well, if IBM ever brings the REXX in TSO/E up to the level of the REXX in
OS/2, there will be another complications: in-storage REXX code.
0 new messages