Sort reqd to sum the records & also to reformat the records.



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

Sort reqd to sum the records & also to reformat the records.

Postby Laksh » Tue Jan 08, 2008 12:41 pm

My input file has the first seven bytes as the sort tag. I need a sort that would give me two output files - One with unique records with the first seven bytes and the count of such records. The second should be the same as my input file with the first seven bytes removed. Is it possible to write such a Sort?

My input file:
ABCDEFG jkhfjdkhmhgjldhglkdgh
ACDFGRE ljglkrgjrklgjrklgjrklgjkl
BFGRSFF dgdgdkglrgmlgmlglgklkl
ABCDEFG jfkfjkjlmhnfdjknfhssjs
ASDFREG jklejf agfwdhdsbndmfj
ACDFGRE hwitbbcvmznhyurhwin

My output files should be:
Output 1:
ABCDEFG 2
ACDFGRE 2
ASDFREG 1
BFGRSFF 1


Output 2: This can be sorted or may be written in the same order as in the input file.
jkhfjdkhmhgjldhglkdgh
ljglkrgjrklgjrklgjrklgjkl
dgdgdkglrgmlgmlglgklkl
jfkfjkjlmhnfdjknfhssjs
jklejf agfwdhdsbndmfj
hwitbbcvmznhyurhwin

Thanks in advance,
Laksh
Laksh
 
Posts: 3
Joined: Mon Jan 07, 2008 3:43 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sort reqd to sum the records & also to reformat the records.

Postby Alissa Margulies » Fri Feb 29, 2008 11:26 pm

This can be accomplished in a single pass of the data using PIPESORT, which is an add-on product to SyncSort for z/OS. Assuming that you do NOT have access to PIPESORT, here is a SyncSort application that should provide the desired results:
//STEP1  EXEC  PGM=SORT           
//SYSOUT   DD  SYSOUT=*           
//SORTOUT  DD  SYSOUT=*           
//SORTIN   DD  *                             
ABCDEFG JKHFJDKHMHGJLDHGLKDGH               
ACDFGRE LJGLKRGJRKLGJRKLGJRKLGJKL           
BFGRSFF DGDGDKGLRGMLGMLGLGKLKL               
ABCDEFG JFKFJKJLMHNFDJKNFHSSJS               
ASDFREG JKLEJF AGFWDHDSBNDMFJ               
ACDFGRE HWITBBCVMZNHYURHWIN                 
//SYSIN     DD  *                           
   INREC FIELDS=(1,16)                       
   SORT FIELDS=(1,7,ZD,A)                   
   OUTFIL REMOVECC,NODETAIL,                 
   SECTIONS=(1,7,TRAILER3=(1:1,7,9:COUNT))   
/*
//STEP2  EXEC  PGM=SORT               
//SYSOUT   DD  SYSOUT=*               
//SORTOUT  DD  SYSOUT=*               
//SORTIN   DD  *                     
ABCDEFG JKHFJDKHMHGJLDHGLKDGH         
ACDFGRE LJGLKRGJRKLGJRKLGJRKLGJKL     
BFGRSFF DGDGDKGLRGMLGMLGLGKLKL       
ABCDEFG JFKFJKJLMHNFDJKNFHSSJS       
ASDFREG JKLEJF AGFWDHDSBNDMFJ         
ACDFGRE HWITBBCVMZNHYURHWIN           
//SYSIN     DD  *                     
   SORT FIELDS=COPY                   
   OUTREC FIELDS=(9,25)       
/*       
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: Sort reqd to sum the records & also to reformat the records.

Postby Alissa Margulies » Sat Mar 01, 2008 1:08 am

For the first step, you can also specify:
//SYSIN    DD *               
  SORT FIELDS=(1,7,CH,A)     
  INREC OVERLAY=(1,7,9:C'1')
  SUM FIELDS=(9,1,ZD)         
  OUTREC FIELDS=(1,9)       
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: Sort reqd to sum the records & also to reformat the records.

Postby arunprasad.k » Sat Mar 01, 2008 1:18 pm

Laksh, How about this JCL in single pass?

//S01   EXEC  PGM=SORT                                                 
//SYSOUT  DD  SYSOUT=*                                                 
//OUT1    DD  SYSOUT=*                                                 
//OUT2    DD  SYSOUT=*                                                 
//SORTIN  DD  *                                                         
ABCDEFG JKHFJDKHMHGJLDHGLKDGH                                           
ACDFGRE LJGLKRGJRKLGJRKLGJRKLGJKL                                       
BFGRSFF DGDGDKGLRGMLGMLGLGKLKL                                         
ABCDEFG JFKFJKJLMHNFDJKNFHSSJS                                         
ASDFREG JKLEJF AGFWDHDSBNDMFJ                                           
ACDFGRE HWITBBCVMZNHYURHWIN                                             
//SYSIN     DD  *                                                       
   SORT FIELDS=(1,7,ZD,A)                                               
   OUTFIL FNAMES=OUT1,REMOVECC,NODETAIL,                               
          SECTIONS=(1,7,TRAILER3=(1:1,7,9:COUNT))                       
   OUTFIL FNAMES=OUT2,OUTREC=(1:9,25)                                   
/*                                                                     


Output 2: This can be sorted or may be written in the same order as in the input file.


My JCL will give the O/P in sorted order.

Post if you have any question.

Arun.
arunprasad.k
 
Posts: 110
Joined: Thu Dec 27, 2007 5:18 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Sort reqd to sum the records & also to reformat the records.

Postby Alissa Margulies » Mon Mar 03, 2008 11:12 pm

arunprasad.k wrote:My JCL will give the O/P in sorted order.

Sorry, I misread the initial post and thought the second output had to be the same order of the original input file.
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


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post