View previous topic :: View next topic
|
Author |
Message |
callkris_cit
New User
Joined: 22 Apr 2006 Posts: 44
|
|
|
|
Hi All,
I have the below input file
1- 6 Indicates Name, 7 - 9 Indicates Amount
Sample input file:
RAMESH100
SURESH090
RAMESH999
SURESH090
I want to add the amounts if the names are equal. Hence i specified the below SORT card
SORT FIELDS=(1,6,CH,A)
SUM FIELDS=(7,3,ZD)
My output is:
RAMESH099 -> Incorrect because it should be RAMESH1099 ( In
this 1099 displayd as 099 )
SURESH180 -> Correct
Please let me know how to get the 1099 value for first record. Is there any option is there to get the correct value.
I need a output like below:
RAMESH1099
SURESH0180
Thanks in advance,
Suresh |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
The problem here is that your 3-digit values are overflowing the 3-digit field. You need to "fix" the overflow by using 4-digit values. Here's a DFSORT job that will do that:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/9)
//SORTOUT DD DSN=... output file (FB/10)
//SYSIN DD *
* Add '0' before 3-digit value to get 4-digit value.
INREC FIELDS=(1,6,C'0',7,3)
SORT FIELDS=(1,6,CH,A)
OPTION ZDPRINT
* Sum on 4-digit value.
SUM FIELDS=(7,4,ZD)
/*
|
|
|
Back to top |
|
|
callkris_cit
New User
Joined: 22 Apr 2006 Posts: 44
|
|
|
|
Thanks a lot
Regards,
Suresh |
|
Back to top |
|
|
|