View previous topic :: View next topic
|
Author |
Message |
hemanthboga
New User
Joined: 15 May 2008 Posts: 1 Location: bangalore
|
|
|
|
Hi,
I need to read an amount filed x(12) field from a flat file and move it into s9(9)v99 format. My client is preparing the flat file with decimal point and sign, we dont have any other option but to receiving it into X(12) field. I had made a work aroung using redifines clause, which was working fine with +ve sign. If the amount have -Ve sign my program is abending.
For ex: if value is -90000.90 in x(12) filed, how can I move this to
S9(9)v99 field. I am having issues with handling the sign.
Thanks a lot for you help.
Heman. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Code: |
in-field pic -999999999.99.
out-field pic s9(9)v99.
move in-field to out-field. |
That will work with most current versions of COBOL. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
COMPUTE NUMERICVARIABLE = FUNCTION NUMVAL (XVARIABLE) . |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Here's something to consider:
If you have 9 significant digits before the decimal point for any value occurence for the field, you will truncate the the sign. Not a prob if the sign is pos; bad if it's neg.
If your I/P fld only contains 8 integer digits you can change the O/P fld to S9(8)V99 when using NUMVAL. |
|
Back to top |
|
|
Max Payne
New User
Joined: 13 Dec 2007 Posts: 10 Location: Shanghai
|
|
|
|
-90000.90 in x(12)
you mean BBB-90000.90 or -90000.90BBB? |
|
Back to top |
|
|
star_dhruv2000
New User
Joined: 03 Nov 2006 Posts: 87 Location: Plymouth, MN USA
|
|
|
|
NUMVAL is right choice for you...
Appreciate ur effort Robert...
Cheers!
Happy coding |
|
Back to top |
|
|
ssk1711
New User
Joined: 16 Jun 2008 Posts: 40 Location: bangalore
|
|
|
|
Robert Sample wrote: |
COMPUTE NUMERICVARIABLE = FUNCTION NUMVAL (XVARIABLE) . |
This will meet the requirement. |
|
Back to top |
|
|
|