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

Searching GDG using REXX


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

New User


Joined: 15 May 2006
Posts: 28

PostPosted: Thu Mar 15, 2007 11:30 am
Reply with quote

Is there any way to search for a particluar value inside each GDG versions starting from the latest version?

for ex:
i have a GDG say XXX.YYY.ZZZ as base. This GDG is having versions starting from

XXX.YYY.ZZZ.V01 to XXX.YYY.ZZZ.V22.

The Rexx should start the search from V22 to V01 for a value i give as input and stop if any match occurs.

Please somebody help me out.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Thu Mar 15, 2007 1:43 pm
Reply with quote

Think that the default processing when a gdg base is defined as an input DD is last to first.

Have you tried it ?
Back to top
View user's profile Send private message
diwa_thilak

Active User


Joined: 13 Jul 2006
Posts: 205
Location: At my desk

PostPosted: Thu Mar 15, 2007 2:48 pm
Reply with quote

Hi prodigy,

May be the below code will give you some idea.

Code:
$DSN = "TTT.YYY.ZZZ"                             
 $SKU = <your value to be searched>
                                                             
 /*-- LIST ALL GDG ENTRIES FOR THIS DATASET.  --*/           
 Q = OUTTRAP(DATA.)                                         
 "LISTC ENT('"||$DSN||"')"                                   
 Q = OUTTRAP(OFF)                                           
                                                             
 /*-- DETERMINE THE CURRENT GDG DATASET NAME --*/           
 $REC = DATA.0 -1                                           
 PARSE VAR DATA.$REC . . $NAME                               
 SAY 'NAME==>' $NAME

This one will list the latest version of the GDG. From here you have to write search routine to search the GDG and traverse back till first.

If you have any queries rever back to me.

---------------------------
Diwakar
-----------------------------------

Nobody is perfect . I am Nobody
Back to top
View user's profile Send private message
cpuhawg

Active User


Joined: 14 Jun 2006
Posts: 331
Location: Jacksonville, FL

PostPosted: Thu Mar 15, 2007 6:13 pm
Reply with quote

Here is some REXX code. GDGSET should be equal to the GDG base. GDGDSN that is produced at the end will be the most current version of the GDG.

Code:

/* THIS IS USED TO FIND A GDG VERSION */                             
GDG_LEVEL = 0                                                       
GDGSET = "PUT.GDG.BASE.FILE.HERE"                                     
X = OUTTRAP('LISTCAT.')                                             
"LISTCAT LEVEL('"GDGSET"')"                                         
X = OUTTRAP('OFF')                                                   
WORK_LEVEL = 1                                                       
GDGDSN = ""                                                         
DO SUBSCRIPT = LISTCAT.0 - 1 BY -2,                                 
   UNTIL SUBSCRIPT  <  1  |  GDGDSN  <>  ""                         
IF POS("NONVSAM ------- ",LISTCAT.SUBSCRIPT)  >  0  THEN DO         
    PARSE VAR LISTCAT.SUBSCRIPT "NONVSAM ------- " CATDSN " " .     
    CATREV = REVERSE(CATDSN)                                         
    PARSE VAR CATREV  LASTNODE "." GDG_BASE                         
    LASTNODE = REVERSE(LASTNODE)                                     
    GDG_BASE = REVERSE(GDG_BASE)                                     
    PARSE VAR LASTNODE 1 LASTNODE_POS1 2 GEN 6 LASTNODE_POS6 7 LVL   
    IF LASTNODE_POS1 = "G"  &  LASTNODE_POS6 = "V"  THEN DO         
        IF GDG_LEVEL = '+1' THEN DO 
        GEN = GEN + 1                                           
        GEN = RIGHT(GEN,4,"0")                                 
        GDGDSN = GDG_BASE".G"GEN"V"LVL                         
    END                                                         
    ELSE DO                                                     
        WORK_LEVEL = WORK_LEVEL - 1                             
        IF WORK_LEVEL  =  GDG_LEVEL  THEN GDGDSN = CATDSN       
    END                                                         
    END                                                         
    END                                                         
    END                                                         
DATASET = GDGDSN                                               
                               
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Thu Mar 15, 2007 6:47 pm
Reply with quote

As I have pointed out above, using the GDG base will process the entries from last to first.

You DO NOT need to know the absolute generation numbers to process the gdg in this manner.

Please feel free to try this yourselves.

Code:

//MYREXX   EXEC PGM=IKJEFT01,PARM='execname'
//SYSEXEC  DD DSN=where.my.rexx.lives,DISP=SHR
//GDGIN    DD gdg.base.name,DISP=SHR
//SYSTSIN  DD DUMMY
//SYSTSPRT  DD SYSOUT=*
Back to top
View user's profile Send private message
prodigy

New User


Joined: 15 May 2006
Posts: 28

PostPosted: Thu Mar 22, 2007 9:59 pm
Reply with quote

Thanks ppl. i will try out and revert back if needed... thx a lot
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 Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top