View previous topic :: View next topic
|
Author |
Message |
satya12
New User
Joined: 25 Apr 2006 Posts: 32 Location: India
|
|
|
|
Hi
I am trying to sum fields on ZD and my file has some records with negative values.Looks like DFOSRT is not recogizing the negative sign which adding the amounts.
Code: |
//SORT02 EXEC PGM=SORT
//*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1 200703 -55246
1 200703 -11516
1 200703 -55165
1 200703 -2715081
1 200703 -964
1 200703-17809223
1 200703 10
2 200703 24
2 200703 20
2 200703 10
/*
//SORTOUT DD SYSOUT=*
//*
//SYSIN DD *
SORT FIELDS=(1,1,CH,A)
OUTREC FIELDS=(1,1,C';',10,9,ZD,EDIT=(STTTTTTTTT),SIGNS=(,-))
SUM FIELDS=(10,9,ZD)
/*
|
output
Code: |
1; 020647205
2; 000000054
|
Is there any option in DFSORT to recoginze the sign?
Any hekp is appreciated.
Thanks
Satya |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
satya,
Try SFF (Signed free format) in place of ZD. |
|
Back to top |
|
|
satya12
New User
Joined: 25 Apr 2006 Posts: 32 Location: India
|
|
|
|
I don't think we can use SFF in sum fields option.
I tried n getting an error message saying invalid format.
I tried another option of conveting ZP to PD and then sum up the PD field.But no luck. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Satya,
Quote: |
I don't think we can use SFF in sum fields option. |
You are correct. Sorry for the wrong suggestion.
Try using TRAILERn with SECTIONS option. |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Satya,
DFSORT recognizes negative signs for ZD values just fine. But your values are NOT ZD values.
A 9-byte negative ZD value would look like this:
X'FdFdFdFdFdFdFdFdDd'
whereas your values have a leading floating sign and leading zeros suppressed. Actually, your values are FS values, not ZD values.
You can't use FS for SUM, but you can do what you want using OUTFIL SECTIONS instead of SUM. Here's a DFSORT job that will do what you want:
Code: |
//SORT02 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1 200703 -55246
1 200703 -11516
1 200703 -55165
1 200703 -2715081
1 200703 -964
1 200703-17809223
1 200703 10
2 200703 24
2 200703 20
2 200703 10
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,1,CH,A)
OUTFIL REMOVECC,NODETAIL,
BUILD=(12X),
SECTIONS=(1,1,
TRAILER3=(1,1,C';',TOT=(10,9,FS,EDIT=(STTTTTTTTT),SIGNS=(,-))))
/*
|
For your example, SORTOUT will have:
Code: |
1;-020647185
2; 000000054
|
|
|
Back to top |
|
|
satya12
New User
Joined: 25 Apr 2006 Posts: 32 Location: India
|
|
|
|
Yup
Both SFF and FS worked when i tried them in the trailer section with TOT option.
Thanks a lot guys
Have a greta weekend. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Yes, both work, but less processing is required for FS than SFF, so in general FS is more efficient than SFF. FS is the better choice for values like
-123456789
whereas SFF is required for values like
-1,234,567.89
for which FS cannot be used. |
|
Back to top |
|
|
|