Page 1 of 1

Conversion from alhanumeric to numeric

PostPosted: Mon Mar 29, 2010 7:08 pm
by diptisaini
Hi,

I am having a field on map #mo-discount-rate (a7) but that field is store in database store as cdiscount-rate ( N4.3). Suppose if i am entering #mo-discount-rate = 1.22 then my requirement is that it will show same value on #mo-discount-rate

is there anyway to do this ? Please let me know as soon as possible.

Thanks.

Re: Conversion from alhanumeric to numeric

PostPosted: Mon Mar 29, 2010 8:25 pm
by Robert Sample
Are you trying to say the field on the map is 7 alphanumeric characters but it is stored in the data base as numeric with 4 digits before the decimal and 3 after? Is this CICS or something else? What are you getting now that doesn't match your requirements? Which language is your program in?

There are ways to do what I think you want, but without more information we can't really provide much assistance.

Re: Conversion from alhanumeric to numeric

PostPosted: Mon Mar 29, 2010 10:00 pm
by diptisaini
Hi,

Sorry for incomplete information.
I am using language as Natural and database as Adabas.
The field on the map is 7 alphanumeric characters but it is stored in the data base as numeric with 4 digits before the decimal and 3 after
decimal this is my requirment.

Re: Conversion from alhanumeric to numeric

PostPosted: Tue Mar 30, 2010 7:25 pm
by RGZbrog
Here's the basic code:
DEFINE DATA LOCAL
1 #ALPHA (A7)
1 #NUM (N4.3)
END-DEFINE
REPEAT
  INPUT #ALPHA (AD=MDL'_')
  IF   #ALPHA IS (N4.3)
   AND #ALPHA <> ' '
    THEN
      ASSIGN #NUM = VAL (#ALPHA)
      DISPLAY #ALPHA #NUM
    ELSE
      REINPUT 'invalid format or value'
  END-IF
END-REPEAT
END

You use the IS clause to test for valid numeric and the VAL function for the conversion.

Re: Conversion from alhanumeric to numeric

PostPosted: Thu Apr 08, 2010 3:46 pm
by diptisaini
Thanks, I used the same concept and now my code is working fine.