View previous topic :: View next topic
|
Author |
Message |
kalyan.v
New User
Joined: 04 Feb 2008 Posts: 65 Location: Hyd
|
|
|
|
Hi,
I have a requirement to find the total of one field and its corresponding record count.
Please see the below example.
Code: |
Input:
79(09) 170(2)
XXXXXXXXXX +0.82XXXXXXXAB
XXXXXXXXXX +20.65XXXXXXXAB
XXXXXXXXXX +53.78XXXXXXXAB
XXXXXXXXXX +13.34XXXXXXXAB
XXXXXXXXXX +3.94XXXXXXXAB
Output should be like this:
1 3(8) 11(10)
AB 5+000009089
<------><-------->
|
I write below sort card using two output files to get the values.
Code: |
//SYSIN DD *
SORT FIELDS=(170,02,CH,A)
OUTFIL FILES=01,REMOVECC,NODETAIL,
INCLUDE=(83,02,CH,NE,C'+0'),
SECTIONS=(170,02,
TRAILER3=(170,02,
COUNT,
TOT=(79,09,SFF,EDIT=(STTTTTTTTT),SIGNS=(+,-))))
OUTFIL FILES=02,REMOVECC,NODETAIL,
INCLUDE=(83,02,CH,EQ,C'+0'),
SECTIONS=(170,02,
TRAILER3=(170,02,
COUNT,
TOT=(79,09,SFF,EDIT=(STTTTTTTTT),SIGNS=(+,-))))
/*
|
Output file 1:
AB 4+000009171
Output file 2:
AB 1+000000082
Using these two values i got the required sum using COBOL.
9171 - 0082 = 9089
Can i get the mentioned output in a single sortout file??
Thanks,
Kalyan |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
kalyan.v
Check the below sort card
Code: |
//*******************************************************
//STEP001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
XXXXXXXXXX +0.82XXXXXXXAB
XXXXXXXXXX +20.65XXXXXXXAB
XXXXXXXXXX +53.78XXXXXXXAB
XXXXXXXXXX +13.34XXXXXXXAB
XXXXXXXXXX +3.94XXXXXXXAB
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=(15,2,CH,EQ,C'+0'),OVERLAY=(15:C'-'))
SORT FIELDS=(27,02,CH,A)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(27,02,
TRAILER3=(27,02,
COUNT,
TOT=(11,09,SFF,EDIT=(STTTTTTTTT),SIGNS=(+,-))))
|
Change the positions as per your need
o/p looks like
|
|
Back to top |
|
|
kalyan.v
New User
Joined: 04 Feb 2008 Posts: 65 Location: Hyd
|
|
|
|
Hi krisprems,
Thanks for ur suggestion.It is working fine.
Thanks,
Kranthi V |
|
Back to top |
|
|
|
|