IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SYNCSORT to add the records of same file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Yash19

New User


Joined: 09 Jun 2008
Posts: 8
Location: Mumbai

PostPosted: Tue May 12, 2009 6:23 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue May 12, 2009 7:33 pm
Reply with quote

Have you looked at the SUM operand?
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Tue May 12, 2009 9:14 pm
Reply with quote

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
View user's profile Send private message
Yash19

New User


Joined: 09 Jun 2008
Posts: 8
Location: Mumbai

PostPosted: Wed May 13, 2009 2:14 pm
Reply with quote

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
View user's profile Send private message
Yash19

New User


Joined: 09 Jun 2008
Posts: 8
Location: Mumbai

PostPosted: Wed May 13, 2009 2:26 pm
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Wed May 13, 2009 4:50 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed May 13, 2009 8:28 pm
Reply with quote

Hello,

Numbers with embedded decimal points are not ZD. . .

That format is SFF.
Back to top
View user's profile Send private message
Yash19

New User


Joined: 09 Jun 2008
Posts: 8
Location: Mumbai

PostPosted: Fri May 15, 2009 5:05 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri May 15, 2009 7:49 pm
Reply with quote

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
View user's profile Send private message
Yash19

New User


Joined: 09 Jun 2008
Posts: 8
Location: Mumbai

PostPosted: Fri May 15, 2009 8:37 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri May 15, 2009 11:18 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat May 16, 2009 1:25 am
Reply with quote

Hello,

I suspect the gdg may be vb and the qsam file is fb. . . icon_confused.gif

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. . . icon_neutral.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top