compare 2 lines from 1 file



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

compare 2 lines from 1 file

Postby retep » Tue Mar 02, 2010 6:20 pm

I have the following problem.

I have a file with the following content:
A TEST 0Y
A TEST 0N
A TEST 1Y
A TEST 2Y
A TEST 2N
A TEST 3N
A TEST 4Y
A TEST 5N


Now, I expect at the end only the following lines at the output:
A TEST 0Y
A TEST 1Y
A TEST 2Y
A TEST 3N
A TEST 4Y
A TEST 5N


what syncsort coding do I need?
retep
 
Posts: 5
Joined: Tue Mar 02, 2010 5:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: compare 2 lines from 1 file

Postby Alissa Margulies » Tue Mar 02, 2010 11:40 pm

Here is a SyncSort for z/OS job that will produce the requested output:
//SORT  EXEC PGM=SORT           
//SORTOUT DD SYSOUT=*           
//SORTIN  DD *                   
A TEST 0Y                       
A TEST 0N                       
A TEST 1Y                       
A TEST 2Y                       
A TEST 2N                       
A TEST 3N                       
A TEST 4Y                       
A TEST 5N                       
//SYSOUT  DD SYSOUT=*           
//SYSIN   DD *                   
   SORT FIELDS=(1,8,CH,A),EQUALS
   SUM FIELDS=NONE   
/*
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 3 times

Re: compare 2 lines from 1 file

Postby retep » Wed Mar 03, 2010 1:54 pm

Thank you very much for the statement - it works very good - when the records are in this special sortorder.

unfortunatly is my example only the half truth - my records can (and, as i understand murphy), will be unsorted.

like this:
A TEST 0N
A TEST 2Y
A TEST 0Y
A TEST 1Y
A TEST 0N
A TEST 5Y
A TEST 4N
A TEST 2Y
A TEST 2N
A TEST 5N
A TEST 3N
A TEST 4Y

at the moment i do in the first step (exec) a sort like this:
SORT FIELDS=(1,8,CH,D)

afterwards i am running your sort.

this work very good, but: can i shorten these 2 steps in 1?

thank you very much for your help !!!
retep
 
Posts: 5
Joined: Tue Mar 02, 2010 5:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: compare 2 lines from 1 file

Postby Alissa Margulies » Wed Mar 03, 2010 9:44 pm

There is a SORT performed in my example on the same field. Why are you sorting in descending order and then resorting in ascending order in my step. Either remove the first sort step and just run my step, or remove your step and modify my step to reflect descending instead of ascending. Is there something I am missing here?
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 3 times

Re: compare 2 lines from 1 file

Postby retep » Thu Mar 04, 2010 7:04 pm

sorry for my wrong details.

1st: i have a file which contains the following UNSORTED data content:
A TEST 0N
A TEST 2Y
A TEST 0Y
A TEST 1Y
A TEST 0N
A TEST 5Y
A TEST 6N
A TEST 4N
A TEST 2Y
A TEST 2N
A TEST 5N
A TEST 3N
A TEST 4Y

2nd: i want to have the following result:
A TEST 6N
A TEST 5Y
A TEST 4Y
A TEST 3N
A TEST 2Y
A TEST 1Y
A TEST 0Y

when POS(1:8) are equals take the first record with 'Y' in POS(9:1), else take the first record with 'N' in POS(9:1), the remaining matching records can be discarded.

i hope this was more clear.

thank you for your patience!
retep
 
Posts: 5
Joined: Tue Mar 02, 2010 5:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: compare 2 lines from 1 file

Postby Alissa Margulies » Thu Mar 04, 2010 9:19 pm

Here is a SyncSort for z/OS 1.3 job that will do what you asked:
//SORT  EXEC PGM=SORT 
//SORTOUT DD SYSOUT=* 
//SORTIN  DD *         
A TEST 0N             
A TEST 2Y             
A TEST 0Y             
A TEST 1Y             
A TEST 0N             
A TEST 5Y             
A TEST 6N             
A TEST 4N             
A TEST 2Y             
A TEST 2N             
A TEST 5N             
A TEST 3N             
A TEST 4Y             
//SYSOUT  DD SYSOUT=* 
//SYSIN   DD *                                                     
   SORT FIELDS=(1,8,CH,A,9,1,CH,D)                                 
   OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,1,ZD,RESTART=(1,8)))
   OUTFIL INCLUDE=(81,1,ZD,EQ,1),BUILD=(1,80)                     
/*     

Here is the output produced from the above job:
A TEST 0Y
A TEST 1Y
A TEST 2Y
A TEST 3N
A TEST 4Y
A TEST 5Y
A TEST 6N
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 3 times

Re: compare 2 lines from 1 file

Postby Alissa Margulies » Thu Mar 04, 2010 9:23 pm

Here is another alternative:
//SYSIN   DD *             
   SORT FIELDS=(1,9,CH,A)   
   OUTFIL SECTIONS=(1,8,   
          TRAILER3=(1,80)),
          REMOVECC,NODETAIL
/*                         
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 3 times

Re: compare 2 lines from 1 file

Postby retep » Thu Mar 11, 2010 8:48 pm

thanx a lot, the second one works phantasic!

:D
retep
 
Posts: 5
Joined: Tue Mar 02, 2010 5:51 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post