IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Display all the datasets of a particular letter -> REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
GThiru

New User


Joined: 19 Feb 2007
Posts: 10
Location: Chennai

PostPosted: Tue May 08, 2007 8:51 pm
Reply with quote

Hi All,

Iam trying to write a Rexx program. The concept is If i give provide a letter as an input the output should be the list of all the dataset which starts with the letter given as input.

For example if i give "A" as input for my rexx exec, the output should be all datasets that starts with the letter "A".

Like "ANF.MSGFILE
ANF.QUEUE
ANF.QUEUE.DATA
ANF.QUEUE.INDEX
AOP.AAOPEXEC
AOP.AAOPHFS
AOP.AAOPHJPN
AOP.AAOPMENU
AOP.AAOPMJPN
AOP.AAOPMOD1
AOP.AAOPPENU
AOP.AAOPPJPN
AOP.SAOPEXEC"


I have created a program which will display all the datasets with that particular HLQ, if i provide "HLQ" as input icon_lol.gif

Code:

/* REXX */                           
/*TRACE I*/     
                     
SAY "ENTER HLQ"                     
PARSE UPPER PULL HLQ                 
IF HLQ="" THEN DO                   
 HLQ=MEMLIST ; MEMLIST="*"           
END           
                     
UPPER HLQ                           
HLQ=STRIP(STRIP(HLQ,"T","*"),"T",".")
DUMMY = OUTTRAP("LISTCAT.","*")     
 
"LISTCAT LEVEL("HLQ")"             
LISTCATRC=RC                       
IF LISTCATRC?=0 THEN DO             
        DO N=1 FOR LISTCAT.0         
          SAY LISTCAT.N             
        END                         
          EXIT LISTCATRC             
         END           
DO N=1 FOR LISTCAT.0                         
      IF WORD(LISTCAT.N,1)= "NONVSAM" THEN , 
      PDSLIST.N= WORD(LISTCAT.N,3)           
  END                                         
     DO I=1 TO LISTCAT.0                     
      PDSLIST.I=STRIP(PDSLIST.I)             
    IF SUBSTR(PDSLIST.I,1,8)="PDSLIST." THEN 
      NOP                                     
      ELSE                                   
      SAY PDSLIST.I                           
                                             
     END                                     
 EXIT                                         


Could any one guide me.. to end up with a good solution. icon_rolleyes.gif

GThiru
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Tue May 08, 2007 11:32 pm
Reply with quote

I'd be a little leery of attempting to list datasets at a level below the first dataset high-level qualifier. The process could take some time and could result in a session time-out due to lack of virtual storage.

That being said, the only way that I know to list datasets below the first HLQ is to use ISPF Library Maintenance (LM) services, specifically the LMDINIT and LMDLIST services. As an example:

Code:

/* REXX */
"ISPEXEC LMDINIT LISTID(idv) LEVEL(A*)"
Do Forever
   "ISPEXEC LMDLIST LISTID("idv") OPTION(LIST) DATASET(dsvar)"
   If rc = 0 Then Say "'"dsvar"'"
   Else Leave
End
"ISPEXEC LMDLIST LISTID("idv") OPTION(FREE)"
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Wed May 09, 2007 12:35 pm
Reply with quote

Quote:
I'd be a little leery of attempting to list datasets at a level below the first dataset high-level qualifier. The process could take some time and could result in a session time-out due to lack of virtual storage.

I agree with what superk has said.
Back to top
View user's profile Send private message
GThiru

New User


Joined: 19 Feb 2007
Posts: 10
Location: Chennai

PostPosted: Wed May 09, 2007 2:10 pm
Reply with quote

Hi Superk & Expat icon_exclaim.gif

Thans for the information... I wil try to modify the REXX program with the example provide. This clue may end up with an accurate output!

Meantime anyone could also guide me.. to add some more extract in it! icon_wink.gif

Once again Thanks a lot!
GThiru icon_lol.gif
Back to top
View user's profile Send private message
GThiru

New User


Joined: 19 Feb 2007
Posts: 10
Location: Chennai

PostPosted: Wed May 09, 2007 3:15 pm
Reply with quote

Hi Superk

Hurray...... I executed the code it's working fine....
You are amazing Super(K) icon_cool.gif .

But i guess that single quotes should be killed

"ISPEXEC LMDINIT LISTID(idv) LEVEL('A*')"


Am i correct icon_question.gif

And could any give me an idea to Get the input from the user
Like

Say " Enter A letter to list Dataset"
Parse upper pull letter
DS="LETTER"||*
"ISPEXEC LMDINIT LISTID(idv) LEVEL('DS')

Is there any way to substitute the user input like mentioned above..
I tried but got errors only.. icon_sad.gif

Thanks & Regards
GThiru icon_lol.gif




[/img]
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Wed May 09, 2007 3:19 pm
Reply with quote

DS="LETTER"||*

Is this a typo, and did you mean to type

DS= LETTER||"*"


I usually use something like

SAY "ENTER DSNAME"
PULL DSN
Back to top
View user's profile Send private message
GThiru

New User


Joined: 19 Feb 2007
Posts: 10
Location: Chennai

PostPosted: Wed May 09, 2007 3:49 pm
Reply with quote

Hey Expat icon_biggrin.gif

Iam trying to get the input from user to display the datasets
In Superk program we are defined in the value in Level, like above specified as "A", Right..

What iam trying to do is..

/*REXX*/
SAY "ENTER A LETTER TO DISPLAY DATASET"
PARSE UPPER PULL LETTER

Suppose iam getting the input value as "B"

Then over here iam concatenating LETTER ("B") with * and assigning it to DS. In order to display all datasets starting with B.

DS= LETTER||"*"

Now substituting DS in Level with in Single quotes..

"ISPEXEC LMDINIT LISTID(IDV) LEVEL('DS')"

DO FOREVER
"ISPEXEC LMDLIST LISTID("IDV") OPTION(LIST) DATASET(DSVAR)"
IF RC = 0 THEN SAY DSVAR
ELSE LEAVE
END
"ISPEXEC LMDLIST LISTID("IDV") OPTION(FREE)"



Could you please let me know whether iam clear in explaining the my doubt....

Thank u Expat icon_wink.gif

Thanks & Regards
GThiru icon_biggrin.gif
Back to top
View user's profile Send private message
GThiru

New User


Joined: 19 Feb 2007
Posts: 10
Location: Chennai

PostPosted: Wed May 09, 2007 3:54 pm
Reply with quote

Hi Expat

But iam getting errors only and not the expected output if i execute the above mentioned REXX. icon_cry.gif

Thanks & Regards
GThiru
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Wed May 09, 2007 4:00 pm
Reply with quote

If

DS= LETTER||"*"

then

"ISPEXEC LMDINIT LISTID(IDV) LEVEL("DS")"

or

"ISPEXEC LMDINIT LISTID(IDV) LEVEL("||DS||")"
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Wed May 09, 2007 4:07 pm
Reply with quote

Yes, but telling us that you are getting errors and not posting the error message is not too much help for us.

What errors are you getting, post an example of the error message or text for us to look at.

Again, as an aside, is it just habit of using the STRIP command, but I guess I'd usually code.

DS= STRIP(LETTER||"*")
Back to top
View user's profile Send private message
GThiru

New User


Joined: 19 Feb 2007
Posts: 10
Location: Chennai

PostPosted: Wed May 09, 2007 4:58 pm
Reply with quote

Hi Superk & Expat

Thanks Dude i have tried using this options given by both of u... icon_smile.gif

Could you please try executing this.. icon_sad.gif

***************************** Top of Data ***************************
/*REXX*/
/*trace*/
SAY "ENTER A LETTER TO DISPLAY DATASETS "
PARSE UPPER PULL HLQ
DS=STRIP(HLQ||"*")
"ISPEXEC LMDINIT LISTID(IDV) LEVEL("'DS'")"
DO FOREVER
"ISPEXEC LMDLIST LISTID("IDV") OPTION(LIST) DATASET(DSVAR)"
IF RC = 0 THEN SAY DSVAR
ELSE LEAVE
END
"ISPEXEC LMDLIST LISTID("IDV") OPTION(FREE)"
**************************** Bottom of Data *************************

When i executed this i got the following output

4 *-* PARSE UPPER PULL HLQ
B
>>> "B"
5 *-* DS=STRIP(HLQ||"*")
>V> "B"
>L> "*"
>O> "B*"
>F> "B*"
6 *-* "ISPEXEC LMDINIT LISTID(IDV) LEVEL("'DS'")"
>L> "ISPEXEC LMDINIT LISTID(IDV) LEVEL("
>L> "DS"
>O> "ISPEXEC LMDINIT LISTID(IDV) LEVEL(DS"
>L> ")"
>O> "ISPEXEC LMDINIT LISTID(IDV) LEVEL(DS)"
7 *-* DO FOREVER
8 *-* "ISPEXEC LMDLIST LISTID("IDV") OPTION(LIST) DATASET(DSVAR)"
>L> "ISPEXEC LMDLIST LISTID("
>V> "ISR00005"
>O> "ISPEXEC LMDLIST LISTID(ISR00005"
>L> ") OPTION(LIST) DATASET(DSVAR)"
>O> "ISPEXEC LMDLIST LISTID(ISR00005) OPTION(LIST) DATASET(DSVAR)"
+++ RC(4) +++
9 *-* IF RC = 0
>V> "4"
>L> "0"
>O> "0"
10 *-* ELSE
*-* LEAVE
7 *-* DO FOREVER
12 *-* "ISPEXEC LMDLIST LISTID("IDV") OPTION(FREE)"
>L> "ISPEXEC LMDLIST LISTID("
>V> "ISR00005"
>O> "ISPEXEC LMDLIST LISTID(ISR00005"
>L> ") OPTION(FREE)"
>O> "ISPEXEC LMDLIST LISTID(ISR00005) OPTION(FREE)"
+++ RC(8) +++
***

And return code as 0, have i done any mistake... icon_cry.gif


What should i do...?

Thanks & Regards
GThiru
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Wed May 09, 2007 5:14 pm
Reply with quote

Try it again yourself, but use TRACE I

I've just run it, was notified of the problem, and then resolved it.


superk - I'm learning more and more about ISPF & LM services thanks to you.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Wed May 09, 2007 5:18 pm
Reply with quote

Try that: "ISPEXEC LMDINIT LISTID(IDV) LEVEL(&DS)"

O.
Back to top
View user's profile Send private message
GThiru

New User


Joined: 19 Feb 2007
Posts: 10
Location: Chennai

PostPosted: Wed May 09, 2007 6:12 pm
Reply with quote

Hi All

Superk Trace was typo mistake.. Thanks dude... icon_smile.gif

Ofer Thanks a lot for the help... icon_smile.gif

Superk, Expat & Ofer....
With the help of you people i got the expected solution..

Hurrray! icon_biggrin.gif

Thanks & Regards
GThiru
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Wed May 09, 2007 6:18 pm
Reply with quote

expat wrote:
superk - I'm learning more and more about ISPF & LM services thanks to you.


I think that anyone who needs to deal with and manipulate dataset lists, ISPF statistics, and PDS's really needs to know how to use the LM services. Our storage management folks unfortunately don't, which I think is rather silly.
Back to top
View user's profile Send private message
GThiru

New User


Joined: 19 Feb 2007
Posts: 10
Location: Chennai

PostPosted: Wed May 09, 2007 7:07 pm
Reply with quote

Hi All

Here is the REXX program for your display, icon_lol.gif which will aslo create a dataset to store the output... & will be dis[layed ini browse mode after executing the REXX.


/*REXX*/
/*TRACE I */
SAY "ENTER A LETTER TO DISPLAY ALL THE DATASET"
PARSE UPPER PULL HLQ
USER = SYSVAR(SYSUID)
PDS =USER||'.DATASET.REPORT'
DATA = SYSDSN("'"PDS"'")
IF DATA = 'OK' THEN
DO
X = MSG('OFF')
"DELETE ('"PDS"')"
X = MSG('ON')
END

"ALLOC DD(DDIN) DA('"PDS"')",
" NEW LRECL(80) RECFM(F B) DSORG(PS) REUSE",
"SPACE(2,1) TRA"

DS=STRIP(HLQ||"*")
"ISPEXEC LMDINIT LISTID(IDV) LEVEL(&DS)"
DO FOREVER
"ISPEXEC LMDLIST LISTID("IDV") OPTION(LIST) DATASET(DSVAR)"
IF RC = 0 THEN
DO
SAY DSVAR
QUEUE " "DSVAR
N = QUEUED()

"ALLOC F(OUT) DS('"PDS"') MOD REUSE"
"EXECIO" N "DISKW OUT(FINIS "
"FREE F(OUT)"
END
ELSE LEAVE
END
"ISPEXEC LMDLIST LISTID("IDV") OPTION(FREE)"
ISPEXEC "BROWSE DATASET('"PDS"')"



Thanks all once again for the patience & guidence


Cheers!
GThiru icon_biggrin.gif
Back to top
View user's profile Send private message
vcjadhav
Warnings : 1

New User


Joined: 27 May 2008
Posts: 19
Location: India

PostPosted: Mon Apr 04, 2016 4:44 pm
Reply with quote

This was really helpful. Thanks guys.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Run rexx with JCL Job CLIST & REXX 1
No new posts Run rexx in batch job CLIST & REXX 7
No new posts Does anyone know rexx for VSE CLIST & REXX 3
No new posts TSO ALLOC In REXX Needs Improvement JCL & VSAM 3
No new posts REXX/CMS How to place command console... CLIST & REXX 4
Search our Forums:

Back to Top