MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Validating Trailer Count on File Using SORT

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
WallaceC
Beginner


Joined: 17 Dec 2002
Posts: 22
Topics: 10

PostPosted: Wed Apr 16, 2008 5:25 pm    Post subject: Validating Trailer Count on File Using SORT Reply with quote

Besides writing COBOL program, is it possible to use SORT on a job to validate trailer count on a file and return condition codes depending upon if number of detail records matching trailer count or not.

EXAMPLE 1
INPUT FILE:

Code:
1HDR
2DTLAAAAA
2DTLBBBBB
2DTLCCCCC
9TRL  00000003


Number of 2DTL records = 3, count on 9TRL record = 3
==> counts match and return code = 0

EXAMPLE 2
INPUT FILE:

Code:
1HDR
2DTLAAAAA
2DTLBBBBB
2DTLCCCCC
9TRL  00000004



Number of 2DTL records = 3, count on 9TRL record = 4
==> counts mismatch and return code > 0
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Apr 16, 2008 6:35 pm    Post subject: Reply with quote

You can use a DFSORT job like the following to do what you asked for. Note that you need z/OS DFSORT V1R5 to use NULLOUT (it's not supported in DFSORT R14).

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
1HDR
2DTLAAAAA
2DTLBBBBB
2DTLCCCCC
9TRL  00000004
/*
//SYM DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//TRL DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL FNAMES=SYM,INCLUDE=(1,1,CH,EQ,C'9'),
    BUILD=(C'OCOUNT,+',7,8,80:X)
  OUTFIL FNAMES=TRL,REMOVECC,NODETAIL,
    INCLUDE=(1,1,CH,EQ,C'2'),
    BUILD=(8X),
    TRAILER1=(COUNT=(M11,LENGTH=8))
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)
//SORTOUT DD DUMMY
//SYSIN    DD    *
  OPTION COPY,NULLOUT=RC4
  INCLUDE COND=(1,8,ZD,EQ,OCOUNT)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
WallaceC
Beginner


Joined: 17 Dec 2002
Posts: 22
Topics: 10

PostPosted: Thu Apr 17, 2008 5:22 am    Post subject: Reply with quote

Hi Frank,

I tried your suggestion and it worked perfectly. Thank you!

Wallace
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Apr 17, 2008 10:13 am    Post subject: Reply with quote

WallaceC,

Try this one pass DFSORT solution which will give you the desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                           
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                       
1HDR                                                 
2DTLAAAAA                                             
2DTLBBBBB                                             
2DTLCCCCC                                             
9TRL  00000003                                       
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                       
  SORT FIELDS=COPY                                   
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
         IFTHEN=(WHEN=(1,4,CH,EQ,C'9TRL'),           
        OVERLAY=(81:+2,SUB,81,8,ZD,M11,LENGTH=8))     
                                                     
  OUTFIL NULLOFL=RC4,
  INCLUDE=(1,4,CH,EQ,C'9TRL',AND,07,8,ZD,EQ,81,8,ZD)
/*

Hope this helps...

Cheers
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
WallaceC
Beginner


Joined: 17 Dec 2002
Posts: 22
Topics: 10

PostPosted: Thu Apr 17, 2008 3:54 pm    Post subject: Reply with quote

Thank you, Kolusu. It worked also.

Wallace
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group