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
 

 

Compare two records in the same ps file

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

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Dec 19, 2013 8:58 am    Post subject: Compare two records in the same ps file
Reply with quote

I've a requirement to create two output files from one single file.

Code:

ID             CODE
11111          AAAA
11111          BBBB
11111          CCCC
11111          EEEE
22222          AAAA
22222          CCCC
22222          DDDD
22222          EEEE
22222          FFFF


From the above file,
File 1 should contain:
1. Same ID with code 'AAAA' AND 'BBBB'
2. Same ID with code 'CCCC' AND 'DDDD'
2. Same ID with code 'EEEE' AND 'FFFF'

File 2 should contain all other non-matched records

output should be
File 1
Code:

ID             CODE
11111          AAAA
11111          BBBB
22222          CCCC
22222          DDDD
22222          EEEE
22222          FFFF


File 2

Code:

ID             CODE
11111          CCCC
11111          EEEE
22222          AAAA


Any help would be greatly appreciated.
Back to top
View user's profile Send private message

gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Thu Dec 19, 2013 11:58 am    Post subject:
Reply with quote

Hi,

Can there be duplicate CODEs within the same ID ?

Are the wanted CODEs consecutively in the file ?


Gerry
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Dec 19, 2013 12:02 pm    Post subject:
Reply with quote

Mr. Gcicchet

1. Yes. there may be duplicate CODE's within same ID.
2. The file is sorted by ID then CODE.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Thu Dec 19, 2013 12:41 pm    Post subject:
Reply with quote

Hi Suresh,

How many different codes do you expect?
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Dec 19, 2013 12:53 pm    Post subject:
Reply with quote

There are only 6 CODE's. They are
AAAA
BBBB
CCCC
DDDD
EEEE
FFFF
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu Dec 19, 2013 2:03 pm    Post subject: Reply to: Compare two records in the same ps file
Reply with quote

If there can be duplicate codes within the same ID, please show that in your sample input with the expected output.
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Dec 19, 2013 2:11 pm    Post subject:
Reply with quote

Hi Bill,

AAAA & BBBB is one set, so are CCCC & DDDD and EEEE & FFFF.
All the records have set should come in file 1. All others should be written to file1.

if input file contains
11111 AAAA
11111 AAAA
11111 AAAA
11111 BBBB
11111 BBBB
22222 BBBB

Then, File 1 should be
11111 AAAA
11111 AAAA
11111 BBBB
11111 BBBB

File 2 should be
11111 AAAA
22222 BBBB

Code 'AAAA' & 'BBBB' are 1 set. One ID 11111 with code 'AAAA' doesn't have its set. so it should come in file2. So is the last record.

I hope, I'm not confusing more. Thanks all for your efforts.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Thu Dec 19, 2013 2:37 pm    Post subject:
Reply with quote

What is the sort product and version you are using?
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Dec 19, 2013 2:47 pm    Post subject:
Reply with quote

Hi Pandora,

I'm using Z/OS DFSORT V1R10.

ICE201I H RECORD TYPE (October, 2010 PTF and are completely up to date on DFSORT functional PTFs )

Please let me know if anything missing or I understood your question wrongly.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Thu Dec 19, 2013 9:54 pm    Post subject:
Reply with quote

Try this

Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//INA      DD *
11111          AAAA
11111          AAAA
11111          AAAA
11111          BBBB
11111          BBBB
22222          BBBB
//INB      DD *
11111          AAAA
11111          AAAA
11111          AAAA
11111          BBBB
11111          BBBB
22222          BBBB
//SORTOUT  DD DSN=&&TEMP,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT1     DD SYSOUT=*
//OUT2     DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  JOINKEYS F1=INA,FIELDS=(28,3,A,22,2,A,1,5,A)
  JOINKEYS F2=INB,FIELDS=(28,3,A,22,2,A,1,5,A)
  JOIN UNPAIRED F1,F2
  REFORMAT FIELDS=(F1:1,30,?,F2:1,30)
* INREC IFTHEN=(WHEN=(31,1,CH,EQ,C'B'),BUILD=(1,30,C'B',/,32,30,C'B')),
*       IFTHEN=(WHEN=(31,1,CH,EQ,C'1'),BUILD=(32,30,C'I'))
  OUTFIL INCLUDE=(31,1,CH,EQ,C'B',OR,31,1,CH,EQ,C'1',
         OR,31,1,CH,EQ,C'2'),
         BUILD=(1,31,/,1:32,30,31,1)
* OUTFIL FNAMES=OUT2,INCLUDE=(31,1,CH,EQ,C'1'),BUILD=(1,30)
//*
//JNF1CNTL DD *
  INCLUDE COND=(16,4,CH,EQ,C'AAAA',OR,16,4,CH,EQ,C'CCCC',OR,
                16,4,CH,EQ,C'EEEE')
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,20,28:SEQNUM,3,ZD)),
        IFTHEN=(WHEN=(16,4,CH,EQ,C'AAAA'),BUILD=(1,20,X,C'AB',
                                        28:28,3)),
        IFTHEN=(WHEN=(16,4,CH,EQ,C'CCCC'),BUILD=(1,20,X,C'CD',
                                        28:28,3)),
        IFTHEN=(WHEN=(16,4,CH,EQ,C'EEEE'),BUILD=(1,20,X,C'EF',
                                        28:28,3))
//*
//JNF2CNTL DD *
  INCLUDE COND=(16,4,CH,EQ,C'BBBB',OR,16,4,CH,EQ,C'DDDD',OR,
                16,4,CH,EQ,C'FFFF')
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,20,28:SEQNUM,3,ZD)),
        IFTHEN=(WHEN=(16,4,CH,EQ,C'BBBB'),BUILD=(1,20,X,C'AB',
                                          28:28,3)),
        IFTHEN=(WHEN=(16,4,CH,EQ,C'DDDD'),BUILD=(1,20,X,C'CD',
                                          28:28,3)),
        IFTHEN=(WHEN=(16,4,CH,EQ,C'FFFF'),BUILD=(1,20,X,C'EF',
                                          28:28,3))
//*
//STEP0200 EXEC PGM=SORT
//SORTIN   DD DSN=&&TEMP,DISP=(MOD,PASS)
//SORTOUT DD SYSOUT=*
//OUT1       DD SYSOUT=*
//OUT2       DD SYSOUT=*
//SYSOUT  DD SYSOUT=*
//SYSIN   DD *
  OMIT COND=(1,20,CH,EQ,C' ')
  SORT FIELDS=(1,5,CH,A,16,4,CH,A,22,10,CH,A)
  SUM FIELDS=NONE
  OUTFIL FNAMES=OUT1,INCLUDE=(31,1,CH,EQ,C'B'),BUILD=(1,20)
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Fri Dec 20, 2013 12:49 am    Post subject: Reply to: Compare two records in the same ps file
Reply with quote

Pandora-box,

The data is already sorted. By splitting the data in JNFnCNTL as you do you can make use of the sort order. Use IFTHEN=(WHEN=GROUP with KEYBEGIN (H has it) to give a sequence number as the fourth key (first two keys are the original data, third is the "AB" etc, fourth the sequence number).

B match-marker gives one file, anything else gives the other file. Remember to drop the extension.

One step, no sorts.

When extending records, try to use OVERLAY where possible. If better identifies what is happening, to the next person along, and at times will be more efficient than BUILD (if it doesn't "build" as it extends the record, but OVERLAYs existing data, it will save shuffling stuff about).
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Fri Dec 20, 2013 1:12 am    Post subject: Reply to: Compare two records in the same ps file
Reply with quote

Thanks Bill will try that for my own collection

Just getting to used to speed after quiet some disappointing performances icon_biggrin.gif
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Fri Dec 20, 2013 5:58 am    Post subject:
Reply with quote

Hi Pandora-Box,

what is the result using this data ?
Code:
11111    01YES AAAA
11111    02YES AAAA
11111          AAAA
11111    01YES BBBB
11111    02YES BBBB
11111          CCCC
11111          EEEE
22222          AAAA
22222    01YES CCCC
22222          CCCC
22222          CCCC
22222    01YES DDDD
22222    02YES EEEE
22222    02YES FFFF
22222          FFFF
22222          FFFF
22222          FFFF
22222          FFFF



Using the above data, this is the result I'm getting

Code:
11111    01YES AAAA 
11111    02YES AAAA 
11111    01YES BBBB 
11111    02YES BBBB 
instead of
Code:
11111    01YES AAAA
11111    01YES BBBB
11111    02YES AAAA
11111    02YES BBBB
22222    01YES CCCC
22222    01YES DDDD
22222    02YES EEEE
22222    02YES FFFF


Gerry
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Fri Dec 20, 2013 7:23 am    Post subject:
Reply with quote

Hi All,

First of all I want to thank everyone for all your efforts.

Pandora-Box - I've single file that needs to be split-ed into 2 files.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Fri Dec 20, 2013 7:26 am    Post subject:
Reply with quote

Hi,

a different approach
Code:
//STEP0100 EXEC PGM=ICETOOL     
//TOOLMSG  DD SYSOUT=*           
//DFSMSG   DD SYSOUT=*           
//IN       DD *                 
11111    01YES AAAA             
11111    02YES AAAA             
11111          AAAA             
11111    01YES BBBB             
11111    02YES BBBB             
11111          CCCC             
11111          EEEE             
22222          AAAA             
22222    01YES CCCC             
22222          CCCC             
22222          CCCC             
22222    01YES DDDD             
22222    02YES EEEE             
22222    02YES FFFF             
22222          FFFF             
22222          FFFF             
22222          FFFF             
22222          FFFF                                         
/*                                                           
//T1       DD DSN=&&T1,DISP=(,PASS,DELETE),                 
//            UNIT=SYSDA,SPACE=(TRK,(10,5),RLSE)             
//OUT      DD SYSOUT=*                                       
//OTHER    DD SYSOUT=*                                       
//SYSOUT   DD SYSOUT=*                                       
//TOOLIN   DD *                                             
  COPY FROM(IN) TO(T1) USING(CTL1)                           
  SELECT FROM(T1) TO(OUT) ON(01,5,CH) -                     
                          ON(22,2,CH) -                     
                          ON(41,8,CH) EQUAL(2) -             
  DISCARD(OTHER)                                             
//CTL1CNTL DD *                                             
  INREC IFTHEN=(WHEN=INIT,                                   
                OVERLAY=(31:SEQNUM,8,ZD,                     
                         41:SEQNUM,8,ZD,RESTART=(16,4))),   
        IFTHEN=(WHEN=(16,4,CH,EQ,C'AAAA'),                   
                OVERLAY=(22:C'AB')),                         
        IFTHEN=(WHEN=(16,4,CH,EQ,C'BBBB'),                   
                OVERLAY=(22:C'AB')),                         
        IFTHEN=(WHEN=(16,4,CH,EQ,C'CCCC'),           
                OVERLAY=(22:C'CD')),                 
        IFTHEN=(WHEN=(16,4,CH,EQ,C'DDDD'),           
                OVERLAY=(22:C'CD')),                 
        IFTHEN=(WHEN=(16,4,CH,EQ,C'EEEE'),           
                OVERLAY=(22:C'EF')),                 
        IFTHEN=(WHEN=(16,4,CH,EQ,C'FFFF'),           
                OVERLAY=(22:C'EF'))                 
 SORT FIELDS=(1,5,BI,A,22,2,BI,A,41,8,BI,A,16,4,BI,A)
/*


Gerry
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Fri Dec 20, 2013 7:54 am    Post subject:
Reply with quote

Superb Mr.Gcicchet.

Your CTL1 card meets my requirement. Thank you so much.

I was trying with same kind of approach but didn't include the SEQNUM, which caused same ID with same CODE came in File1.

Thanks to Pandora-Box and Bill.

You guys saved my day. Greatly appreciated.
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Fri Dec 20, 2013 9:02 am    Post subject:
Reply with quote

Hi All,

A small change, May be silly yet, needs to be spotted for anyone who needed it in future.

When I use Gerry's JOB, I got proper output but with SEQNUMs in the files. So here is the JOB with small modification for output files without SEQNUMs.

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*     
//IN       DD *           
11111    01YES AAAA       
11111    02YES AAAA       
11111          AAAA       
11111    01YES BBBB       
11111    02YES BBBB       
11111          CCCC       
11111          EEEE       
22222          AAAA       
22222    01YES CCCC       
22222          CCCC       
22222          CCCC       
22222    01YES DDDD       
22222    02YES EEEE       
22222    02YES FFFF       
22222          FFFF                                     
22222          FFFF                                     
22222          FFFF                                     
22222          FFFF                                     
/*                                                       
//T1       DD DSN=&&T1,DISP=(,PASS,DELETE),             
//            UNIT=SYSDA,SPACE=(TRK,(10,5),RLSE)         
//OUT      DD SYSOUT=*                                   
//OTHER    DD SYSOUT=*                                   
//SYSOUT   DD SYSOUT=*                                   
//TOOLIN   DD *                                         
  COPY FROM(IN) TO(T1) USING(CTL1)                       
  SELECT FROM(T1) TO(OUT) ON(01,5,CH) -                 
                          ON(22,2,CH) -                 
                          ON(41,8,CH) EQUAL(2) -         
  DISCARD(OTHER) USING(CTL2)                             
//CTL1CNTL DD *                                         
  INREC IFTHEN=(WHEN=INIT,                               
                OVERLAY=(31:SEQNUM,8,ZD,                 
                         41:SEQNUM,8,ZD,RESTART=(16,4))),
        IFTHEN=(WHEN=(16,4,CH,EQ,C'AAAA'),               
                OVERLAY=(22:C'AB')),                 
        IFTHEN=(WHEN=(16,4,CH,EQ,C'BBBB'),           
                OVERLAY=(22:C'AB')),                 
        IFTHEN=(WHEN=(16,4,CH,EQ,C'CCCC'),           
                OVERLAY=(22:C'CD')),                 
        IFTHEN=(WHEN=(16,4,CH,EQ,C'DDDD'),           
                OVERLAY=(22:C'CD')),                 
        IFTHEN=(WHEN=(16,4,CH,EQ,C'EEEE'),           
                OVERLAY=(22:C'EF')),                 
        IFTHEN=(WHEN=(16,4,CH,EQ,C'FFFF'),           
                OVERLAY=(22:C'EF'))                 
 SORT FIELDS=(1,5,BI,A,22,2,BI,A,41,8,BI,A,16,4,BI,A)
//CTL2CNTL DD *                                     
  OUTFIL FNAMES=OUT,BUILD=(1,19) 
  OUTFIL FNAMES=OTHER,BUILD=(1,19)                             
/*                                                   


Thanks once again Guys.
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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
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


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