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
 

 

Selective retention of duplicate records in file

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

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Mon Nov 14, 2011 11:11 am    Post subject: Selective retention of duplicate records in file
Reply with quote

Hello Team,

I have an input file with 4 fields (FB 80). The first field (pos 1-4) is the key on which I am doing the comparison. The third field (pos 10) can have values Y/N.

Code:
 SRK1 AK1 Y XYZ
 SRK1 AK2 N DFG
 SRK1 AK3 N ERT
 SRK2 AK4 N GTY
 SRK2 AK5 N JKU
 SRK3 AK6 Y JKL
 SRK4 AK7 N POI
 SRK4 AK8 Y QWE
 SRK5 AK9 N QST


If for a key, we have a record with Y in the third column, all other records for the key need to be removed (only one record will be present with Y for any key in the input file). If for a key only N records are present, then all duplicates should be retained. Currently, I am splitting this file into 2, one with all Y recs and the other with N and then using an easytrieve to get my final result. The final file looks like this.

Code:
SRK1 AK1 Y XYZ
SRK2 AK4 N GTY
SRK2 AK5 N JKU
SRK3 AK6 Y JKL
SRK4 AK8 Y QWE
SRK5 AK9 N QST


Is it possible to do this in a single step using SORT? Thanks for your inputs.
Back to top
View user's profile Send private message

sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Mon Nov 14, 2011 8:19 pm    Post subject:
Reply with quote

remoonline,
See if below works...

Code:
//STEP0001 EXEC PGM=SORT                                               
//SORTIN   DD  *                                                       
SRK1 AK1 Y XYZ                                                         
SRK1 AK2 N DFG                                                         
SRK1 AK3 N ERT                                                         
SRK2 AK4 N GTY                                                         
SRK2 AK5 N JKU                                                         
SRK3 AK6 Y JKL                                                         
SRK4 AK7 N POI                                                         
SRK4 AK8 Y QWE                                                         
SRK5 AK9 N QST                                                         
//SORTOUT  DD  SYSOUT=*                                                 
//SYSIN DD *                                                           
 SORT FIELDS=(1,4,CH,A,10,1,CH,D),EQUALS                               
 OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,4),PUSH=(10:10,1,81:SEQ=8))     
 OUTFIL INCLUDE=((10,1,CH,EQ,C'N'),OR,                                 
                 (10,1,CH,EQ,C'Y',AND,81,8,ZD,EQ,1)),BUILD=(1,80)       
/*                                                                     
//SYSOUT DD SYSOUT=*                                                   

OUTPUT
Code:
SRK1 AK1 Y XYZ 
SRK2 AK4 N GTY 
SRK2 AK5 N JKU 
SRK3 AK6 Y JKL 
SRK4 AK8 Y QWE 
SRK5 AK9 N QST 

Thanks,
Back to top
View user's profile Send private message
remoonline

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Tue Nov 15, 2011 7:28 pm    Post subject:
Reply with quote

Thank you sqlcode1 for the response. Unfortunately, the version here doesn't support WHEN=GROUP. Is there any alternative way to achieve this?
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Tue Nov 15, 2011 8:35 pm    Post subject:
Reply with quote

remoonline wrote:
Thank you sqlcode1 for the response. Unfortunately, the version here doesn't support WHEN=GROUP. Is there any alternative way to achieve this?

Very unlikely unless you are on a very old version of DFSort. I am guessing you probably got an error for KEYBEGIN.

Please post your sysout message.

Thanks,
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Tue Nov 15, 2011 11:35 pm    Post subject:
Reply with quote

Hello,

Quote:
Unfortunately, the version here doesn't support WHEN=GROUP


Check here:

http://ibmmainframes.com/about54778.html
Back to top
View user's profile Send private message
remoonline

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Wed Nov 16, 2011 2:29 pm    Post subject:
Reply with quote

We have a 2007 version which doesn't support either of WHEN=GROUP or KEYBEGIN.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Nov 17, 2011 12:14 am    Post subject:
Reply with quote

Ask your System Programmer to upgrade to a current release of DFSORT.
Back to top
View user's profile Send private message
remoonline

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Thu Nov 17, 2011 11:55 am    Post subject:
Reply with quote

I have passed on this feedback sometime back. But not sure of it being done anytime soon. It may happen during the next license renewal.

So, is it not possible to achive this without using the group function?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Nov 18, 2011 3:40 am    Post subject:
Reply with quote

It's difficult to come up with a job that will work for you when we don't know which functions you can use and which you can't. You say you don't have WHEN=GROUP, but we don't even know if you have IFTHEN, OVERLAY, etc. I guess as a start, we should determine your exact level of DFSORT. Run this job and show your //SYSOUT messages:

Code:

//S1    EXEC  PGM=SORT               
//SYSOUT    DD  SYSOUT=*             
//SORTIN DD *                       
RECORD                               
//SORTOUT DD DUMMY                   
//SYSIN    DD    *                   
    OPTION COPY                     
/*                                   
Back to top
View user's profile Send private message
remoonline

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Sat Nov 19, 2011 12:14 pm    Post subject:
Reply with quote

Thank you Frank for the response. The current version supports IFTHEN clause and the OVERLAY sub-parameter. WHEN=INIT, WHEN=(logical expression) and WHEN=NONE work without any issues.
Back to top
View user's profile Send private message
kratos86

Active User


Joined: 17 Mar 2008
Posts: 148
Location: Anna NGR

PostPosted: Sat Nov 19, 2011 1:33 pm    Post subject:
Reply with quote

As Frank suggested run the job and show your sysout messages. It will save our time and give us an idea about what other features will not work in DFSORT level you are using.
Back to top
View user's profile Send private message
remoonline

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Thu Dec 01, 2011 11:01 am    Post subject:
Reply with quote

Our installation has function level corresponding to z/OS DFSORT V1R5 PTF UK90007.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Dec 02, 2011 12:57 am    Post subject:
Reply with quote

That's really old!!

I think this DFSORT/ICETOOL job will work at that level, but I can't test it, so you'll have to try it out:

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)
SPLICE FROM(T1) TO(OUT) ON(1,4,CH) WITHALL KEEPBASE KEEPNODUPS -
  WITH(1,9) WITH(11,78) USING(CTL2)
/*
//CTL1CNTL DD *
  SORT FIELDS=(1,4,CH,A,10,1,CH,D),EQUALS
  OUTREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,4))
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=OUT,
    INCLUDE=((10,1,CH,EQ,C'N'),OR,
             (10,1,CH,EQ,C'Y',AND,81,8,ZD,EQ,1)),
    BUILD=(1,80)
/*
Back to top
View user's profile Send private message
remoonline

New User


Joined: 17 Nov 2006
Posts: 11
Location: Bangalore

PostPosted: Fri Dec 02, 2011 7:32 pm    Post subject:
Reply with quote

It works like a charm. Thank you Frank.
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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