Split file with key and its subsequent records



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

Split file with key and its subsequent records

Postby akanchu » Sat Aug 08, 2009 7:26 am

Hi,
Checking to see if this is possible with SORT/ICETOOL.
I have a file that has records in the following format.
HEAD MCNTRXX 0807200916301242            0000000001                             
HEAD CNTARXX 0807200916301242            0000000002010766100                     
10000085000A010766100                                                           
30                    0003500001                                               
70                                        14 GRABLES CIR                         
HEAD CNTBRXX 0807200916301242            000000000351800760873                   
10000085000A51800760873                                                         
30                    0003500001                                               
70                                        3 FENDER CT                           
HEAD CNTARXX 0807200916301242            0000000010010768900                     
10000085000A010768900                                                           
23                    0003500001                                               
73                                        56 JILLCREST RD                       

.
.
.

HEAD MCNTRXX 0807200916301242            0000000013   


The first record is the header of the file that needs to be skipped.
The second record is the header for the group.
So the records :
HEAD CNTARXX 0807200916301242 0000000002010766100
10000085000A010766100
30 0003500001
70 14 GRABLES CIR
are 1 set.
simiarly others.

The last record is the trailer of the file, with a count in it, that can be skipped.

The task here is to split the file into 2 files so that records with its header and set of records should be written to 1 file.. and other group to 2nd file.
Last record should be the trailer with the count of that file.

The first 12 bytes is the key - in this case "HEAD CNTARXX" and "HEAD CNTBRXX"

So the result should be :
File 1 :
HEAD CNTARXX 0807200916301242            0000000006010766100                     
10000085000A010766100                                                           
30                    0003500001                                               
70                                        14 GRABLES CIR                         
HEAD CNTARXX 0807200916301242            0000000010010768900                     
10000085000A010768900                                                           
23                    0003500001                                               
73                                        56 JILLCREST RD                       
HEAD CNTARXX 0807200916301242            0000000002


File 2 :
HEAD CNTBRXX 0807200916301242            000000000351800760873                   
10000085000A51800760873                                                         
30                    0003500001                                               
70                                        3 FENDER CT                           

HEAD CNTBRXX 0807200916301242            0000000001


Hope I have drafted my question properly.
Let me know if anyone needs more clarification.

Thanks
Aka
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: Split file with key and its subsequent records

 

Re: Split file with key and its subsequent records

Postby Frank Yaeger » Mon Aug 10, 2009 9:32 pm

Let me know if anyone needs more clarification.


Yes:

What is the RECFM and LRECL of the input file?

What is the starting position, length and format of each relevant field?

The first record can just be ignored - right?

Where does the following field in the trailer record come from

0807200916301242

Is it just a hardcoded string or is it copied from one of the input records (which one)?

It appears the count in the trailer record is the count of the number of groups (e.g. the number of CNTARXX groups for output file1) - is that correct?
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Split file with key and its subsequent records

Postby akanchu » Tue Aug 11, 2009 12:25 am

Here are the answers :

What is the RECFM and LRECL of the input file?
RECFM is FB and LRECL is 3000 bytes
What is the starting position, length and format of each relevant field?
the key starts from 1 to 13 bytes.
The first record can just be ignored - right?
Yes it can be ignored
Where does the following field in the trailer record come from

0807200916301242

Is it just a hardcoded string or is it copied from one of the input records (which one)?
it is hardcoded same pos as the other records in the key record

It appears the count in the trailer record is the count of the number of groups (e.g. the number of CNTARXX groups for output file1) - is that correct?
Yes your understanding is correct, it is the count of number of groups

thanks.
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: Split file with key and its subsequent records

Postby Frank Yaeger » Tue Aug 11, 2009 1:33 am

Here's a DFSORT job that will do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTDIAG DD DUMMY
//SORTIN DD DSN=... input file (FB/3000)
//OUT1 DD DSN=...   output file1 (FB/3000)
//OUT2 DD DSN=...   output file2 (FB/3000)
//SYSIN DD *
  OPTION SKIPREC=1,EQUALS
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'HEAD'),
    PUSH=(3001:1,29))
  SORT FIELDS=(3001,12,CH,A)
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,12,CH,EQ,C'HEAD CNTARXX'),
    PUSH=(3030:ID=10)),
   IFTHEN=(WHEN=GROUP,BEGIN=(1,12,CH,EQ,C'HEAD CNTBRXX '),
    PUSH=(3030:ID=10))
  OUTFIL FNAMES=OUT1,INCLUDE=(3001,12,CH,EQ,C'HEAD CNTARXX'),
    REMOVECC,
    BUILD=(1,3000),
    TRAILER1=(3001,29,42:3030,10)
  OUTFIL FNAMES=OUT2,INCLUDE=(3001,12,CH,EQ,C'HEAD CNTBRXX'),
    REMOVECC,
    BUILD=(1,3000),
    TRAILER1=(3001,29,42:3030,10)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Split file with key and its subsequent records

Postby akanchu » Tue Aug 11, 2009 7:08 am

Hi Frank,
Thanks for your reply.
Do I have to have a specific version of SORT.
It goves me the following error
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'HEAD'),   
                   *                                 
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,8,CH,EQ,C'...
                    *                                     
WER268A  INREC STATEMENT   : SYNTAX ERROR                     
WER268A  OUTREC STATEMENT  : SYNTAX ERROR                     



We have version : SYNCSORT FOR Z/OS 1.3.1.0R

Am I missing something.
Thanks
akanchu
 
Posts: 36
Joined: Fri Jan 23, 2009 3:11 am
Has thanked: 0 time
Been thanked: 0 time

Re: Split file with key and its subsequent records

Postby dick scherrer » Tue Aug 11, 2009 7:51 am

Hello,

We have version : SYNCSORT FOR Z/OS 1.3.1.0R

Am I missing something.
Yup. . . This part of the forum is for DFSORT topics.

I'll move the topic to the Syncsort part of the forum.

WHEN=GROUP is also supported by Syncsort, but your system support would need to install the latest upgrade.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post