View previous topic :: View next topic |
Author |
Message |
rasprasads Beginner
Joined: 10 Dec 2002 Posts: 59 Topics: 20 Location: Chennai
|
Posted: Fri Dec 20, 2002 1:15 am Post subject: Numeric edited conversions |
|
|
I have a S9(13)V99 filed.I should move it to a numeric edited field
such that the output would be like :
-$999,999,999,999.99(for value - 999999999999.99)
$0.00(for zero)
-$2.00(for -2)
-$12.50(for -12.5)
I tried -$$$,$$$,$$$,$$9.99.But i get output as:
- blanks $12.50
For me negative sign must be just before the $ sign...
Please help... _________________ Rasprasad S |
|
Back to top |
|
|
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Fri Dec 20, 2002 3:34 am Post subject: |
|
|
Why don't you try to do something like
-$zz,zz,zz,z9.99
Regards,
Manas |
|
Back to top |
|
|
Mike Tebb Beginner
Joined: 02 Dec 2002 Posts: 20 Topics: 0 Location: Yorkshire, England
|
Posted: Fri Dec 20, 2002 4:28 am Post subject: |
|
|
Manas,
that gives fixed editing of -$spaces9.99.
Although the requirement seemed simple, I don't think you can get that result with a simple edit mask.
You can have floating currency symbols (as shown by Rasprasads), or you can have floating minus signs, but I don't think you can have both. (someone may prove me wrong of course).
I would just code something like:
Code: |
03 WS-AMOUNT PIC S9(13)V99 VALUE.
03 WS-AMOUNT-EDITED PIC $$$$$$$$$$$$$9.99.
03 WS-INDEX PIC S9(4) BINARY VALUE 0.
MOVE WS-AMOUNT TO WS-AMOUNT-EDITED
IF WS-AMOUNT < 0 THEN
PERFORM VARYING WS-INDEX FROM 1 BY 1
UNTIL WS-INDEX > 17
IF WS-AMOUNT-EDITED(WS-INDEX:1) = '$' THEN
MOVE '-' TO WS-AMOUNT-EDITED(WS-INDEX - 1:1)
MOVE 18 TO WS-INDEX
END-IF
END-PERFORM
END-IF
|
_________________ Cheers - Mike
Last edited by Mike Tebb on Fri Dec 20, 2002 4:32 am; edited 1 time in total |
|
Back to top |
|
|
rasprasads Beginner
Joined: 10 Dec 2002 Posts: 59 Topics: 20 Location: Chennai
|
Posted: Fri Dec 20, 2002 4:31 am Post subject: |
|
|
Manas, Thanks for your help ...
I have tried your idea .It would give the following result:
-$ BLANKS 21,230.00
I need no spaces betwwen the $ and sign and as well as the amount...
Hope i would get a solution for this... _________________ Rasprasad S |
|
Back to top |
|
|
rasprasads Beginner
Joined: 10 Dec 2002 Posts: 59 Topics: 20 Location: Chennai
|
Posted: Fri Dec 20, 2002 4:41 am Post subject: |
|
|
Mike,
Thanks a lot.
Your solution is ok.It works fine.
But i have some 3 such fields for a single record.
I also should perform this for a huge amount of records(around 1 million).
I think if there is some other solution than going for code it would be better.
So please suggest me if any other solution is possible... _________________ Rasprasad S |
|
Back to top |
|
|
Mike Tebb Beginner
Joined: 02 Dec 2002 Posts: 20 Topics: 0 Location: Yorkshire, England
|
Posted: Fri Dec 20, 2002 4:51 am Post subject: |
|
|
I wouldn't worry about the performance implications.
Anyway does it HAVE to look like that.
Coding $$$$$$$$$$$$$9.99- would give you $123.45- _________________ Cheers - Mike |
|
Back to top |
|
|
|
|