Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to remove duplicate fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Durgesh Kumar

New User


Joined: 19 Jun 2012
Posts: 2
Location: India

PostPosted: Wed Jun 27, 2012 8:41 pm    Post subject: How to remove duplicate fields
Reply with quote

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
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Jun 27, 2012 8:50 pm    Post subject:
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Wed Jun 27, 2012 8:59 pm    Post subject:
Reply with quote

Your SORT FIELDS statement will change the order.
I think, ICETOOL SELECT with FIRST operand will help you in this situation.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Jun 27, 2012 9:12 pm    Post subject: Reply to: How to remove duplicate fields
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Wed Jun 27, 2012 9:39 pm    Post subject:
Reply with quote

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. icon_smile.gif
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Thu Jun 28, 2012 12:29 am    Post subject:
Reply with quote

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 icon_smile.gif
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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Thu Jun 28, 2012 12:46 am    Post subject: Reply to: How to remove duplicate fields
Reply with quote

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
View user's profile Send private message
Durgesh Kumar

New User


Joined: 19 Jun 2012
Posts: 2
Location: India

PostPosted: Thu Jun 28, 2012 8:13 pm    Post subject: Reply to: How to remove duplicate fields
Reply with quote

Thank you all
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Remove Special Characters from Mainfr... Rodger Zhang All Other Mainframe Topics 6 Wed Jul 06, 2016 1:12 am
No new posts Need Help to Define 36 Input Fields (... satish.ms10 CLIST & REXX 2 Sat May 07, 2016 3:08 pm
No new posts FileAid to compare(logical operations... anand1204 Compuware & Other Tools 3 Wed Apr 06, 2016 2:55 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us