Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Select records under a specific DD name.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Fri Feb 03, 2012 4:20 pm    Post subject: Select records under a specific DD name.
Reply with quote

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
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Fri Feb 03, 2012 5:05 pm    Post subject: Reply to: Select records under a specific DD name.
Reply with quote

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
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Fri Feb 03, 2012 5:09 pm    Post subject:
Reply with quote

Hi,
It was my mistake I missed to mention that the datasets may not have the REQUIRED word in the dataset name. icon_redface.gif

The dataset name after "DSN= "can be anything.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Fri Feb 03, 2012 5:11 pm    Post subject: Reply to: Select records under a specific DD name.
Reply with 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?
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Fri Feb 03, 2012 5:13 pm    Post subject:
Reply with quote

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
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Fri Feb 03, 2012 5:28 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Fri Feb 03, 2012 6:20 pm    Post subject: Reply to: Select records under a specific DD name.
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Feb 03, 2012 6:37 pm    Post subject: Reply to: Select records under a specific DD name.
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Fri Feb 03, 2012 6:50 pm    Post subject: Reply to: Select records under a specific DD name.
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Feb 03, 2012 7:11 pm    Post subject: Reply to: Select records under a specific DD name.
Reply with quote

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 icon_wink.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Feb 03, 2012 10:22 pm    Post subject: Reply to: Select records under a specific DD name.
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Fri Feb 03, 2012 10:22 pm    Post subject: Reply to: Select records under a specific DD name.
Reply with quote

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
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Feb 06, 2012 9:27 pm    Post subject:
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Feb 06, 2012 9:41 pm    Post subject: Reply to: Select records under a specific DD name.
Reply with quote

now it is not clear what the requirement was to start with ...
the raw JCL statements or just the dsnames icon_eek.gif
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Feb 06, 2012 9:48 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us