converting char amount fileds to numeric



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

converting char amount fileds to numeric

Postby prasad75 » Tue Nov 01, 2011 7:02 pm

Hi,

I would like to convert to X(17) amount value to PIC S9(15)V9(02).

Amount value from input file is 12345.99

i need to convert it into PIC S9(15)V9(02).

Please advise.

thanks
prasad75
 
Posts: 3
Joined: Wed Oct 12, 2011 12:36 pm
Has thanked: 0 time
Been thanked: 0 time

Re: converting char amount fileds to numeric

Postby BillyBoyo » Tue Nov 01, 2011 8:45 pm

Have a look at the Cobol intrinsic function NUMVAL in the manuals.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: converting char amount fileds to numeric

Postby dick scherrer » Tue Nov 01, 2011 9:51 pm

Hello,

I would like to convert to X(17) amount value to PIC S9(15)V9(02).
Amount value from input file is 12345.99
I suspect one of these is in error. . . If there is a decimal point in the value, then the x(17) would be x(18) or the most significant digit would be truncated.

Will there always be 2 decimal places or might the number vary?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: converting char amount fileds to numeric

Postby prasad75 » Wed Nov 02, 2011 12:54 pm

good catch. yes, it is X(18). There will always be 2 decimal places.
prasad75
 
Posts: 3
Joined: Wed Oct 12, 2011 12:36 pm
Has thanked: 0 time
Been thanked: 0 time

Re: converting char amount fileds to numeric

Postby BillyBoyo » Wed Nov 02, 2011 1:04 pm

Is the number right-aligned? If yes, you can do it without NUMVAL, otherwise did you look into that?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post