MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to eliminate duplicates if input looks like this...

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Jun 30, 2004 8:31 am    Post subject: How to eliminate duplicates if input looks like this... Reply with quote

Hi All,
I need a small help on DFSORT.

My input file looks like this.
Code:

a1  b1 c1      a2  b2  c2       a3  b3  c3      a4  b4  c4   
 
1   a   2       1   a   2        8   f   7       8   f   7       
3   b   4       3   b   4        6   g   9       6   g   9       
5   c   6       5   c   6        4   h   3       4   h   3       
7   d   8       7   d   8        2   i   5       2   i   5       


I want the output in this form shown below.

i.e. it has to compare a1 with a2, b1 with b2, c1 with c2 for each row and if they are same it needs to put spaces for in a2, b2, c2 for all rows.
Similarly it has to compare a3 with a4, b3 with b4, c3 with c4 for each row and if they are same it needs to put spaces for in a4, b4, c4 for all rows.

Code:

a1 b1 c1      a2 b2 c2      a3   b3  c3       a4 b4 c4   
 
1   a   2                    8    f   7       
3   b   4                    6    g   9       
5   c   6                    4    h   3       
7   d   8                    2    i   5
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12382
Topics: 75
Location: San Jose

PostPosted: Wed Jun 30, 2004 9:06 am    Post subject: Reply with quote

vkPhani,

Try this job.

Code:

//STEP0100 EXEC PGM=SORT                           
//SYSOUT    DD SYSOUT=*                             
//SORTIN    DD *                                   
----+----1----+----2----+----3----+----4----+----5--
1  A  2  1  A  2  8  F  7  8  F  7                 
3  B  4  3  B  4  6  G  9  6  G  9                 
5  C  6  5  C  6  4  H  3  4  H  3                 
7  D  8  7  D  8  2  I  5  2  I  5                 
//SORTOUT   DD SYSOUT=*                             
//SYSIN     DD   *                                 
 SORT  FIELDS=COPY                                 
 INCLUDE COND=(01,1,CH,EQ,10,1,CH,AND,             
               04,1,CH,EQ,13,1,CH,AND,             
               07,1,CH,EQ,16,1,CH,AND,             
               19,1,CH,EQ,28,1,CH,AND,             
               22,1,CH,EQ,31,1,CH,AND,             
               25,1,CH,EQ,34,1,CH)                 
 OUTREC FIELDS=(1,9,     $ FIRST 9 BYTES AS IS       
                X,      $ SPACE OUT A2             
                11,2,   $ NEXT 2 BYTES AS IS       
                X,      $ SPACE OUT B2             
                14,2,   $ NEXT 2 BYTES AS IS       
                X,      $ SPACE OUT C2             
                17,11,  $ NEXT 11 BYTES AS IS       
                X,      $ SPACE OUT A4             
                29,2,   $ NEXT 2 BYTES AS IS       
                X,      $ SPACE OUT B4             
                32,2,   $ NEXT 2 BYTES AS IS       
                X,      $ SPACE OUT C4             
                35,46)  $ REST OF THE DATA         
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12382
Topics: 75
Location: San Jose

PostPosted: Wed Jun 30, 2004 9:08 am    Post subject: Reply with quote

Vkphani,

What is wrong with you? : Evil or Very Mad You posted three topics with the same question. Post the question just once.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Jun 30, 2004 9:18 am    Post subject: Reply with quote

Thanks for the reply Kolusu.
By mistake I posted 3 times.I am very sorry.
Back to top
View user's profile Send private message Send e-mail
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Jun 30, 2004 9:34 am    Post subject: Reply with quote

Kolusu,

With this code it will just put spaces for A2,B2,C2,A4,B4,C4.
It is not putting spaces by comparing a1 with a2, b1 with b2, c1 with c2 ,a3 with a4, b3 with b4, c3 with c4.

If and only if it meets the above crieteria it needs to put spaces.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12382
Topics: 75
Location: San Jose

PostPosted: Wed Jun 30, 2004 9:42 am    Post subject: Reply with quote

Vkphani,

The above posted job is indeed is comparing a1 with a2, b1 with b2, c1 with c2 ,a3 with a4, b3 with b4, c3 with c4.

Look at the include condition. We are writting out the records if all of the conditions match.
Code:

a1 matches a2 and
b1 matches b2 and
c1 matches c2 and
a3 matches a4 and
b3 matches b4 and
c3 matches c4.


What do you want to do with unmatched records?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Jun 30, 2004 9:55 am    Post subject: Reply with quote

Thanks Kolusu.
The code worked fine.
Back to top
View user's profile Send private message Send e-mail
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Jun 30, 2004 10:05 am    Post subject: Reply with quote

Kolusu,

If there are 20 columns for each headers a, b, c. Then how to compare each 'a' record with each column?

i.e. comparing a1 with a2,a3....a20.
comparing a2 with a1,a3....a20 so on.

comparing b1 with b2,b3....b20.
comparing b2 with b1,b3....b20 so on.

comparing c1 with c2,c3....c20.
comparing c2 with c1,c3....c20 so on.

As soon as a match is found, it has to put spaces for all other duplicates.

How to do this.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12382
Topics: 75
Location: San Jose

PostPosted: Wed Jun 30, 2004 11:47 am    Post subject: Reply with quote

Vkphani,

You just can replicate the above posted job to meet your requirements. Try to understand the job and by doing so you will learn a lot. Don't blindly copy the sample code.

The include cond is self explanatory.
Code:

INCLUDE COND=(01,1,CH,EQ,10,1,CH,AND,             
               04,1,CH,EQ,13,1,CH,AND,             
               07,1,CH,EQ,16,1,CH,AND,             
               19,1,CH,EQ,28,1,CH,AND,             
               22,1,CH,EQ,31,1,CH,AND,             
               25,1,CH,EQ,34,1,CH)                 


In the above code, sort will include only records

Code:

1.when pos1(A1) for a length of 1 byte is equal , the field at pos 10(A2) for a length of 1 byte AND

2.when pos4(B1) for a length of 1 byte is equal , the field at pos 13(B2) for a length of 1 byte AND

3.when pos7(C1) for a length of 1 byte is equal , the field at pos 16(C2) for a length of 1 byte AND

4.when pos19(A3) for a length of 1 byte is equal , the field at pos 28(A4) for a length of 1 byte AND

5.when pos22(B3) for a length of 1 byte is equal , the field at pos 31(B4) for a length of 1 byte AND

6.when pos25(C3) for a length of 1 byte is equal , the field at pos 34(C4) for a length of 1 byte


Using the same logic code the 20 conditions.

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group