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

Reading 0th Generation of GDG in REX


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

New User


Joined: 19 May 2006
Posts: 26

PostPosted: Sat May 31, 2014 3:29 am
Reply with quote

Hi,

I have the below code in my REXX which works fine if I hard code the generation of the GDG. But I need to read the 0th generation of the GDG in my REXX.

So when I have my code as below, it works fine:
Code:

ADDRESS TSO
"ALLOC FI(Flfi) DSN('MYGDG.GDG1.G0001V00') SHR REU"
"EXECIO 10 DISKR Flfi 100 (STEM rec1. FINIS"
"Free FI(Flfi)

But When IU use the below it fails.
Code:

ADDRESS TSO
"ALLOC FI(Flfi) DSN('MYGDG.GDG1(0)') SHR REU"
"EXECIO 10 DISKR Flfi 100 (STEM rec1. FINIS"
"Free FI(Flfi)


The error I get is:
IKJ56709I INVALID DATA SET NAME, 'MYGDG.GDG1(0)'
IKJ56709I MISSING DATA SET NAME OR *+
IKJ56709I MISSING NAME OF DATA SET TO BE ALLOCATED
IRX0555E The input or output file FLFI is not allocated. It cannot be opened for I/O.
IRX0555E EXECIO error while trying to GET or PUT a record.
IKJ56247I FILE FLFI NOT FREED, IS NOT ALLOCATED


Can you please help me out here? How can I read in the 0th generation in my Rexx instead of using the hard-coded generation number.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat May 31, 2014 4:18 am
Reply with quote

BPXWDYN
Back to top
View user's profile Send private message
Pete Wilson

Active Member


Joined: 31 Dec 2009
Posts: 580
Location: London

PostPosted: Mon Jun 09, 2014 4:33 pm
Reply with quote

You may need to call IDCAMS to get the latest generation. Check the creation dates to confirm which is the latest generation and also check the STATUS field indicates 'ACTIVE' to make sure it is a valid rolled-in generation as well.

Another way could be to specify it in the JCL if the REXX is running in Batch.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Mon Jun 09, 2014 6:18 pm
Reply with quote

If you want to move into using ISPF routines, you can use something like:
"ISPEXEC LMDINIT LISTID(DSLIST) LEVEL(&QUAL)"

Where QUAL contains 'MYGDG.GDG1.G*'

Then, you walk the list to the end to get the current generation with something like:
DO WHILE RC=0
"ISPEXEC LMDLIST LISTID(&DSLIST)",
"DATASET(DSNVAR) OPTION(LIST) STATS(YES)"

This may be bad advice for several reasons, like needing ISPF in batch, or the complexity of the LMDLIST code. I like it because it handles it all inside the rexx.
Back to top
View user's profile Send private message
Pete Wilson

Active Member


Joined: 31 Dec 2009
Posts: 580
Location: London

PostPosted: Mon Jun 09, 2014 6:34 pm
Reply with quote

I suggested the IDCAMS approach because of the issue of wrapping GDG numbers (going from G9999V00 to G0001V00) and also deferred or rolled-off GDG's which may have the highest number but are not the (0) generation. Checking the creation date along with the status field together mean you're going to have a lower risk of getting the wrong file.

Of course there's probably other query tools beside IDCAMS (FDREPORT for example, maybe Naviquest, or DCOLLECT) that would provide some or all of the same information.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jun 09, 2014 7:25 pm
Reply with quote

again what is wrong using BPXWDYN ...

the snippet ...

Code:

 ****** ***************************** Top of Data ******************************
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  7 Line(s) not Displayed
 000008 /* Rexx  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000009 Trace "O"
 000010 ddn  = "DDN"
 000011 gdg  = "ENRICO.TEST.GDG"
 000012 gen  = "0"
 000013 rtrc = BPXWDYN("ALLOC FI(DDN) DA('ENRICO.TEST.GDG("gen")')" ,
 000014                " SHR REUSE  RTDSN(RTDSN) ")
 000015
 000016 say "myrc " RTRC
 000017 say "realname" RTDSN
 000018 exit
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 11 Line(s) not Displayed
 ****** **************************** Bottom of Data ****************************


the result
Code:

********************************* TOP OF DATA **********************************
myrc  0
realname ENRICO.TEST.GDG.G0003V00
******************************** BOTTOM OF DATA ********************************


why complicate things when a simpler solution is there ???

PS.
the snippet shows how to allocate and retrieve the REAL dsname
the RTDSN part can be dropped for a plain allocation
Back to top
View user's profile Send private message
don.leahy

Active Member


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

PostPosted: Mon Jun 09, 2014 8:52 pm
Reply with quote

I'm with you Enrico. I've been using BPXWDYN exclusively for this task ever since I first learned about it.

IMO, all of those other tricks that we formerly used to obtain the absolute generation are obsolete. icon_cool.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jun 09, 2014 9:56 pm
Reply with quote

Quote:
IMO, all of those other tricks that we formerly used to obtain the absolute generation are obsolete.


I used REALNAME by Doug Nadel

and/or FULLDSN the equivalent from GFS
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Tue Jun 10, 2014 7:12 pm
Reply with quote

Now that I've seen how it works...I'll switch to BPXWDYN.
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 Reading dataset in Python - New Line ... All Other Mainframe Topics 22
No new posts DFHPI1008 JSON generation failed COBOL Programming 0
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Started task using a generation dataset JCL & VSAM 7
No new posts Report generation JCL & VSAM 18
Search our Forums:

Back to Top