View previous topic :: View next topic
Author
Message
vasanthz Global Moderator Joined: 28 Aug 2007Posts: 1744 Location: Tirupur, India
Hi,
I have a requirement to get only the records with a particular DD name.
Only the records that belong to DDNAME "REQUIRED" is needed.
Could you please let me know how we can do this.
Input file: FB LRECL 80
Code:
//JS010 EXEC PGM=IKJEFT01
//REQUIRED DD DSN=WELLS.REQUIRED.DATASET1,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET2,DISP=OLD
//JS010 EXEC PGM=IKJEFT01
//REQUIRED DD DSN=WELLS.REQUIRED.DATASET1,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET2,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET3,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET4,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET5,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET6,DISP=OLD
//RANDOM DD DSN=SOME.DATASET,DISP=OLD
//SYSOUT DD SYSOUT=*
//JS010 EXEC PGM=IKJEFT01
//REQUIRED DD DSN=WELLS.REQUIRED.DATASET1,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET2,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET3,DISP=OLD
Output file: FB LRECL 80
Code:
//REQUIRED DD DSN=WELLS.REQUIRED.DATASET1,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET2,DISP=OLD
//REQUIRED DD DSN=WELLS.REQUIRED.DATASET1,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET2,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET3,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET4,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET5,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET6,DISP=OLD
//REQUIRED DD DSN=WELLS.REQUIRED.DATASET1,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET2,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET3,DISP=OLD
Thanks,
Vasanth.S
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
INCLUDE with a SubStrirng for C'REQUIRED'?
EDIT: To ensure it is a DD, an AND and another SS for C' DD '
Also C'.REQUIRED' would be a little more secure, might manage to exclude a comment on another DD.
Further EDIT: Of course, DSN doesn't have to be on the same line as the DD.... Any "site standards" for your JCL?
Back to top
vasanthz Global Moderator Joined: 28 Aug 2007Posts: 1744 Location: Tirupur, India
Hi,
It was my mistake I missed to mention that the datasets may not have the REQUIRED word in the dataset name.
The dataset name after "DSN= "can be anything.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
So you have "some word", that you know at the time you want to know, and you want to list those with "some word" which may vary from run to run?
Back to top
vasanthz Global Moderator Joined: 28 Aug 2007Posts: 1744 Location: Tirupur, India
Quote:
DSN doesn't have to be on the same line as the DD.... Any "site standards" for your JCL?
Fortunately the "REQUIRED DD" statements all of them look alike.
All the DD statements have DSN in the same line.(these lines of code are generated by a program).
Back to top
vasanthz Global Moderator Joined: 28 Aug 2007Posts: 1744 Location: Tirupur, India
Quote:
So you have "some word", that you know at the time you want to know, and you want to list those with "some word" which may vary from run to run?
Thanks for the reply.
Yes, all records belonging to a particular DD name are needed.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
So where's the catch?
You want it with Sort? rexx? I know you can knock about the odd bit of code or two, in several languages/utilities, so there must be some problem you have encountered to be asking here.
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10879 Location: italy
what about something along the lines of
Code:
000001 //ICE EXEC PGM=SORT
000002 //SYSPRINT DD SYSOUT=*
000003 //SYSOUT DD SYSOUT=*
000004 //SORTIN DD DATA,DLM=$$
==CHG> //YYYYYYYY DD ...1
000006 // DD ...2
000007 //DISCARD DD ....
000008 // DD ....
==CHG> //YYYYYYYY DD ...1
000010 // DD ...2
000011 // DD ...3
000012 $$
000013 //SORTOUT DD SYSOUT=*,
000014 // DCB=(RECFM=FB,LRECL=80)
000015 //SYSIN DD *
000016 OPTION COPY
000017 INREC IFTHEN=(WHEN=GROUP,BEGIN=(3,1,CH,NE,C' '),
000018 PUSH=(81:3,8))
000019 OUTFIL BUILD=(1,80),
000020 INCLUDE=(81,8,CH,EQ,C'YYYYYYYY')
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Thanks enrico. That's what I didn't get. All the DSNs for the DD name of "REQUIRED" (being whatever).
If you want to toss a bunch of JCL in, rather than just DD's, PARSE for " DD " as well.
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10879 Location: italy
the snippet as posted will propagate the name/label to the subsequent <unnamed> statements ( quick and dirty )
when I hear the word parsing I start to itch
it is something that ...
do it properly, or , do not even start thinking about it,
any approximation will lead to wrong results
so I just kept it as simple as possible
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
vasanthz,
Use the following DFSORT JCL which will strip the DSN names for you.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DATA,DLM=$$
//JS010 EXEC PGM=IKJEFT01
//REQUIRED DD DSN=WELLS.REQUIRED.DATASET1,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET2,DISP=OLD
//JS010 EXEC PGM=IKJEFT01
//REQUIRED DD DSN=WELLS.REQUIRED.DATASET1,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET2,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET3,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET4,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET5,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET6,DISP=OLD
//RANDOM DD DSN=SOME.DATASET,DISP=OLD
//SYSOUT DD SYSOUT=*
//JS010 EXEC PGM=IKJEFT01
//REQUIRED DD DSN=WELLS.REQUIRED.DATASET1,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET2,DISP=OLD
// DD DSN=WELLS.REQUIRED.DATASET3,DISP=OLD
$$
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(3,1,CH,NE,C' '),PUSH=(81:3,8)),
IFTHEN=(WHEN=(81,8,CH,EQ,C'REQUIRED'),
PARSE=(%1=(STARTAFT=C'DSN=',ENDBEFR=C' ',ENDBEFR=C',',FIXLEN=44)),
OVERLAY=(90:%1))
OUTFIL BUILD=(90,44),
INCLUDE=(81,8,CH,EQ,C'REQUIRED',AND,90,1,CH,GT,C' ')
//*
The output of this is
Code:
WELLS.REQUIRED.DATASET1
WELLS.REQUIRED.DATASET2
WELLS.REQUIRED.DATASET1
WELLS.REQUIRED.DATASET2
WELLS.REQUIRED.DATASET3
WELLS.REQUIRED.DATASET4
WELLS.REQUIRED.DATASET5
WELLS.REQUIRED.DATASET6
WELLS.REQUIRED.DATASET1
WELLS.REQUIRED.DATASET2
WELLS.REQUIRED.DATASET3
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Having brought it up, I have done it, a somewhat blunt solution, I should think.
Vasanthz is well-capable of understanding symbols in a sort.
Extending enrico's:
Code:
//DDPAR EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DATA,DLM=$$
//YYYY JOB NOTIFYBLAH
//YYYY EXEC PGM=BLAH
//SYSOUT DD SYSOUT=BLAH
//YYYY DD ...1
// DD ...2
//YYYY DD ...1A
//DISCARD DD ....
// DD ....
//YYYY DD ...1
// DD ...2
// DD ...3
$$
//SORTOUT DD SYSOUT=*
//SYMNOUT DD SYSOUT=*
//SYMNAMES DD *
ORIGINAL-RECORD,1,80,CH
OVERLAY-EXTEND-START,*,1,CH
OVERLAY-EXTEND,=,80,CH
PUSH-EXTEND-START,*,1,CH
PUSH-EXTEND,=,80,CH
FIRST-AFTER-SLASHSLASH-FOR-GROUP,3,1,CH
TEST-DDNAME,%1
TEST-FOR-BLANK,C' '
TEST-FOR-DD-STATEMENT,C' DD '
JCL-LINE-START,C'//'
DDNAME-TO-SEARCH-FOR,C'YYYY'
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(TEST-DDNAME=(STARTAFT=JCL-LINE-START,
ENDBEFR=TEST-FOR-DD-STATEMENT,
FIXLEN=80)),
OVERLAY=(OVERLAY-EXTEND-START:TEST-DDNAME)),
IFTHEN=(WHEN=GROUP,
BEGIN=(FIRST-AFTER-SLASHSLASH-FOR-GROUP,
NE,TEST-FOR-BLANK),
PUSH=(PUSH-EXTEND-START:OVERLAY-EXTEND))
OUTFIL BUILD=(ORIGINAL-RECORD),
INCLUDE=(PUSH-EXTEND,EQ,DDNAME-TO-SEARCH-FOR)
//*
Output is:
Code:
//YYYY DD ...1
// DD ...2
//YYYY DD ...1A
//YYYY DD ...1
// DD ...2
// DD ...3
After Symbol Substitution, for those who like:
Code:
OPTION COPY
INREC IFTHEN=(WHEN=INIT,PARSE=(%01=(STARTAFT=C'//',ENDBEFR=C' DD ',FIX*
LEN=80)),OVERLAY=(81:%01)),IFTHEN=(WHEN=GROUP,BEGIN=(3,1*
,CH,NE,C' '),PUSH=(161:81,80))
OUTFIL BUILD=(1,80),INCLUDE=(161,80,CH,EQ,C'YYYY')
Back to top
vasanthz Global Moderator Joined: 28 Aug 2007Posts: 1744 Location: Tirupur, India
Thanks Bill & Enrico for the suggestions and snippets. I would give the above program a try.
Skolusu,
Thanks for the code & the additional parsing bit to get the DSN names. Works Great!
My brains were not working lately and was unable to figure out a solution.
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10879 Location: italy
now it is not clear what the requirement was to start with ...
the raw JCL statements or just the dsnames
Back to top
vasanthz Global Moderator Joined: 28 Aug 2007Posts: 1744 Location: Tirupur, India
The final requirement was to get the dsnames.
I was planning to get the raw JCL statements and then parse the statements later.
But was stuck in the first step of getting raw statements.
Back to top
Please enable JavaScript!