Page 1 of 1

Count and remove duplicate trailer record.

PostPosted: Tue Dec 16, 2014 10:22 pm
by ragsara
Hi ,

Requirement : Check if the file has duplicate trailer record, remove if present.

Length of file : FB 100
Trailer record is identified by record type ' 002'

Input File :
ABC 001 December162014
ABC 100 MATHS
ABC 200 SCIENCE
ABC 300 PHYSICS
ABC 002 003
ABC 002 004


Output file :
ABC 001 December162014
ABC 100 MATHS
ABC 200 SCIENCE
ABC 300 PHYSICS
ABC 002 003


Initially i have planned to use COUNT, IFTHEN and REMOVE function. Am yet to code, before which i want to check if we have better way to resolve this issue.

Re: Count and remove duplicate trailer record.

PostPosted: Tue Dec 16, 2014 11:07 pm
by BillyBoyo
Use INREC IFTHEN=(WHEN=(logical expression) to test for your trailer and extend the record by a sequence number (make sure it is long enough to cover as many duplicates as you may have(!).

Use OUTFIL OMIT= to remove records with a sequence number greater than C'1' (with leading zeros to the length you have chosen) and BUILD to return your record to the original size.

COUNT is from TRAILERn processing, REMOVE is from ICETOOL's SUBSET operator and IFTHEN is for processing inputs records to INREC, OUTREC and OUTFIL. Just because you feel they have likely-looking names doesn't mean that you can apply them how you want.

Re: Count and remove duplicate trailer record.

PostPosted: Wed Dec 17, 2014 4:16 pm
by Thampy
The OUTFIL IFTRAIL option can also can be used to remove the duplicate trailer record as shown below

 SORT FIELDS=COPY                                                   
 OUTFIL IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'ABC 002'),               
        TRLUPD=(9:COUNT=(M11,LENGTH=3)))