|
View previous topic :: View next topic
|
| Author |
Message |
Durgesh Kumar
New User
Joined: 19 Jun 2012 Posts: 2 Location: India
|
|
|
|
Hi,
I want to remove duplicate fields at position 7 having length 9 without changing the order of file.
I have used
sort fields(7,9,ch,a)
sum fields=none
but it was change the order in ascending form. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Assuming your file is of 80 bytes
| Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=output file (FB/80)
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD)
SORT FIELDS=(7,9,CH,A)
SUM FIELDS=NONE
/*
//CTL2CNTL DD *
SORT FIELDS=(81,8,ZD,A)
OUTREC BUILD=(1,80)
/* |
|
|
| Back to top |
|
 |
agkshirsagar
Active Member

Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
| Quote: |
| Your SORT FIELDS statement will change the order. |
did You try to understand the logic behind the proposed solution ?
apply a sequence number to the input records,
sort on the <proper> key getting rid of the duplicates
sort on the sequence number to reproduce the original sequence.
I did not check the SORT/ICETOOL statements syntax, but the approach is the right one! |
|
| Back to top |
|
 |
agkshirsagar
Active Member

Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Enrico,
In my defense, my response was to OP. I hadn't seen Pandora's solution when I posted my response.
I must not have refreshed the page before I posted my response, and that's what caused the confusion..
Pandora-Box,
I did like your approach.. My apologies if I offended you in some way.  |
|
| Back to top |
|
 |
agkshirsagar
Active Member

Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
If anyone is still interested, here is a solution using SELECT. It uses the same approach used by Pandora-Box.. but with less clutter..no offense
Assumption - Input file record length = 80.
Remember to account for sequence number in TEMP01 record length.
| Code: |
//CTL1CNTL DD *
INREC BUILD=(1,80,SEQNUM,10,ZD)
/*
//CTL2CNTL DD *
SORT FIELDS=(81,10,ZD,A)
/*
//TOOLIN DD *
SELECT FROM(DD01) TO(TEMP01) ON(7,9,CH) FIRST USING(CTL1)
SORT FROM(TEMP01) TO(DD02) USING(CTL2)
/*
// |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Why not just do the SELECT? If the SELECT sorts (I have a slow connection at the moment, so can't check the manual) could try, carefully, with SORT FIELDS=COPY in the CNTL file.
However, maybe TS wants the file sorted to bring all possible duplicates together, then put the file back in order - in which case two sorts would be necessary. |
|
| Back to top |
|
 |
Durgesh Kumar
New User
Joined: 19 Jun 2012 Posts: 2 Location: India
|
|
|
|
| Thank you all |
|
| Back to top |
|
 |
|
|