Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Oct 30, 2003 9:57 am Post subject:
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.
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