# field character into field numeric

**URL:** <https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux\
**Created:** [November 6, 2012, 3:43pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706 "2012-11-06T15:43:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Claudio\_Muller](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/claudio_muller/32/518_2.png) [@Claudio\_Muller](https://techcommunity.softwareag.com/u/Claudio_Muller)\
**Post date:** [November 6, 2012, 3:43pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/1 "2012-11-06T15:43:38Z")

</div>

Hi,  
can i convert field character into field numeric?

I read: #text (a50)  
’ 12345’  
’ 4445565 ’  
'1234 ’

(have spaces after and before the numbers)

And i need to move only numeric into #numeric (n 8 ) ?

---

<div class="post-metadata">

**Author:** ![Douglas\_Kelly](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/douglas_kelly/32/102_2.png) [@Douglas\_Kelly](https://techcommunity.softwareag.com/u/Douglas_Kelly)\
**Post date:** [November 6, 2012, 4:10pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/2 "2012-11-06T16:10:47Z")

</div>

IF #text IS (N8)  
#num := VAL(#text)  
ElSE  
write #text “not a valid number”  
END-IF

---

<div class="post-metadata">

**Author:** ![Claudio\_Muller](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/claudio_muller/32/518_2.png) [@Claudio\_Muller](https://techcommunity.softwareag.com/u/Claudio_Muller)\
**Post date:** [November 6, 2012, 4:12pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/3 "2012-11-06T16:12:36Z")

</div>

Thanks.

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [November 6, 2012, 7:11pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/4 "2012-11-06T19:11:37Z")

</div>

Minor enhancement:

```auto
IF #TEXT IS (N8)
 AND #TEXT <> ' ' /* <--
  THEN 
    #NUM := VAL (#TEXT) 
  ELSE 
    WRITE #TEXT 'not a valid number' 
END-IF 
```

---

<div class="post-metadata">

**Author:** ![Todd\_Beckwith](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/todd_beckwith/32/388_2.png) [@Todd\_Beckwith](https://techcommunity.softwareag.com/u/Todd_Beckwith)\
**Post date:** [November 6, 2012, 7:57pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/5 "2012-11-06T19:57:10Z")

</div>

Ralph,

Why the check to make sure it isn’t blank? At least on HPUX, blank does not pass the “IS (N8)” test. Is the IS functionality not consistent on other platforms?

Thanks.

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [November 6, 2012, 9:40pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/6 "2012-11-06T21:40:25Z")

</div>

Hi Claudio;

Was just a bit curious re your question.

Do you want to extract all numeric strings from #text?

If so you would SEPARATE #text into #ARRAY (_) /_ a blank is one of the default delimiters

Then you could test the members of #array to see if they are numeric (as discussed in earlier posts).

steve

---

<div class="post-metadata">

**Author:** ![Claudio\_Muller](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/claudio_muller/32/518_2.png) [@Claudio\_Muller](https://techcommunity.softwareag.com/u/Claudio_Muller)\
**Post date:** [November 6, 2012, 11:57pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/7 "2012-11-06T23:57:26Z")

</div>

I dont use array with VAL…

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [November 7, 2012, 4:48pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/8 "2012-11-07T16:48:10Z")

</div>

I had presumed that the LUW behavior matched the mainframe, where the IS clause accepts a blank value but the VAL function does not. I’ll continue to use the additional test until Natural’s syntax is synchronized on the two platforms. Version 8, perhaps?

---

<div class="post-metadata">

**Author:** ![Todd\_Beckwith](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/todd_beckwith/32/388_2.png) [@Todd\_Beckwith](https://techcommunity.softwareag.com/u/Todd_Beckwith)\
**Post date:** [November 7, 2012, 5:45pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/9 "2012-11-07T17:45:16Z")

</div>

Good to know Ralph, in case I get canned here and have to find employment in a Mainframe shop. Thanks.

---

<div class="post-metadata">

**Author:** ![Nikolay\_Kuhta](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nikolay\_Kuhta](https://techcommunity.softwareag.com/u/Nikolay_Kuhta)\
**Post date:** [November 9, 2012, 5:16pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/10 "2012-11-09T17:16:19Z")

</div>

Hi guys,  
Just FYI I wanted to mention that Ralph was absolutely right:  
on Natural Version 8.2.2.3 (mainframe) blank is NOT (N whatever); apparently, you just need to upgrade your mainframe environment 🙂  
Best regards.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:02pm UTC](https://techcommunity.softwareag.com/t/field-character-into-field-numeric/101706/11 "2021-04-02T15:02:33Z")

</div>


