Page 1 of 1

Copy & Sum the records

PostPosted: Mon Apr 27, 2009 11:37 pm
by akanchu
I have a file that has mulitple header records and their subsequent transaction records.

I am trying to copy the file, but only sum the count in the headers and create only 1 Header record.


<key> <date><time> <count>
file looks like
HeaderHome 04272009113000 0000002
Record1
Record2
HeaderHome 04272009113200 0000001
Record1
HeaderHome 04272009113500 0000003
Record1
Record2
Record3


Result should be

HeaderHome 04272009113000 0000006
Record1
Record2
Record1
Record1
Record2
Record3


I was able to addup the counts, but could not get the trans records copied using SYNCSORT.
I am trying to use the the IFTHEN to apply the merge or the sum only on the key (HeaderHome) but no breakthru.

Any suggestions?

Thanks in advance.

Re: Copy & Sum the records

PostPosted: Tue Apr 28, 2009 1:15 am
by Alissa Margulies
akanchu,

Try this SyncSort for z/OS 1.3 job:

//SORT1 EXEC PGM=SORT 
//SYSOUT  DD SYSOUT=*   
//SORTIN  DD *                                             
HEADERHOME 04272009113000 0000002                         
RECORD1                                                   
RECORD2                                                   
HEADERHOME 04272009113200 0000001                         
RECORD1                                                   
HEADERHOME 04272009113500 0000003                         
RECORD1                                                   
RECORD2                                                   
RECORD3                                                   
//SORTOUT DD SYSOUT=*
//SYSIN   DD *                                               
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),       
         IFTHEN=(WHEN=(1,1,CH,EQ,C'H'),OVERLAY=(81:8C'0'))   
   SORT FIELDS=(81,8,CH,A)                                   
   DUPKEYS SUM=(27,7,ZD)                                     
   OUTREC FIELDS=(1,80)                                     
/*                                                         

Re: Copy & Sum the records

PostPosted: Tue Apr 28, 2009 8:24 am
by akanchu
Hi Alissa,
Thanks for the reply.
I am not sure if I am missing anything. Here are the problems I am facing.
(a) We have SYNCSORT, which did not recognize DUPKEYS, so could not use that with SYNCSORT.
(b) I tried the same code with ICETOOL, but did not work, it just gave the same data as output. No difference, no total.

this is what it looks like
//STEP01   EXEC PGM=ICETOOL                         
//INPT     DD *                                     
HEADERHOME 04272009113000 0000001                   
RECORD1                                             
RECORD2                                             
HEADERHOME 04272009113200 0000001                   
RECORD1                                             
HEADERHOME 04272009113500 0000003                   
RECORD1                                             
RECORD2                                             
RECORD3                                             
/*                                                 
//OUPT     DD SYSOUT=*
//SYSOUT   DD SYSOUT=*                                               
//SYSPRINT DD SYSOUT=*                                               
//SYSUDUMP DD SYSOUT=*                                               
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//TOOLIN DD *                                                         
    COPY FROM(INPT) TO(OUPT) USING(CTL1)                             
/*                                                                   
//CTL1CNTL DD *                                                       
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),                 
         IFTHEN=(WHEN=(1,1,CH,EQ,C'H'),OVERLAY=(81:8C'0'))           
   SORT FIELDS=(81,8,CH,A)                                           
   DUPKEYS SUM=(27,7,ZD)                                             
   OUTREC FIELDS=(1,80)                                               
/*                                                                   

Am I missing something ? I do not want all the header records to be copied.. just one (first one).

Please help.

Thanks in advance.

Re: Copy & Sum the records

PostPosted: Tue Apr 28, 2009 8:41 am
by dick scherrer
Hello,

Please help.
You need to help yourself. . . Do not post "it didn't work".

We cannot help unless you provide the proper info. When something does not work correctly or terminates with some error, you need to post all of the informational messages (including the message ids) from the problem run.

Why did you use icetool when the posted solution uses sort? When someone from the vendor offers a solution, it is best to work the solution they provided. . .

Did you notice that Alissa mentions release 1.3. Is your sort product current (this is also in the informational output from the sort)?

Re: Copy & Sum the records

PostPosted: Tue Apr 28, 2009 6:53 pm
by akanchu
This may sound a little weird.

When I do a jj with the SORT, it gives me the following error :
DSS11051E UNRECOGNIZED 'SORT' KEYWORD 'DUPKEYS'

so I switched to ICETOOL, to see if that takes it. It did recognize it.
But then did not get the right result.

After reading Dick's mail, I went ahead to submit the JCL with the SORT and IT WORKED.. not sure why it gives the JCL error.

Thanks to both of you.

Re: Copy & Sum the records

PostPosted: Tue Apr 28, 2009 8:29 pm
by Alissa Margulies
akanchu,

JCL checkers typically are not kept up-to-date with the current features and functions of the SORT utilities. This is quite a common problem. Just as you had done here, in the future I would recommend simply just running the actual test sort jobs to see what results you get.

Re: Copy & Sum the records

PostPosted: Wed Apr 29, 2009 1:44 am
by dick scherrer
Good to hear it is working - thanks for letting us know :)

As Alissa mentions, different jcl checkers fall way behind - quite regularly.

There is also the liklihood that the jcl checkers will not implement all of the variations supported all of the software providers.

To check jcl syntax and not actually run a job, you could include TYPRUN=SCAN on the JOB statement and submit this.