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
 

 

How to check only the first record?

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

New User


Joined: 17 Nov 2005
Posts: 60

PostPosted: Wed Jun 30, 2010 9:18 am    Post subject: How to check only the first record?
Reply with quote

Hello experts:

I have such a file and want to output the whole file(including the 1st record) if the first record matches (1,2,CH,EQ,C'30',AND,18,2,CH,EQ,C'99').
How to code the SORT control command?

Thanks!

Code:

30AAAAAAAAAAAAAAA99
461AAAAAAAAAAAAAAAA
452AAAAAAAAAAAAAAAA
463AAAAAAAAAAAAAAAA
454AAAAAAAAAAAAAAAA
465AAAAAAAAAAAAAAAA
456AAAAAAAAAAAAAAAA
467AAAAAAAAAAAAAAAA
458AAAAAAAAAAAAAAAA
469AAAAAAAAAAAAAAAA
4510AAAAAAAAAAAAAAA
Back to top
View user's profile Send private message

gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Wed Jun 30, 2010 10:21 am    Post subject:
Reply with quote

Hi,

I would use something like this
Code:
//S1       EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                           
30AAAAAAAAAAAAAAA99                                       
461AAAAAAAAAAAAAAAA                                       
452AAAAAAAAAAAAAAAA                                       
463AAAAAAAAAAAAAAAA                                       
454AAAAAAAAAAAAAAAA                                       
465AAAAAAAAAAAAAAAA                                       
456AAAAAAAAAAAAAAAA                                       
467AAAAAAAAAAAAAAAA                                       
458AAAAAAAAAAAAAAAA                                       
469AAAAAAAAAAAAAAAA                                       
4510AAAAAAAAAAAAAAA                                       
/*                                                         
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  OPTION COPY,STOPAFT=1,NULLOUT=RC4                       
  INCLUDE COND=(1,2,CH,EQ,C'30',AND,18,2,CH,EQ,C'99')     
/*                                                         


Now if the return code is 0, you can run step2 to copy the entire file.

I have not provided the JCL for step2, it's just a simple copy.


Gerry
Back to top
View user's profile Send private message
Lord.of.Wind

New User


Joined: 17 Nov 2005
Posts: 60

PostPosted: Wed Jun 30, 2010 11:48 am    Post subject:
Reply with quote

thank you so much Gerry!
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Jun 30, 2010 9:39 pm    Post subject:
Reply with quote

gcicchet,

There is a slight problem with your approach as the INCLUDE COND gets executed before the STOPAFT. So even if 30AAAAAAAAAAAAAAA99 is the 10 th record or any other record your job will issue a return code of 0 which is wrong. Try your job moving the first record anywhere and check it for yourself.

Check this link for illustratration of the processing order for record handling, exits, statements, and options in DFSORT

Lord.of.Wind,

Use the following DFSORT JCL which will copy the entire file in one pass ONLY if the very first record matches (1,2,CH,EQ,C'30',AND,18,2,CH,EQ,C'99') or else it would be empty

I assumed that your input is FB recfm and LRECL of 80
Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
30AAAAAAAAAAAAAAA99                                                   
461AAAAAAAAAAAAAAAA                                                   
452AAAAAAAAAAAAAAAA                                                   
463AAAAAAAAAAAAAAAA                                                   
454AAAAAAAAAAAAAAAA                                                   
465AAAAAAAAAAAAAAAA                                                   
456AAAAAAAAAAAAAAAA                                                   
467AAAAAAAAAAAAAAAA                                                   
458AAAAAAAAAAAAAAAA                                                   
469AAAAAAAAAAAAAAAA                                                   
4510AAAAAAAAAAAAAAA                                                   
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),                   
  IFTHEN=(WHEN=(81,8,ZD,EQ,1,AND,1,2,CH,EQ,C'30',AND,18,2,CH,EQ,C'99'),
  OVERLAY=(89:C'Y'))                                                   
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(89,1,CH,EQ,C'Y'),PUSH=(89:89,1))   
  OUTFIL BUILD=(1,80),INCLUDE=(89,1,CH,EQ,C'Y')                       
//*
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Thu Jul 01, 2010 5:57 am    Post subject:
Reply with quote

Hi Skolusu,

I apologise for providing an incorrect solution.

In your example which I cannot test GROUP due an old version of DFSORT,
are you still reading the entire file ?

Would it not be best to copy out 1st record only and test it, it's no point reading the entire file when only the first record needs to be tested. especially if it happens to be a large input file.

Gerry
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Jul 01, 2010 9:30 pm    Post subject:
Reply with quote

gcicchet wrote:
Would it not be best to copy out 1st record only and test it, it's no point reading the entire file when only the first record needs to be tested. especially if it happens to be a large input file.

Gerry


gcicchet,

Yes I would read the entire file, but it is a good idea to just validate the first record and then copy it. In that case OP needs to use the following control cards

Code:

//SYSIN    DD *                                                   
  OPTION COPY,STOPAFT=1                                           
  OUTFIL NULLOFL=RC4,INCLUDE=(1,2,CH,EQ,C'30',AND,18,2,CH,EQ,C'99')
//*


This will set a return code of 4 if the first record does not match the include cond.
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 What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm


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