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 a pair of records thru SYNC-SORT

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


Joined: 05 Sep 2003
Posts: 119
Topics: 33
Location: Hyderabad

PostPosted: Thu Jan 19, 2006 8:38 pm    Post subject: How to eliminate a pair of records thru SYNC-SORT Reply with quote

Hi,
I am having 2 files with FB of length 80.The data in the file look like this.

File 1:
Code:


AAAAAA                    ZZZZZZZ
AAAAAA                    ZZZZZZZ
BBBBBB                    KKKKKKK
BBBBBB                    KKKKKKK
CCCCCC                    DDDDDDD


File 2 :
Code:

AAAAAA                    ZZZZZZZ
BBBBBB                    KKKKKKK
BBBBBB                    KKKKKKK


I need to prduce an o/p file with one ot one match.The o/p file should look like

Code:


AAAAAA                    ZZZZZZZ
CCCCCC                    DDDDDDD



1)There are 2 records(AAAA..) in file-1 and 1 record in file-2,so I need to eliminate 1 record from the i/p file.
2)There are 2 records (BBBB..) in both the files,So I need to eliminate all the records.
3)There is no record (CCCCC..) in the file 2 ,So I need to retain the record in the o/p file.


Is this possible thru SYNC-SORT ?

Thank you
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Jan 19, 2006 9:33 pm    Post subject: Reply with quote

bprasanna,

With some assumptions , the following JCL will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=YOUR FILE 1,
//            DISP=SHR
//         DD DSN=YOUR FILE 2,
//            DISP=SHR
//SORTOUT  DD SYSOUT*
//SYSIN    DD *
  INREC FIELDS=(1,80,C'00000001')
  SORT FIELDS=(1,6,CH,A)
  SUM FIELDS=(81,8,ZD)
  OUTFIL INCLUDE=(81,8,ZD,LE,3),
  OUTREC=(1,80)
/*


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
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Jan 20, 2006 2:30 am    Post subject: Reply with quote

Kolusu,

From what I understoold from bprasanna's note, he wants to reject all matched ones and pick-up only the un-matched / extra records. I would prefer to check if the summed sequence number is ODD instead of saying (81,8,ZD,LE,3). Still, it doesnot satisfy all test cases. (I hope, this is what u meant by this "With Some Assumptions")

bprasanna,
It would be better if you can provide a more detailed list of test cases so that we can provide a accurate solution. (currently, we are forced to guess lots of things).

Question 1:
What if you have 3 records with same key in file 1 but there are no occurences in file 2 ? Do you want to write 3 output records or only 1 record ?

Question 2:
What are the maximum occurances possible for a key in each of your input files.

Question 3:
You have shown 2 fields in your input datasets. Both have the same value in your sample data. Is this always true ? Do you want us to match only on the first field (AAAAA, BBBBB, CCCCC ????) or would u like to match on the second field also ?

Thanks,

Phantom
Back to top
View user's profile Send private message
bprasanna
Beginner


Joined: 05 Sep 2003
Posts: 119
Topics: 33
Location: Hyderabad

PostPosted: Sun Jan 22, 2006 3:58 pm    Post subject: Reply with quote

Hi,
Thank you for the replies.I am out of town for few days.
Here is my requirement. I am getting a file with data like bank user ,account number , trans-type, reveresed and amount.
The fileds reversed is going to have either Y or 'N'.Here is the test file that look like.


Code:

USER  A/C no   Trans-type   Reversed   Amt
====  ======   ==========   ========   =====
01    12345     KF           N         10.01
01    12345     KF           Y         10.01
01    12345     KF           N         10.01
01    12345     KF           N         20.00
01    12346     KF           N         20.00
01    12347     KF           N         24.00
01    12347     KF           Y         24.00
01    12347     KF           N         24.00
01    12347     KF           N         24.00
01    12348     KF           Y         21.00 


I need to generate the o/p with eliminating the paired transactions(Ie..if an a/c number is having the same trans typ for same amount with 'y' and 'n' then I need to remove it from the list).

Code:

USER  A/C no   Trans-type   Reversed   Amt
====  ======   ==========   ========   =====
01    12345     KF           N         10.01
01    12345     KF           N         20.00
01    12346     KF           N         20.00
01    12347     KF           N         24.00
01    12347     KF           N         24.00
01    12348     KF           Y         21.00
 


I have given 2 files in my post becuase ,I have splitted the file in to 2 files with trans 'y' one and 'N' one.

Thank you.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Sun Jan 22, 2006 7:13 pm    Post subject: Reply with quote

You really don't have to really split the files into 2 files as 'y' and 'n'. Try this JCL

Code:

//STEP0100 EXEC PGM=SYNCTOOL                 
//TOOLMSG  DD SYSOUT=*                       
//DFSMSG   DD SYSOUT=*                       
//IN       DD *                             
----+----1----+----2----+----3----+----4----+----5
01    12345     KF           N         10.01
01    12345     KF           Y         10.01
01    12345     KF           N         10.01
01    12345     KF           N         20.00
01    12346     KF           N         20.00
01    12347     KF           N         24.00
01    12347     KF           Y         24.00
01    12347     KF           N         24.00
01    12347     KF           N         24.00
01    12348     KF           Y         21.00
/*
//T1       DD DSN=&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&T2,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//T3       DD DSN=&T3,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//CON      DD DSN=&T1,DISP=OLD,VOL=REF=*.T1                         
//         DD DSN=&T2,DISP=OLD,VOL=REF=*.T2                         
//OUT      DD SYSOUT=*                                             
/*
//TOOLIN   DD *                                 
  SORT   FROM(IN)  USING(CTL1)                   
  SPLICE FROM(CON) TO(T3)  -                     
         ON(01,02,CH)      -                     
         ON(07,05,CH)      -                     
         ON(17,02,CH)      -                     
         ON(30,02,CH)      -                     
         WITH(1,85) WITHALL USING(CTL2)         
  SELECT FROM(T3) TO(OUT)  -                     
         ON(01,02,CH)      -                     
         ON(07,05,CH)      -                     
         ON(17,02,CH)      -                     
         ON(40,05,CH)      -                     
         ON(81,05,CH) NODUPS USING(CTL3)         
/*
//CTL1CNTL DD *                                                     
 SORT FIELDS=(01,02,CH,A,    $ USER                                 
              07,05,CH,A,    $ ACT-NO                               
              17,02,CH,A,    $ TRANS-TYPE                           
              30,02,CH,A)    $ REVERSE FLAG                         
  OUTREC FIELDS=(1,80,SEQNUM,5,ZD,5X)                               
  OUTFIL FNAMES=T1,NODETAIL,REMOVECC,                               
  SECTIONS=(1,2,07,05,17,02,30,02,                                 
  TRAILER3=(1,85,MIN=(81,5,ZD,M11,LENGTH=5)))                       
  OUTFIL FNAMES=T2                                                 
/*
//CTL2CNTL DD *                                       
  OUTFIL FNAMES=T3,                                   
  OUTREC=(1,80,                                       
          ((81,5,ZD,SUB,86,5,ZD),ADD,+1),EDIT=(TTTTT))
/*
//CTL3CNTL DD *                                       
  OUTFIL FNAMES=OUT,                                 
  OUTREC=(1,80)                                       
/*


This will produce an output like this

Code:

01    12345     KF           N         10.01
01    12345     KF           N         20.00
01    12346     KF           N         20.00
01    12347     KF           N         24.00
01    12347     KF           N         24.00
01    12348     KF           Y         21.00


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