Mixed dups.
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Utilities

#1: Mixed dups. Author: ramy2016 PostPosted: Fri Dec 20, 2024 12:12 pm
    —
Good day everyone and Happy Holiday Season!

Could someone, please, let me know how to accomplish the following with DFSORT step (SORT or ICETOOL).

I have a dataset, FB LRECL=80, where there could be duplicate Account-No records accompanied by Account-Class values.
There could be three types of duplicates:
- duplicate Account-No recs within Account-Class '9'
- duplicate Account-No recs between Account-Class '9' and Account-Class '5'
- duplicate Account-No recs within Account-Class '9' AND a record from Account-Class '5'
- there could never be duplicate Account-No recs within Account-Class '5'.

All duplicates within Account-Class '9' should go to an Output. Also recs of Account-Class '9' take precedence over Class '5', so if there are duplicate Accounts from both Classes, only Account-Class '9' should make it to the Output.
And non-dups from Account-Class '5' should also be in the Output.

Input records could be sorted in any order, as needed.

Input.
Code:
----+----1----+----2----+----3----+----4----+----5----+----6
              111111111111        5           
              222222222222        9           
              222222222222        9           
              333333333333        5           
              333333333333        9           
              444444444444        5           
              444444444444        9           
              444444444444        9
              444444444444        9
              555555555555        9     
              666666666666        5     


Output.
Code:
----+----1----+----2----+----3----+----4----+----5----+----6
              111111111111        5           
              222222222222        9           
              222222222222        9           
              333333333333        9           
              444444444444        9           
              444444444444        9
              444444444444        9
              555555555555        9     
              666666666666        5     


Thanks.

#2:  Author: kolusuLocation: San Jose PostPosted: Fri Dec 20, 2024 5:29 pm
    —
ramy2016,

You need to use the trick of joinkeys matching the file to it self. The second file will count the number of duplicates and upon matching every record has the counter. Now we can just eliminate the records with dup count > 1 and class of '5' on OUTFIL

Here is an untested DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//INA      DD *                                                     
              111111111111        5                                 
              222222222222        9                                 
              222222222222        9                                 
              333333333333        5                                 
              333333333333        9                                 
              444444444444        5                                 
              444444444444        9                                 
              444444444444        9                                 
              444444444444        9                                 
              555555555555        9                                 
              666666666666        5                                 
//INB      DD *                                                     
              111111111111        5                                 
              222222222222        9                                 
              222222222222        9                                 
              333333333333        5                                 
              333333333333        9                                 
              444444444444        5                                 
              444444444444        9                                 
              444444444444        9                                 
              444444444444        9                                 
              555555555555        9                                 
              666666666666        5                                 
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  JOINKEYS F1=INA,FIELDS=(15,11,A)         # KEY                     
  JOINKEYS F2=INB,FIELDS=(01,11,A)         # KEY                     
  REFORMAT FIELDS=(F1:01,80,               # 80 BYTE RECORD         
                   F2:12,08)               # SUM COUNTER             
                                                                     
  OUTFIL BUILD=(01,80),                    # BUILD ONLY 80 BYTES     
  OMIT=(81,8,ZD,GT,1,AND,                  # OMIT DUP COUNTER > 1   
        35,1,CH,EQ,C'5')                   # CLASS '5'               
/*                                                                   
//JNF2CNTL DD *                                               
  INREC BUILD=(15,11,                      # KEY             
               C'00000001')                # COUNTER OF 1     
                                                             
   SUM FIELDS=(12,08,ZD)                   # SUM THE COUNTER 
/*                                                           



MVSFORUMS.com -> Utilities


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group