Count and remove duplicate trailer record.



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

Count and remove duplicate trailer record.

Postby ragsara » Tue Dec 16, 2014 10:22 pm

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.
ragsara
 
Posts: 23
Joined: Thu Mar 22, 2012 5:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Count and remove duplicate trailer record.

Postby BillyBoyo » Tue Dec 16, 2014 11:07 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Count and remove duplicate trailer record.

Postby Thampy » Wed Dec 17, 2014 4:16 pm

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)))                           
Thampy
 
Posts: 36
Joined: Sat Sep 26, 2009 2:27 pm
Has thanked: 0 time
Been thanked: 3 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post