Conversion from alhanumeric to numeric



Software AG's platform-independent programming language with full support for open-source and Internet applications

Conversion from alhanumeric to numeric

Postby diptisaini » Mon Mar 29, 2010 7:08 pm

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.
diptisaini
 
Posts: 90
Joined: Sun Mar 14, 2010 5:12 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Conversion from alhanumeric to numeric

Postby Robert Sample » Mon Mar 29, 2010 8:25 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Conversion from alhanumeric to numeric

Postby diptisaini » Mon Mar 29, 2010 10:00 pm

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.
diptisaini
 
Posts: 90
Joined: Sun Mar 14, 2010 5:12 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Conversion from alhanumeric to numeric

Postby RGZbrog » Tue Mar 30, 2010 7:25 pm

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.
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: Conversion from alhanumeric to numeric

Postby diptisaini » Thu Apr 08, 2010 3:46 pm

Thanks, I used the same concept and now my code is working fine.
diptisaini
 
Posts: 90
Joined: Sun Mar 14, 2010 5:12 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Natural

 


  • Related topics
    Replies
    Views
    Last post