View previous topic :: View next topic
|
Author |
Message |
Yash19
New User
Joined: 09 Jun 2008 Posts: 8 Location: Mumbai
|
|
|
|
I have a number of records in my Input file as
100
500
400
300
How to add these records and write the total in output file. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Have you looked at the SUM operand? |
|
Back to top |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
Here is a SyncSort for z/OS job that will produce your requested output:
Code: |
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
100
500
400
300
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL TRAILER1=(TOT=(1,3,ZD)),NODETAIL,REMOVECC
/* |
|
|
Back to top |
|
|
Yash19
New User
Joined: 09 Jun 2008 Posts: 8 Location: Mumbai
|
|
|
|
Thank you very much for the response.
The sort card that you mentioned works fine, however how to add if the number conatins desimal values.
eg.
100.12
500.45
400
300
how to make sum of these numbers.
Thanks you for your help. |
|
Back to top |
|
|
Yash19
New User
Joined: 09 Jun 2008 Posts: 8 Location: Mumbai
|
|
|
|
William Thompson wrote: |
Have you looked at the SUM operand? |
Yes I checked with Sum fields=(Startting Position, Length,ZD)
however its not working, if sum oprand is anything different please guide me on this. |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
SUM descrition:
The SUM statement can be used to summarize data, based on the SORT statement. One record will be produced for each unique key present in the input. If numeric fields are specified for summation, those fields will be summed up. The SYNCSORT software does not guarantee unique records if numeric fields are required to be summed up. Whenever there is an overflow of a numeric field, more than one record may be created. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Numbers with embedded decimal points are not ZD. . .
That format is SFF. |
|
Back to top |
|
|
Yash19
New User
Joined: 09 Jun 2008 Posts: 8 Location: Mumbai
|
|
|
|
Thank you ,
with SFF it worked, but one concern is that if I am taking the input as flat file then I am getting the correct total, however if I use 'genaeration data set' as input file its giving me a incorrect value, kindly guide me if we have solution on this. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
There should be no difference if both the flat file and the gdg have the same attributes and content. . .
Showing some the input and the results from both processes may help us help you. Also, post the jcl sort control statements, and any informational messages generated by the runs (include message ids). |
|
Back to top |
|
|
Yash19
New User
Joined: 09 Jun 2008 Posts: 8 Location: Mumbai
|
|
|
|
dick scherrer wrote: |
Hello,
There should be no difference if both the flat file and the gdg have the same attributes and content. . .
Showing some the input and the results from both processes may help us help you. Also, post the jcl sort control statements, and any informational messages generated by the runs (include message ids). |
Hi.
904.00
378.65
Input data in both cases is as above
1) Using flat file as an Input file I am geting corret output as 1282.65
2) Using GDS as an input file I am getting 1.27 in an output file and when I open that output file gets following message.
"Truncation warning. The data you are editing is variable length data with at least one record that ends with a blank. Saving the data will result in
removal of any trailing blanks from all records. You can issue the PRESERVE ON command if you don't want the blanks removed. "
I am using follwing sort card:
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL NODETAIL,
TRAILER1=(TOTAL=(1,6,SFF,EDIT=(TTTT.TT)))
/*
Please guide me and let me know if you want any more details.
Thanks a lot for your support so far . |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
dick scherrer
wrote: |
post the jcl sort control statements, and any informational messages generated by the runs (include message ids).
|
Yash19 wrote: |
let me know if you want any more details |
Yash,
You need to post all the requested details before going into "more details". |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I suspect the gdg may be vb and the qsam file is fb. . .
To repeat:
Quote: |
There should be no difference if both the flat file and the gdg have the same attributes and content. . . |
It is surely a shame that people looking to solve their problems will not post requested info. . . |
|
Back to top |
|
|
|