View previous topic :: View next topic
|
Author |
Message |
sureshreddy24
New User
Joined: 29 May 2009 Posts: 3 Location: hyderabad
|
|
|
|
hi,
I have a flat file in whice amount filed id there. in amount field it have '-' sign.
ex:
-.1.20
-22.56
-123.11
-0.12
12.23
123.23
How can I get the addition of this all the amounts. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Have you looked at SFF? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use a DFSORT job like the following to do what you asked for:
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
-1.20
-22.56
-123.11
-0.12
12.23
123.23
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=(TOT=(1,7,SFF,EDIT=(SIIIT.TT),SIGNS=(,-)))
/*
|
|
|
Back to top |
|
|
anshul_gugnani
New User
Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hello Frank,
I tried to test the above sort card as
Code: |
//STEP010 EXEC PGM=SORT
//*
//SYSOUT DD SYSOUT=*
//*
//SORTIN DD *
-10.00
20.00
-30.00
10.00
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC, NODETAIL
TRAILER1=(TOT=(1,6,SFF,EDIT=(SIIT.TT),SIGNS=(-,+)))
//*
|
The result I got is +10.00
However, I think it should be -10.00.
Can you please guide where am I going wrong?
Thanks |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Look very very carefully at the code that you have used and the code supplied by Frank. Especially SIGNS=
I have tried Franks code with your data and get the expected result. |
|
Back to top |
|
|
anshul_gugnani
New User
Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Thanks Expat for correcting me.
Got the correct result. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
To clarify:
Quote: |
The result I got is +10.00
However, I think it should be -10.00.
Can you please guide where am I going wrong?
|
SIGNS=(,-)
indicates a blank for the leading positive sign and a - for the leading negative sign.
SIGNS=(-,+)
indicates a - for the leading positive sign and a + for the leading negative sign - certainly NOT what you want.
SIGNS=(+,-)
indicates a + for the leading positive sign and a - for the leading negative sign - perhaps that's what you want? |
|
Back to top |
|
|
anshul_gugnani
New User
Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hello Frank,
Didnt knew that first symbol will be considered for the positive and next for the negetive.
Thanks a ton for the information.
Thanks,
Anshul. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Yes, the complete syntax for SIGNS is like this:
SIGNS=(lp,ln,tp,tn)
lp = leading positive sign
ln = leading negative sign
tp = trailing positive sign
tn = trailing negative sign
A "silly" example:
EDITS=(STTTS),SIGNS=(+,-,+,-)
If you leave out a sign, a blank is used, for example:
SIGNS=(,-) |
|
Back to top |
|
|
anshul_gugnani
New User
Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hi Frank,
Thanks a lot. This helps a lot. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Glad I could help.
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080 |
|
Back to top |
|
|
|