IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Selective retention of duplicate records in file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 577
Location: USA

PostPosted: Mon Nov 14, 2011 8:19 pm
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
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: 577
Location: USA

PostPosted: Tue Nov 15, 2011 8:35 pm
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
Reply with quote

Hello,

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


Check here:

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
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 Developer


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

PostPosted: Thu Nov 17, 2011 12:14 am
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
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 Developer


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

PostPosted: Fri Nov 18, 2011 3:40 am
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
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
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
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 Developer


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

PostPosted: Fri Dec 02, 2011 12:57 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top