Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

PARSE SOURCE and identifying the EXEC dataset.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Josh Keller

New User


Joined: 08 Oct 2007
Posts: 36
Location: Columbia, SC

PostPosted: Thu Mar 24, 2011 7:46 pm    Post subject: PARSE SOURCE and identifying the EXEC dataset.
Reply with quote

According to the documentation, I should be able to get the dataset name my REXX was run from, however I get a "?" instead.

Here's a display of the PARSE SOURCE data when I type TSO REXX2 on my command line. REXX2 is located in my pds, so I expected to see that reflected below.

Code:
 TSO COMMAND REXX2 SYSEXEC ? ? TSO ISPF ?



What am I missing?
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Mar 24, 2011 8:43 pm    Post subject:
Reply with quote

what does REXX2 look like?
Back to top
View user's profile Send private message
Josh Keller

New User


Joined: 08 Oct 2007
Posts: 36
Location: Columbia, SC

PostPosted: Thu Mar 24, 2011 8:51 pm    Post subject:
Reply with quote

It does nothing other than display the SOURCE data.

Code:
/* REXX */
ARG ARGS
PARSE SOURCE SRCEDATA
SAY SRCEDATA
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1714
Location: UK

PostPosted: Thu Mar 24, 2011 9:09 pm    Post subject:
Reply with quote

Possibly nothing as I get the same result. The manual does NOT say that you will DEFINITELY get the dataset name so maybe this has not been implemented in zOS/MVS
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Thu Mar 24, 2011 9:27 pm    Post subject:
Reply with quote

I get the same result. If the Rexx program is loaded from a concatenation (such as SYSEXEC or SYSPROC) it does not provide the data set name that it was loaded from. (Note that this is just my observation; the manual does not explicitly tell you when the DSN is "not known".)

If you execute it explicitly: TSO EX 'your.library.name(REXX2)' then the DSN is returned.
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

PostPosted: Thu Mar 24, 2011 9:33 pm    Post subject: Reply to: PARSE SOURCE and identifying the EXEC dataset.
Reply with quote

Here's my understanding:

If you use the EXEC TSO command to execute your exec, you see the results like:

TSO COMMAND execname SYS00028 datasetname ? TSO ISPF ?

whereas if you have your exec in a system library and execute it explicitly:

TSO COMMAND execname SYSPROC ? ? TSO ISPF ?

the manual should probably be clearer.
Back to top
View user's profile Send private message
Josh Keller

New User


Joined: 08 Oct 2007
Posts: 36
Location: Columbia, SC

PostPosted: Thu Mar 24, 2011 9:36 pm    Post subject:
Reply with quote

I saw that Nic.

The manual states. "If the name is not know, this token is a question mark." So how do I ensure its known ?

Perhaps its the way I allocat my concatenations? I use TRX ADD. I know ALTLIB is another method. I can give that a try and let ya'll know.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 641
Location: Whitby, ON, Canada

PostPosted: Thu Mar 24, 2011 10:13 pm    Post subject:
Reply with quote

If you really need to know the DSN, you can search the SYSEXEC concatenation using ISPF services.

I have also seen some nasty looking Rexx code that traverses control blocks to return the DSNs in a concatenation.
Back to top
View user's profile Send private message
Josh Keller

New User


Joined: 08 Oct 2007
Posts: 36
Location: Columbia, SC

PostPosted: Thu Mar 24, 2011 10:19 pm    Post subject:
Reply with quote

Just tested that

TSO EX 'TSO.SOME.PDS(REXX2)'

I get this result:

TSO COMMAND REXX2 SYS00032 TSO.SOME.PDS ? TSO ISPF ?

I guess that seems pointless, because if I tell TSO what I want to execute, then why whould I need to check for it?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Mar 24, 2011 10:30 pm    Post subject:
Reply with quote

Cribbed from one place I worked before
Code:
Parse Source . howcalled  module . mod_lib .
Parse Arg parm .
If mod_lib = "?" Then mod_lib = find_origin()


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                          /*@ FIND_ORIGIN               */
/* ----------------------------------------------------------------- */
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              /*@ SWAREQ                    */
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Mar 24, 2011 10:34 pm    Post subject: Reply to: PARSE SOURCE and identifying the EXEC dataset.
Reply with quote

Quote:
I guess that seems pointless, because if I tell TSO what I want to execute, then why whould I need to check for it?


No... it is not pointless
there are quite a lot of programs, with aliases where the name under which the program is invoked determines the function provided

for example I have a script for optimum blksize computation
it can be invoked as
blkszcal device lrecl [keylen]

I gave the aliases blks3350 and blks3390 in order to use parse source to find the script name
and use it as a canned parameter

blks3390 lrecl [keylen]
instead of
blkszcal 3390 lrecl [keylen]

by the way the manual seems clear enough to me

Code:
/* REXX */
parse source _src
parse version _ver
say "parse version _ver ==>"_ver
say "parse source  _src ==>"_src
exit



on TSO
Code:
parse version _ver ==>REXX370 3.48 01 May 1992
parse source  _src ==>TSO COMMAND TEST2 SYSPROC ? ? TSO ISPF ?


the same on my mac

Code:
enrico-mbp:ztests enrico$ ./test2.rx
parse version _ver ==>REXX-ooRexx_4.2.0(MT) 6.04 18 Mar 2011
parse source  _src ==>MACOSX COMMAND /Users/enrico/ztests/test2.rx
enrico-mbp:ztests enrico$ rexx test2.rx
parse version _ver ==>REXX-ooRexx_4.2.0(MT) 6.04 18 Mar 2011
parse source  _src ==>MACOSX COMMAND /Users/enrico/ztests/test2.rx
Back to top
View user's profile Send private message
Josh Keller

New User


Joined: 08 Oct 2007
Posts: 36
Location: Columbia, SC

PostPosted: Thu Mar 24, 2011 11:29 pm    Post subject: Re: Reply to: PARSE SOURCE and identifying the EXEC dataset.
Reply with quote

Quote:
there are quite a lot of programs, with aliases where the name under which the program is invoked determines the function provided


I understand that.

What if, in my case, I want to determine the funtion based on the dataset that my REXX executed from?

From what I've discovered, PARSE SOURCE you will only return the dataset if you fully qualify the exec using TSO EX 'TSO.MYPDS.PDS(REXX2)' which doesn't satisfy my scenerio as users will type TSO REXX2.

While there's a multitude of ways to achive my result, I wanted to know why PARSE SOURCE wasn't returning the data in my case before I moved on to my next option.


Also Enrico, is that REXX for MacOS a free download somewhere? I might be interested in that.


Thanks for everyone's help! I found my answer!
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Mar 24, 2011 11:48 pm    Post subject: Reply to: PARSE SOURCE and identifying the EXEC dataset.
Reply with quote

You can download it from here
http://sourceforge.net/projects/oorexx/
for a precompiled install ( universal IIRC )

I prefer to download it from the svn and build it myself ( I have some personal mods implemented )
( to build just 64 bits things )

for just the rexx interpreter
svn co https://oorexx.svn.sourceforge.net/svnroot/oorexx/main/trunk oorexx-svn

for the whole svn repository including the incubator with the developers workareas
svn co https://oorexx.svn.sourceforge.net/svnroot/oorexx oorexx-svn-full

the bolded directories are my choices/standards due to my setup

if You are going to install it let me now and I' ll share the solution for some issues

my directory structure

/opt
/opt/ooRexx <== the install dir
/opt/ooRexx-svn <== svn for rexx basics
/opt/ooRexx-svn-full <== svn for the full shebang

there are some quirks because the tool chain used by xcode has a couple of components backlevel

here is the configure script I am using

Code:
#! /bin/bash

PREFIX="/opt/ooRexx"

BUILD="x86_64-apple-darwin10.6.0"
HOST="x86_64-apple-darwin10.6.0"
TARGET="x86_64-apple-darwin10.6.0"

./configure  --prefix="${PREFIX}"\
  --disable-nls \
  --build=${BUILD} \
  --host=${HOST} \
  --target=${TARGET}

RC=$?
if [ ${RC} != 0 ] ; then
 echo "./configure script failed"
fi


I run on a mac book pro core2 duo 2.8 ghz 8 gb 1033
and on an iMac core i7 2.93 ghz quad core 16 gb 1333

snow leopard 10.6.7
xcode tools 3.2.6

and everything runs very smoothly icon_biggrin.gif

I also run vmware with Fedora core 14 same directory setup
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

PostPosted: Thu Mar 24, 2011 11:55 pm    Post subject: Re: Reply to: PARSE SOURCE and identifying the EXEC dataset.
Reply with quote

Josh Keller wrote:
What if, in my case, I want to determine the funtion based on the dataset that my REXX executed from?


I guess that, knowing the DDNAME that the exec is executing from, it's a matter of searching each of the PDS's in the concatenation and finding the first occurence of the exec.

Wonder if someone's already come up with a simpler solution ... might have to check (I'm curious) and see ...
Back to top
View user's profile Send private message
Josh Keller

New User


Joined: 08 Oct 2007
Posts: 36
Location: Columbia, SC

PostPosted: Thu Mar 24, 2011 11:56 pm    Post subject:
Reply with quote

Thanks, I'll give it a try this weekend.
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

PostPosted: Fri Mar 25, 2011 12:38 am    Post subject: Reply to: PARSE SOURCE and identifying the EXEC dataset.
Reply with quote

A tiny study in feasability:

Code:

/* REXX */
Parse Source . . execname ddname dsname .
If dsname = '?' Then
  Do
    "ISPEXEC QBASELIB "ddname" ID(dslist)"
    Do Forever
      Parse Var dslist dsname ',' dslist
      If Length(dslist) = 0 Then Leave
      Call Outtrap(ml.)
      "LISTDS "dsname" MEMBERS"
      Call Outtrap(Off)
      Do i = 7 To ml.0
        If Pos(execname,ml.i) <> 0 Then
          Do
            dsn = dsname
            Leave
          End
      End
    End
  End
Else dsn = "'"dsname"'"
Say execname "is a member of" dsn
Exit 0
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm
No new posts Identifying the emulator used vasanthz All Other Mainframe Topics 8 Thu Sep 29, 2016 2:17 am
No new posts Allocate dataset withour BLKSIZE Susanta CLIST & REXX 2 Thu Sep 22, 2016 11:51 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us