Compare Record Count with a Trailer Count



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Compare Record Count with a Trailer Count

Postby jois » Tue Jul 22, 2014 4:37 pm

Hi,
Can somebody help me here ?
I have an Input FIle with a Trailer Record containing an Expected Record COunt Field.
Then I have to write the records of the input file into the Output FIle minus the Trailer Record.
I have to compare the total record count of the Input File (minus the Trailer Record) against the Count given in the trailer record.
If found different , I have to create a LOG-FILE containing an error display.

Jois
jois
 
Posts: 5
Joined: Tue Jul 22, 2014 4:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Compare Record Count with a Trailer Count

 

Re: Compare Record Count with a Trailer Count

Postby Magesh23586 » Wed Jul 23, 2014 12:55 pm

Show us the sample input, expected output and the code which you tried.

Thanks
Magesh
Magesh23586
 
Posts: 35
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Compare Record Count with a Trailer Count

Postby jois » Wed Jul 23, 2014 7:21 pm

In the below file of recl 60, FB, 15th line reads the trailer count.
Col 1-4, value is 9999
Col 6-14, record count
Col 16-20 Program Name

2T04 437492900 20071210200911300086 15
5T04 4374929003606 NC 0100 04256489999991
7T04 4374929003606 NC 01000152S000003
7T04 4374929003606 NC 01000165S000001
7T04 4374929003606 NC 01002600S000001
7T04 4374929003606 NC 01002972S000003
7T04 4374929003606 NC 01003777S000002
7T04 4374929003606 NC 01003955S000003
7T04 4374929003606 NC 01004048S000002
7T04 4374929003606 NC 01004129S000002
7T04 4374929003606 NC 01005186S000003
7T04 4374929003606 NC 01005458S000003
7T04 4374929003606 NC 01006952S000002
7T04 4374929003606 NC 01007362S000003
9999 000000012 CC705

1. I need to compare the Record count (from Trailer Rec) against the number of records From the input file.
2. If difference is 0, RC=0, LOG-FILE is not generated
3. otherwise, RC=4. LOG-FILE is generated
4. Difference should be save the as I need to put it in the LOG-FILE
5. LOG-FILE contains 3 records.
1st Record contains 'LOG FILE ERROR' statement
2nd Record contains the Program name taken from Trailer Rec
3rd Record contains the mismatch Difference as computed by Sort Utility
E.g.
'LOG FILE ERROR'
'PROGRAM CC705 CONTAINS MISMATCH TRAILER COUNT'
'TRAILER RECORD COUNT MISMATCH , DIFFERENCE IS NNNNNNNNN'
jois
 
Posts: 5
Joined: Tue Jul 22, 2014 4:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Compare Record Count with a Trailer Count

Postby Magesh23586 » Thu Jul 24, 2014 1:05 pm

Here is the code for you..
//CPYJK EXEC PGM=SORT
//SYSOUT DD SYSOUT=*                       
//SORTIN DD *                             
2T04 437492900 20071210200911300086 15     
5T04 4374929003606 NC 0100 04256489999991 
7T04 4374929003606 NC 01000152S000003     
7T04 4374929003606 NC 01000165S000001     
7T04 4374929003606 NC 01002600S000001     
7T04 4374929003606 NC 01002972S000003     
7T04 4374929003606 NC 01003777S000002     
7T04 4374929003606 NC 01003955S000003     
7T04 4374929003606 NC 01004048S000002     
7T04 4374929003606 NC 01004129S000002     
7T04 4374929003606 NC 01005186S000003     
7T04 4374929003606 NC 01005458S000003     
7T04 4374929003606 NC 01006952S000002     
7T04 4374929003606 NC 01007362S000003     
9999 000000012 CC705                       
/*                                         
//SORTOUT DD DUMMY
//OUT1 DD SYSOUT=*                         
//SYSIN    DD *                           
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,9,ZD)),                   
        IFTHEN=(WHEN=(1,4,CH,EQ,C'9999'),                             
        OVERLAY=(81:+1,SUB,81,9,ZD,M11,LENGTH=9))                     
  OUTFIL NULLOFL=RC4,                                                 
         INCLUDE=(1,4,CH,EQ,C'9999',AND,06,9,ZD,EQ,81,9,ZD)           
  OUTFIL FNAMES=OUT1,                                                 
         IFTHEN=(WHEN=(1,4,CH,EQ,C'9999',AND,06,9,ZD,NE,81,9,ZD),     
         BUILD=(1:C'LOG FILE ERROR',/,                                 
               C'PROGRAM CC705 CONTAINS MISMATCH',/,                   
               C'DIFFERENCE IS ',(06,9,ZD,SUB,81,9,ZD),               
                   EDIT=(STTTTTTTTT),SIGNS=(,))),                     
         INCLUDE=(1,4,CH,EQ,C'9999',AND,06,9,ZD,NE,81,9,ZD)           

Hope this helps...
Thanks
Magesh
Magesh23586
 
Posts: 35
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Compare Record Count with a Trailer Count

Postby Magesh23586 » Thu Jul 24, 2014 1:09 pm

Jios,

Please start reading DFSORT getting started, good material to start, which has lot of examples.

Regards,
Magesh
Magesh23586
 
Posts: 35
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Compare Record Count with a Trailer Count

Postby jois » Thu Jul 24, 2014 1:52 pm

Thanks Magesh for the SORT JCL, it really helped me for a good start. I knew only bits and pieces of DFSORT features and functionality.
By the way, I need to output the Input File (minnus Trailer Rec) into an Output-FIle, as well as the LOG-FILE. I commented out the SORTOUT DUMMY and the OUT1 SYSOUT=* :
//*SORTOUT DD DUMMY
//*OUT1 DD SYSOUT=*
//SORTOUT DD DSN=ACCT1.X188939.SORTOUT.SORTC,
// DISP=(NEW,CATLG,DELETE),
// UNIT=DASD,
// SPACE=(CYL,(5,5),RLSE),
// DCB=(RECFM=FB,LRECL=60),
// LABEL=RETPD=50
//OUT1 DD DSN=ACCT1.X188939.OUT1.SORTC,
// DISP=(NEW,CATLG,DELETE),
// UNIT=DASD,
// SPACE=(CYL,(5,5),RLSE),
// DCB=(RECFM=FB,LRECL=60),
// LABEL=RETPD=50

However, it gave me an Error, '-OUT1 HAS INCOMPATIBLE LRECL' and the SORTOUT FIle contains an empty record.
Can you tell me what's wrong with it ?
Thanks in advance.
Jois
jois
 
Posts: 5
Joined: Tue Jul 22, 2014 4:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Compare Record Count with a Trailer Count

Postby BillyBoyo » Thu Jul 24, 2014 2:25 pm

The SORTOUT is DUMMY for a reason. That OUTFIL (the one with no name) is being used to get an RC from the step when the counts are different.

I would suggest naming it to be clearer. I use CHKOUT, but you can come up with something else if you like. Include that in your JCL, as DUMMY, and name it on OUTFIL.

The reason you are getting the message is because you have specified RECFM and LRECL in the JCL. You can let SORT do that. If you want fixed-length output, you can ensure that column 60 contains a space, 60:X, and any data positions which have not been set will be automatically set to blank.

If you include SORTOUT (again don't code the RECFM and LRECL) you should get data on it, if the step does not fail.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Compare Record Count with a Trailer Count

Postby jois » Thu Jul 24, 2014 2:50 pm

Hi Magesh,
I already solved it . Pls. see below.
You're really an ANGEL, thanks a bunch!!!

Hi BillyBoyo,
Your suggestions, really helped.. Thanks so much.

/*
//SORTOUT DD DUMMY
//OUT1 DD DSN=ACCT1.XXXXXXX.OUT1.SORTC,
// UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(MOD,CATLG,DELETE)
//OUT2 DD DSN=ACCT1.XXXXXXX.OUT2.SORTC,
// UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(MOD,CATLG,DELETE)
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,9,ZD)),
IFTHEN=(WHEN=(1,4,CH,EQ,C'9999'),
OVERLAY=(81:+1,SUB,81,9,ZD,M11,LENGTH=9))
OUTFIL NULLOFL=RC4,
INCLUDE=(1,4,CH,EQ,C'9999',AND,06,9,ZD,EQ,81,9,ZD)
OUTFIL FNAMES=OUT1,
IFTHEN=(WHEN=(1,4,CH,EQ,C'9999',AND,06,9,ZD,NE,81,9,ZD),
BUILD=(1:C'LOG FILE ERROR',/,
C'PROGRAM CC705 CONTAINS MISMATCH',/,
C'DIFFERENCE IS ',(06,9,ZD,SUB,81,9,ZD),
EDIT=(STTTTTTTTT),SIGNS=(,))),
INCLUDE=(1,4,CH,EQ,C'9999',AND,06,9,ZD,NE,81,9,ZD)
OUTFIL FNAMES=OUT2,
BUILD=(1:1,60),
INCLUDE=(1,4,CH,NE,C'9999')
/*
jois
 
Posts: 5
Joined: Tue Jul 22, 2014 4:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Compare Record Count with a Trailer Count

Postby Magesh23586 » Thu Jul 24, 2014 6:28 pm

Thanks for letting us know, Please learn to use ['code'] tags when your are providing a code , You can find this button above your inputbox or text box.

Regards,
Magesh
Magesh23586
 
Posts: 35
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Compare Record Count with a Trailer Count

Postby jois » Fri Jul 25, 2014 5:32 pm

Thanks again. I don't know how to use the <code>. But will try it next time.
It really helped joining this Forum.
Everybody is helpful .
jois
 
Posts: 5
Joined: Tue Jul 22, 2014 4:27 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post