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

Extract Dataset Name using Rexx. not working for GDG.


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

New User


Joined: 21 Jul 2005
Posts: 23
Location: USA

PostPosted: Fri Mar 28, 2008 11:44 am
Reply with quote

Hi,

I want to extract Dataset name using REXX. the Input by JCL and I created one and its working fine with PS or PDS names but not working for GDG.

Purpose: Extract the generation and write the same to new Dataset.
Eg: input here is MG01D.MEX.DATA.G00V00
I want output, write to new dataset: G00V00.

But here, its working fine when we mention MG01D.MEX.DATA.G00V00 but not working if MG01D.MEX.DATA(0).

JCL:
Code:

//*                                             
//    SET  EXECLIB=MG01D.REXX.EXEC           
//    JCLLIB ORDER=(&EXECLIB.)                 
//*                                             
//IRXJCL1  EXEC PGM=IRXJCL,PARM='REXXGDG'       
//SYSEXEC  DD DSN=&EXECLIB.,DISP=SHR           
//SYSPRINT DD SYSOUT=*                         
//SYSTSPRT DD SYSOUT=*                         
//SYSTSIN  DD *                                 
MG01D.MEX.DATA.G00V00                       
/*                                             
//INSRCH   DD DSN=MG01D.MEX.DATA.G00V00,     
//         DISP=SHR                             
//OUTSRCH  DD DSN=MG01D.REXX.TEST.OUT,         
//         DISP=(OLD,,KEEP),                   
//         DCB=(RECFM=FB,LRECL=80,BLKSIZE=0),   
//         SPACE=(10,(10,5),RLSE) 
//***********************************************
//                                                         


REXX:
Code:

/* REXX */                                                             
"EXECIO * DISKR INSRCH(STEM IN.FINIS";                                 
PARSE UPPER PULL DSN                                                   
SAY "DSN=" DSN                                                         
GDG = SUBSTR(DSN,19,8)                                                 
SAY GDG                                                               
SAY "HELLO"                                                           
QUEUE GDG                                                             
"EXECIO * DISKW OUTSRCH (FINIS";                                       


Please help me:
1. how can I use MG01D.MEX.DATA(0)
2. what is the use of SYSTSIN here. I'm not getting. but with out that its not working properly. that will copy all data to outputfile instead to extract the dsn name.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri Mar 28, 2008 12:49 pm
Reply with quote

You can not use the relative generation within REXX like that.

Try this to get the real generation number, I've used it in the past with no problems. You could also execute IDCAMS LISTCAT within the REXX and parse the output, and I know that there is at least one code sample on the forum because I posted it.
Code:

X   = LISTDSI("INSRCH  FILE")
DSNAME = SYSDSNAME
Back to top
View user's profile Send private message
nirenchan

New User


Joined: 21 Jul 2005
Posts: 23
Location: USA

PostPosted: Fri Mar 28, 2008 1:10 pm
Reply with quote

Thanks xpat, I'll try this and will update you !
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Mar 28, 2008 1:19 pm
Reply with quote

or if You can install things ...
"REALNAME"
http://www.sillysot.com/mvs/index.htm?realname.htm

"FULLDSN"
http://gsf-soft.com/Freeware/FILE183-index.shtml
http://gsf-soft.com/Freeware
Back to top
View user's profile Send private message
cpuhawg

Active User


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

PostPosted: Fri Mar 28, 2008 5:52 pm
Reply with quote

Here is some REXX code for isolating the latest GDG version.

Code:

/* FIND THE GDG LEVEL OF THE DATASET   */
GDG_LEVEL = 0                                                     
GDGSET = "HLQ.GDG.PATTERN.DATASET"                 
X = OUTTRAP('LISTCAT.')                                           
"LISTCAT LEVEL('"GDGSET"')"                                       
X = OUTTRAP('OFF')                                                 
WORK_LEVEL = 1                                                     
GDGDSN = ""                                                       
DO SUBSCRIPT = LISTCAT.0 - 1 BY -1,                               
   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                                                       


Code GDGSET variable with the dataset pattern of the GDG you are seeking the version number of. Once this code executes, the latest GDG version dataset name is stored in the DATASET variable.
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Fri Mar 28, 2008 7:00 pm
Reply with quote

FWIW, this would've worked:

Code:

/* REXX */
PARSE UPPER PULL DSN .
SAY "DSN=" DSN                                                         
ALLOCSTR = "ALLOC FI(DD1) DA('"DSN"') SHR REUSE RTDSN(THEDSN)"
"CALL BPXWDYN(ALLOCSTR)"
DOT = LASTPOS('.',THEDSN)
GDG = STRIP(SUBSTR(THEDSN,(DOT+1),8))                                             
SAY GDG                                                               
SAY "HELLO"                                                           
QUEUE GDG                                                             
"EXECIO "QUEUED() "DISKW OUTSRCH (FINIS"
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Sat Mar 29, 2008 4:01 am
Reply with quote

FWIW, So would this
Code:

GDG = "GDG base name"
DSN = STRIP(GDG!!".G0000V00")               /* DEFAULT IF NOT EXIST  */
X=OUTTRAP(LST.)                             /* LISTCAT GDG BASE      */
" LISTC ENT('"GDG"')"
X=OUTTRAP(OFF)
DO A = LST.0 TO 1 BY -1                     /* FIRST FIND = 0 GDG    */
  IF POS('NONVSAM',LST.A) > 0 THEN DO
    DSN = SUBSTR(LST.A,POS('NONVSAM',LST.A)+13,44)
    A = 0
  END
END
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Sat Mar 29, 2008 6:08 am
Reply with quote

SAS code can be written easily to get full GDG version
Back to top
View user's profile Send private message
nirenchan

New User


Joined: 21 Jul 2005
Posts: 23
Location: USA

PostPosted: Tue Apr 01, 2008 5:01 pm
Reply with quote

Thanks all guys !..

But still not working

@ Expact.. I tried your code and I'm getting the error:

DSN= MG01D.MEXICO.DATA
6 +++ X=OUTTRAP(LST.) /* LISTCAT GDG BASE
IRX0043I Error running REXXGD2, line 6: Routine not found
******************************** Bottom of Data ****************************

=================================

I've used the below code and mentioned the GDG Base name in JCL:

Code:

/* REXX */                                                             
"EXECIO * DISKR INSRCH(STEM IN.FINIS";                                 
PARSE UPPER PULL GDG                                                   
SAY "DSN=" GDG                                                         
DSN = STRIP(GDG!!".G0000V00")               /* DEFAULT IF NOT EXIST  */
X=OUTTRAP(LST.)                             /* LISTCAT GDG BASE      */
" LISTC ENT('"GDG"')"                                                   
X=OUTTRAP(OFF)                                                         
DO A = LST.0 TO 1 BY -1                     /* FIRST FIND = 0 GDG    */
  IF POS('NONVSAM',LST.A) > 0 THEN DO                                   
    DSN = SUBSTR(LST.A,POS('NONVSAM',LST.A)+13,44)                     
    A = 0                                                               
  END                                                                   
END                                                                     
SAY "DSN NEW =" DSN                                                     
QUEUE DSN                                                               
"EXECIO * DISKW OUTSRCH (FINIS"



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

Global Moderator


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

PostPosted: Tue Apr 01, 2008 7:49 pm
Reply with quote

Running in batch ?

Using IRXJCL ? - If so use IKJEFT01 instead
Back to top
View user's profile Send private message
karthikraman_m

New User


Joined: 10 Jun 2005
Posts: 12
Location: India

PostPosted: Tue Apr 01, 2008 8:24 pm
Reply with quote

Hi Nirenchan,

If you only want to use the file name and not to read/update the file, pass the file name as argument from the JCL. You may want to look into threads in JCL forum which discuss the ways to retrieve GDG file name. The argument can be pulled using 'Arg' keyword in REXX program.

As expat mentioned, use IKJEFT01 to execute your REXX routine.

SYSTSIN is used to provide input to the exec program. In IKJEFT01, this DD is used to provide the REXX routine name and arguments if any. I am not sure about IRXJCL.

Thanks,
Karthik Raman
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 Apr 02, 2008 1:19 am
Reply with quote

FYI, expat's code worked fine for me. However, there's something I don't understand:

"EXECIO * DISKR INSRCH (STEM IN. FINIS"

I see where that you read this dataset, but nothing else is done with it. What's the purpose of this line of code?
Back to top
View user's profile Send private message
nirenchan

New User


Joined: 21 Jul 2005
Posts: 23
Location: USA

PostPosted: Wed Apr 02, 2008 5:14 pm
Reply with quote

Thanks a lot to all who find time to get the solution !!!!!!!!!!...Thanks a lot ~!!!!!!


@expat

Yes, I used IRXJCL before. After your comment, I've updated the jcl with IKJEFT01 and it worked for me. Please find the JCL Code and the output... Useful to some one else ... :-)

@ Karthik,
Thanks a lot for the explanation..that helps me a lot. After your reply, I used the parameter as an Arguement and I got the result.

Thanks again for the explanation for SYSTSIN.

@superk.

I'm still in learning phase. I just copy paste the code. from and old one and forgot to remove some :-)


=====================================

JCL:

// SET EXECLIB=MG01D.REXX.EXEC
// JCLLIB ORDER=(&EXECLIB.)
//*
//IRXJCL1 EXEC PGM=IKJEFT01,PARM='REXXGD3'
//SYSEXEC DD DSN=&EXECLIB.,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
MG01D.MEXICO.DATA
/*
//*
//OUTSRCH DD DSN=MG01D.REXX.TEST.OUT,
// DISP=(OLD,,KEEP),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0),
// SPACE=(10,(10,5),RLSE)
//***********************************************
//
================================================

REXX Code:

/* REXX */
PARSE UPPER PULL GDG
DSN = STRIP(GDG!!".G0000V00") /* DEFAULT IF NOT EXIST */
X=OUTTRAP(LST.) /* LISTCAT GDG BASE */
" LISTC ENT('"GDG"')"
X=OUTTRAP(OFF)
DO A = LST.0 TO 1 BY -1 /* FIRST FIND = 0 GDG */
IF POS('NONVSAM',LST.A) > 0 THEN DO
DSN = SUBSTR(LST.A,POS('NONVSAM',LST.A)+13,44)
A = 0
END
END
SAY "GDG=" GDG
SAY "DSN =" DSN
GDG1= SUBSTR(DSN,19,8)
QUEUE GDG1
"EXECIO "QUEUED() "DISKW OUTSRCH (FINIS"
==============================================
OUTPUT:

VIEW MG01D.REXX.TEST.OUT Columns 00001 00072
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
000001 G0007V00
****** **************************** Bottom of Data ***********

===============================================
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri Apr 04, 2008 6:14 pm
Reply with quote

Where you have coded

GDG1= SUBSTR(DSN,19,8)

I would have used GDG1 = RIGHT(DSN,8)

Which would work if the length of the GDG base changed, where your code would only work if the GDG base was 18 bytes long.
Back to top
View user's profile Send private message
ilakkia
Warnings : 1

New User


Joined: 17 May 2008
Posts: 28
Location: chennai

PostPosted: Mon Dec 08, 2008 8:46 am
Reply with quote

In the REXX code below:

/* REXX */
PARSE UPPER PULL GDG
DSN = STRIP(GDG!!".G0000V00") /* DEFAULT IF NOT EXIST */
X=OUTTRAP(LST.) /* LISTCAT GDG BASE */
" LISTC ENT('"GDG"')"
X=OUTTRAP(OFF)
DO A = LST.0 TO 1 BY -1 /* FIRST FIND = 0 GDG */
IF POS('NONVSAM',LST.A) > 0 THEN DO
DSN = SUBSTR(LST.A,POS('NONVSAM',LST.A)+13,44)
A = 0
END
END
SAY "GDG=" GDG
SAY "DSN =" DSN
GDG1= SUBSTR(DSN,19,8)
QUEUE GDG1
"EXECIO "QUEUED() "DISKW OUTSRCH (FINIS"

/* REXX

please explain the part,

IF POS('NONVSAM',LST.A) > 0 THEN DO
DSN = SUBSTR(LST.A,POS('NONVSAM',LST.A)+13,44)

why 13 is used? & why 44 is used?

Please explain.
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 Dec 09, 2008 12:59 am
Reply with quote

I think that poster was coding as if the dataset name starts in the 13th position of the LISTCAT output (it doesn't). The 44 is, of course, the absolute longest value that a dataset name can be, as documented here.

Honestly, that's rather poor coding. A PARSE statement would be much more effective and easier to follow.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Tue Dec 09, 2008 12:16 pm
Reply with quote

superk wrote:
I think that poster was coding as if the dataset name starts in the 13th position of the LISTCAT output (it doesn't).

The coding says that the dataset name will be found 13 bytes after the position of where the string 'NONVSAM' was found, not that it starts in pos 13.
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 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
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
Search our Forums:

Back to Top