MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SUM fields in SYNCSORT

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Ranjish
Beginner


Joined: 22 Dec 2002
Posts: 64
Topics: 28
Location: Chennai

PostPosted: Thu Oct 30, 2003 7:56 am    Post subject: SUM fields in SYNCSORT Reply with quote

Hi,

Could you please let me know how we can do a summation of fields using SYNCSORT?

The data is in the following format.

+00000000004.5000
+00000012104.5000
+00000000344.5000
+00000000454.5333
+00000007034.0000

Thanks
Ranjish
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Oct 30, 2003 9:06 am    Post subject: Reply with quote

Ranjish,

Is the above your entire data?? I mean don't you have any key ?? And is the number always positive??

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ranjish
Beginner


Joined: 22 Dec 2002
Posts: 64
Topics: 28
Location: Chennai

PostPosted: Thu Oct 30, 2003 9:22 am    Post subject: Reply with quote

Kolusu,

No,this is not the complete data. We have some fields before this amount field which is the key value. Also the sign may be negative also.

regards
Ranjish
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Oct 30, 2003 9:57 am    Post subject: Reply with quote

Ranjish,

The following JCL will give you the desired results. I am assuming that your input file is having lrecl=80 and FB format.

The key starts in position 1 and is 10 bytes in length and your amount values starts from position 50 and 17 including the decimal.

A brief explanation of the job. We first need to strip of the decimal from the records and convert the number to packed decimal, so that you can sum the values.once you convert the amount to PD , you can sum it and then again while writting out we can change the PD field back to display field.

Code:

//STEP0100 EXEC  PGM=SYNCTOOL                       
//TOOLMSG  DD SYSOUT=*                               
//DFSMSG   DD SYSOUT=*                               
//IN       DD DSN=YOUR INPUT FILE,
//            DISP=SHR                               
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//OUT      DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),   
//            UNIT=SYSDA,                 
//            SPACE=(CYL,(X,Y),RLSE)     
//TOOLIN   DD    *                   
  COPY FROM(IN) TO(T1)  USING(CTL1) 
  SORT FROM(T1) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
* CHANGE STTTTTTTTTTT.TTTT NUMBER TO STTTTTTTTTTTTTTTT NUMBER SO IT 
* CAN BE CONVERTED FROM FS TO PD                     
  INREC FIELDS=(1,39,                  * BYTES BEFORE AMOUNT     
                40,12,                 * SIGN/DIGITS BEFORE.     
                53,4,                  * DIGITS AFTER.           
                57,24)                 * BYTES AFTER AMOUNT

  OUTREC FIELDS=(1,39,                 * BYTES BEFORE AMOUNT
                 40,16,FS,PD,LENGTH=8, * FS TO PD           
                 57,25)                * BYTES AFTER AMOUNT
//CTL2CNTL DD *
  SORT FIELDS=(1,10,CH,A)              * SORT ON KEY FIELD                     
  SUM FIELDS=(40,8,PD)                 * SUM PD NUMBER                   
  OUTREC FIELDS=(1,39,                 * BYTES BEFORE AMOUNT     
                 40,8,PD,EDIT=(STTTTTTTTTTT.TTTT),SIGNS=(,-),
                 48,24)                * BYTES AFTER THE AMOUNT   
/*


Hope this helps...

cheers

kolusu

PS: Please post all the details like LRECL,RECFM, POSITION of the field to be summed and a sample of input and output data would help you get the solution. This will avoid any unnecessary guess work.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group