View previous topic :: View next topic
Author
Message
ravikumarreddy Warnings : 1 New User Joined: 29 Jul 2005Posts: 23
HI,
here i have a question which is suppose to answer thru JCL.
MY FILE LIKE FOLLOWING:
Code:
PRC-NB COUNT
101 20
101 30
102 40
102 50
103 60
103 70
--------------------------------------------------------------
OUT PUT NEEDS LIKE FOLLOWING
Code:
PRC-NB COUNT
101 50
102 90
103 130
******************************************
I NEED ABOVE THRU JCL.....
Back to top
rajesh_1183 Active User Joined: 24 Nov 2005Posts: 121 Location: Tadepalligudem
HI,
Code:
//JOB CARD...
//STEP1 EXEC PGM=SORT
//SORTIN DD DSN=INPUT FILE
//SORTXSUM DD DSN=OUTPUT FILE
//SYSIN DD *
SORTFIELDS=(1,3,CH,A)
SUMFIELDS=(5,2,CH)
/*
//
CORRECTIONS WELCOMED
Thanks,
Rajesh
Back to top
fixdoubts New User Joined: 21 Oct 2005Posts: 54
Hi,
The about jcl is correct but i doubt about
Quote:
SUMFIELDS=(5,2,CH)
I think the the SUM FIELDS needs to be numeric
should be
This will do i hope..
Regards,
Back to top
Mane Sagar New User Joined: 12 Jul 2005Posts: 41 Location: mumbai
Hi,
fixdoubts is very right.
It has to be
Code:
SUM FIELDS=(5,2,ZD)
Regards,
Sagar.
Back to top
manyone New User Joined: 09 Mar 2006Posts: 9
however the sum will be truncated if it's 100 or over because it's too short. to fix it, you need
INREC FIELDS=(1,3,X,C'0000',5,2)
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,6,ZD)
if you want record count too (here, i made it packed) , try this
INREC FIELDS=(1,3,X,X'00001C',X,C'0000',5,2)
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=(5,PD,9,6,ZD)
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Since your records are already in sorted order, you can avoid a sort, and use copy or merge which are more efficient.
Here are two ways to do this with DFSORT:
Method 1: COPY with SECTIONS and TRAILER1
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
101 20
101 30
102 40
102 50
103 60
103 70
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(3,3,
TRAILER3=(1,11,TOT=(12,5,FS,TO=FS,LENGTH=5)))
/*
Method 2: MERGE with SUM
Code:
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN01 DD *
101 20
101 30
102 40
102 50
103 60
103 70
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION ZDPRINT
MERGE FIELDS=(3,3,CH,A)
SUM FIELDS=(12,5,ZD)
/*
Back to top
vin78dotcom Warnings : 2 New User Joined: 06 Dec 2005Posts: 7 Location: pune
hello,
thanks for the different methods of sort and sums..
it worked for me ...but can you please let me know how to remove leading zeroes from the output summations.
e.g my output sum is coming as:000001
and i wanted just: 1 where zeroes should be replaced by spaces.
I used the COPY with SECTIONS and TRAILER1 techniques.
thnks
vinay
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
With DFSORT, TO=FS does remove the leading zeros. The output would be:
Code:
101 50
102 90
103 130
Perhaps you're not using DFSORT. Check the //SYSOUT messages. If they start with ICE (e.g. ICE000I), then you're using DFSORT. If you are using DFSORT, then post your control statements and //SYSOUT messages and the output you're getting. If you're not using DFSORT, then I can't help you.
Back to top
Please enable JavaScript!