View previous topic :: View next topic
|
Author |
Message |
nirenchan
New User
Joined: 21 Jul 2005 Posts: 23 Location: USA
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
nirenchan
New User
Joined: 21 Jul 2005 Posts: 23 Location: USA
|
|
|
|
Thanks xpat, I'll try this and will update you ! |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
Back to top |
|
|
cpuhawg
Active User
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
|
|
SAS code can be written easily to get full GDG version |
|
Back to top |
|
|
nirenchan
New User
Joined: 21 Jul 2005 Posts: 23 Location: USA
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Running in batch ?
Using IRXJCL ? - If so use IKJEFT01 instead |
|
Back to top |
|
|
karthikraman_m
New User
Joined: 10 Jun 2005 Posts: 12 Location: India
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
nirenchan
New User
Joined: 21 Jul 2005 Posts: 23 Location: USA
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
ilakkia Warnings : 1 New User
Joined: 17 May 2008 Posts: 28 Location: chennai
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
|