Remove Duplicates and rewrite file unsorted

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
maing
Member
Posts: 3
Joined: Thu Nov 09, 2006 5:18 pm

Remove Duplicates and rewrite file unsorted

Post by maing » Thu Nov 09, 2006 5:33 pm

Hi,

I have a file that I need to remove duplicates from. When the duplicates are removed, I need an output file that is unsorted - that is, it hasn't changed the order of the original file - that I'm getting the original file minus the duplicates.

Is this possible? Any ideas would be great! :o

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Nov 09, 2006 6:07 pm

use two sorts.

SORT 1:
  • add 6 char to length of output file
  • put seqno in new 6 char
  • SORT file based on keys that will identify dups
  • use drop dups
SORT 2:
  • SORT key is seqno added by first sort
  • use original record length (input to SORT 1) as length of OUTPUT, thus truncating the seqno added by SORT 1.
output of SORT 2 is a copy of your original minus the dups.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

maing
Member
Posts: 3
Joined: Thu Nov 09, 2006 5:18 pm

Post by maing » Thu Nov 09, 2006 6:24 pm

Thanks!

It kinda does do it - it gives me the orignal file minus the duplicates but the file is sorted - I need the file in it's original order. I don't want the file sorted sequentially. Is there something I can add to the first sorting? :o

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Nov 09, 2006 6:28 pm

The seqno added (appended) to the output record needs to be added in the input phase of the sort, not the output phase, that way the seqno represents the original order.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

maing
Member
Posts: 3
Joined: Thu Nov 09, 2006 5:18 pm

Post by maing » Thu Nov 09, 2006 6:45 pm

Excellent! That has worked a treat!

Thank you.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others