Iam struck in a production issue
Following is my requirement..
I have data as follows(no,of I/P records.12)
-------------------
99999XXXX0000
99999XXXX0000
99999XXXX0001
99999XXXX0001
99999XXXX0002
99999XXXX0002
99999XXXX0003
99999XXXX0003
99999XXXX0003
99999XXXX0004
99999XXXX0004
99999XXXX0004
-------------------
after JCL Sort it should look like.(no,of O/P records.9)
-------------------
99999XXXX0000
99999XXXX0001
99999XXXX0002
99999XXXX0003
99999XXXX0003
99999XXXX0003
99999XXXX0004
99999XXXX0004
99999XXXX0004
-------------------
I will be very much thankfull if any one can provide a
SELCOPY/JCL SORT example to solve the above issue.......
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You haven't given enough information for anyone to provide a solution.
The only pattern I see is that you're removing duplicates for the 0000, 0001 and 0002 records, but keeping duplicates for the 0003 and 0004 records. Is that the "rule" you want to use to get from input to output or is it something else? If it's something else, what is it?
Is the "key" all of the bytes or just some of the bytes?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Here's a DFSORT job that will do what you asked for. It wasn't clear to me what your key was (it would have helped if you'd just given the starting position and length of the key or keys), so I assumed i was just the 4-byte number in positions 14-17. You can change the job appropriately for other keys.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB)
//SORTOUT DD DSN=... output file (VB)
//SYSIN DD *
* Reformat 0003 and 0004 records to:
* |RDW|seqnum..|data|nnnn|
INREC IFTHEN=(WHEN=(14,4,ZD,GT,+2),
BUILD=(1,4,5:SEQNUM,8,ZD,13:5)),
* Reformat 0001, 0002 and 0003 records to:
* |RDW|00000000|data|nnnn|
IFTHEN=(WHEN=NONE,
BUILD=(1,4,5:C'00000000',13:5))
OPTION EQUALS
* Sort on seqnum and nnnn.
SORT FIELDS=(5,8,ZD,A,22,4,ZD,A)
* Remove duplicates:
* For 0003 and 0004 records, each record has a different
* seqnum so dups are not removed. For 0001, 0002 and 0003
* records, each record has a seqnum of 00000000, so dups
* are removed.
SUM FIELDS=NONE
* Remove seqnum.
OUTREC BUILD=(1,4,5:13)
/*
Hi,
I think we can use SORT FIELDS= NONE, to elimanate the duplicate records, then after we should use SKIP REC. i.e where we need to ignore the NONE condition.
I guess it will works.