Comparing records in same file



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Comparing records in same file

Postby Arunz » Tue Jun 16, 2015 7:08 pm

Hi,

I am new resource of mainframe. I am having a requirement as follows. Please help me out.

Filein:

0001 76
0001 76
0001 77
0001 40
0002 77
0002 76
0003 78
0003 79
0003 89

Required output is:

0001 76
0001 76
0002 76
0003 78
0003 79
0003 89

requirement is:
We need to match the columns on 1 to 4. based on this when columns 06,02,EQ,C'76' we need to write output only the records having 76. we need to omit all other rows not having 76. If there are no records having 76 we need to write all the records including the duplicates.

Thanks in advance...
Arunz
 
Posts: 6
Joined: Tue Jun 16, 2015 6:56 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Comparing records in same file

Postby Magesh23586 » Wed Jun 17, 2015 8:03 pm

Here is the code for you, Used same inputs in INA and INB, If you are using dataset/File, then give same datset/file name for INA and INB.

//S1   EXEC  PGM=SORT     
//SYSOUT DD SYSOUT=*       
//INA DD *                 
0001 76                   
0001 76                   
0001 77                   
0001 40                   
0002 77                   
0002 76                   
0003 78                   
0003 79                   
0003 89                   
//INB DD *                 
0001 76                   
0001 76                   
0001 77                   
0001 40                   
0002 77                   
0002 76                   
0003 78                   
0003 79                   
0003 89                                                     
//SORTOUT DD SYSOUT=*                                       
//SYSIN    DD *                                             
  OPTION COPY                                               
  JOINKEYS F1=INA,FIELDS=(1,4,A)                             
  JOINKEYS F2=INB,FIELDS=(1,4,A)                             
  REFORMAT FIELDS=(F1:1,9,?)                                 
  JOIN UNPAIRED,F1                                           
  OUTFIL INCLUDE=((10,1,CH,EQ,C'B',AND,6,2,CH,EQ,C'76'),OR, 
                  (10,1,CH,EQ,C'1'))                         
//*                                                         
//JNF2CNTL DD *                                             
  INCLUDE COND=(06,02,CH,EQ,C'76')                           
  SUM FIELDS=NONE                                           
//*                                                         


Regards,
Magesh
Magesh23586
 
Posts: 36
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Comparing records in same file

Postby BillyBoyo » Wed Jun 17, 2015 10:26 pm

Maghesh,

The data looks to be in order, but you are sorting the file, twice. OK, you are using SUM on one, but why SORT the other?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Comparing records in same file

Postby Magesh23586 » Thu Jun 18, 2015 2:33 pm

Yes, your are right, we need not require sort for File 1.

Please update the below code.

  JOINKEYS F1=INA,FIELDS=(1,4,A),SORTED,NOSEQCK
Magesh23586
 
Posts: 36
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Comparing records in same file

Postby Arunz » Tue Jun 23, 2015 3:35 pm

Hi Maghesh,

Sorry for the late reply. Thanks for your code. But here you are comparing two files. But I am having only one file...
Arunz
 
Posts: 6
Joined: Tue Jun 16, 2015 6:56 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Comparing records in same file

Postby enrico-sorichetti » Tue Jun 23, 2015 4:04 pm

Used same inputs in INA and INB,


join keys needs two files,
the trick is to use the same/only file for both
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

These users thanked the author enrico-sorichetti for the post:
Arunz (Tue Jun 23, 2015 4:43 pm)
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Comparing records in same file

Postby Arunz » Tue Jun 23, 2015 4:45 pm

Got It... Worked as Expected... Thank you so much Maghesh and Enrico :) :)
Arunz
 
Posts: 6
Joined: Tue Jun 16, 2015 6:56 pm
Has thanked: 1 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post