# check the type of value in a field

**URL:** <https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-News-and-General-Topics\
**Created:** [May 23, 2013, 12:31pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243 "2013-05-23T12:31:14Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph\_Tharakan](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joseph\_Tharakan](https://techcommunity.softwareag.com/u/Joseph_Tharakan)\
**Post date:** [May 23, 2013, 12:31pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/1 "2013-05-23T12:31:14Z")

</div>

I have a probelm. In a field in an Adabas file which is defined as aplha numeric I have both numerical data and alphanumeric one for different records. I need to get those records having only alphanumeric data in this field Can anyone help me out? IS there any predefined function to check this like ISNUMERIC() in COBOL

---

<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:** [May 23, 2013, 12:58pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/2 "2013-05-23T12:58:29Z")

</div>

No.

KNOW THY DATA.

Ask those who put’ in mixed content for the rule they applied, I assume this didn’t happen randomly.

---

<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:** [May 23, 2013, 1:03pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/3 "2013-05-23T13:03:15Z")

</div>

But, in COBOL terms, if you are talking about DISPLAY type data, and not COMP or COMP-3,  
then Natural has

```auto
IF ... IS (format)
```

---

<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:** [May 23, 2013, 1:12pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/4 "2013-05-23T13:12:31Z")

</div>

Depending on what you are trying to do (eliminate numerics, identify records with numeric, identify which characters are wrong, etc) you might also have a look at IF field = MASK (…)

MASK possibilities include A (for upper and lower case alpha) N (for numeric digits) and I believe L (lower alpha) and U (upper alpha) (check on the last two, I am working from memory)

---

<div class="post-metadata">

**Author:** ![Joseph\_Tharakan](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joseph\_Tharakan](https://techcommunity.softwareag.com/u/Joseph_Tharakan)\
**Post date:** [May 23, 2013, 2:11pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/5 "2013-05-23T14:11:20Z")

</div>

Hi Wolfgang ,

01.IF … IS (N3)

Is this used to check whether a variable has a value of type ‘N3’ ? or whether the variable is defined in the type ‘N3’

---

<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:** [May 23, 2013, 2:47pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/6 "2013-05-23T14:47:49Z")

</div>

> [@Joseph Tharakan](#):
>
> Is this used to check whether a variable has a value of type ‘N3’ ? or whether the variable is defined in the type ‘N3’

IS can be used to check if data in an A field can be converted to the target type.

As always … [It’s in the documentation](http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat823mf/pg/pg_furth_lcc.htm#IS_Option_CFLV)

---

<div class="post-metadata">

**Author:** ![Joseph\_Tharakan](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joseph\_Tharakan](https://techcommunity.softwareag.com/u/Joseph_Tharakan)\
**Post date:** [May 23, 2013, 3:04pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/7 "2013-05-23T15:04:46Z")

</div>

Thanks Wolfgang Winter for the help

---

<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:** [May 23, 2013, 4:31pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/8 "2013-05-23T16:31:52Z")

</div>

If there is more to it than a simple numeric / not numeric decision then you’ll have  
to look at MASK as pointed out by Steve Robinson.

---

<div class="post-metadata">

**Author:** ![sajith\_kumar](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@sajith\_kumar](https://techcommunity.softwareag.com/u/sajith_kumar)\
**Post date:** [October 31, 2014, 2:39pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/9 "2014-10-31T14:39:48Z")

</div>

could you tell me the difference between IS (N9) ans MASK (99999)

regards

---

<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 1, 2014, 11:35am UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/10 "2014-11-01T11:35:51Z")

</div>

The difference is quite simple.

First, I presume you meant to compare IS (N9) and = MASK (999999999)

Let’s start with IS (N9). This checks to see if the contents of the alpha field can be “converted” by the VAL function into an N9 variable.

By contrast, = MASK (999999999) checks to see if the alpha field contains a string of digits between 000000000 and 999999999.

Here is a program that shows the main scenarios you might need to understand

DEFINE DATA LOCAL  
1 #A (A9)  
1 #N (N9)  
END-DEFINE  
\*  
INCLUDE AATITLER  
INCLUDE AASETC  
\*  
MOVE ‘123456789’ TO #A  
WRITE 10T ‘\*\*\*\*\* TESTS FOR MOVE ‘‘123456789’’ TO #A _**’  
IF #A = MASK (999999999)  
WRITE 10T ‘#A = MASK (999999999) IS TRUE’  
ELSE  
WRITE 10T ‘#A = MASK (999999999) IS FALSE’  
END-IF  
IF #A IS (N9)  
WRITE 10T ‘#A IS (N9) IS TRUE’  
ELSE  
WRITE 10T ‘#A IS (N9) IS FALSE’  
END-IF  
COMPUTE #N = VAL (#A)  
WRITE 10T ‘VAL (#A) IS’ #N  
\*  
SKIP 1  
MOVE ‘123’ TO #A  
WRITE 10T ’ **_ TESTS FOR MOVE ‘‘123’’ TO #A _** ’  
IF #A = MASK (999999999)  
WRITE 10T ‘#A = MASK (999999999) IS TRUE’  
ELSE  
WRITE 10T ‘#A = MASK (999999999) IS FALSE’  
END-IF  
IF #A IS (N9)  
WRITE 10T ‘#A IS (N9) IS TRUE’  
ELSE  
WRITE 10T ‘#A IS (N9) IS FALSE’  
END-IF  
COMPUTE #N = VAL (#A)  
WRITE 10T ‘VAL (#A) IS’ #N  
\*  
SKIP 1  
MOVE ’ 123’ TO #A  
WRITE 10T ’ **_ TESTS FOR MOVE ‘’ 123’’ TO #A _** ’  
IF #A = MASK (999999999)  
WRITE 10T ‘#A = MASK (999999999) IS TRUE’  
ELSE  
WRITE 10T ‘#A = MASK (999999999) IS FALSE’  
END-IF  
IF #A IS (N9)  
WRITE 10T ‘#A IS (N9) IS TRUE’  
ELSE  
WRITE 10T ‘#A IS (N9) IS FALSE’  
END-IF  
COMPUTE #N = VAL (#A)  
WRITE 10T ‘VAL (#A) IS’ #N  
\*  
SKIP 1  
MOVE ‘-123’ TO #A  
WRITE 10T ’ **_ TESTS FOR MOVE ‘’-123’’ TO #A _** ’  
IF #A = MASK (999999999)  
WRITE 10T ‘#A = MASK (999999999) IS TRUE’  
ELSE  
WRITE 10T ‘#A = MASK (999999999) IS FALSE’  
END-IF  
IF #A IS (N9)  
WRITE 10T ‘#A IS (N9) IS TRUE’  
ELSE  
WRITE 10T ‘#A IS (N9) IS FALSE’  
END-IF  
COMPUTE #N = VAL (#A)  
WRITE 10T ‘VAL (#A) IS’ #N  
\*  
SKIP 4  
MOVE ‘12.3’ TO #A  
WRITE 10T ’**_ TESTS FOR MOVE ‘‘12.3’’ TO #A \*\*\*\*\*’  
IF #A = MASK (999999999)  
WRITE 10T ‘#A = MASK (999999999) IS TRUE’  
ELSE  
WRITE 10T ‘#A = MASK (999999999) IS FALSE’  
END-IF  
IF #A IS (N9)  
WRITE 10T ‘#A IS (N9) IS TRUE’  
ELSE  
WRITE 10T ‘#A IS (N9) IS FALSE’  
END-IF  
COMPUTE #N = VAL (#A)  
WRITE 10T ‘VAL (#A) IS’ #N  
END

```
PAGE # 1 DATE: 14-11-01
PROGRAM: MASKIS01 LIBRARY: INSIDE

     *****TESTS FOR MOVE '123456789' TO #A*****
     #A = MASK (999999999) IS TRUE
     #A IS (N9) IS TRUE
     VAL (#A) IS 123456789

     *****TESTS FOR MOVE '123' TO #A*****
     #A = MASK (999999999) IS FALSE
     #A IS (N9) IS TRUE
     VAL (#A) IS 123

     *****TESTS FOR MOVE ' 123' TO #A*****
     #A = MASK (999999999) IS FALSE
     #A IS (N9) IS TRUE
     VAL (#A) IS 123

     *****TESTS FOR MOVE '-123' TO #A*****
     #A = MASK (999999999) IS FALSE
     #A IS (N9) IS TRUE
     VAL (#A) IS -123

PAGE # 2 DATE: 14-11-01
PROGRAM: MASKIS01 LIBRARY: INSIDE

     *****TESTS FOR MOVE '12.3' TO #A*****
     #A = MASK (999999999) IS FALSE
     #A IS (N9) IS TRUE
     VAL (#A) IS 12

```

Note that blanks (leading and trailing) , decimal points, and minus (also plus) signs make the MASK test FALSE. By contrast all the IS tests above are TRUE.

ALL of the aspects of IS and MASK are well documented in Natural’s online help. If you do not have access to this documentation you should demand same from the company you work for.

---

<div class="post-metadata">

**Author:** ![sajith\_kumar](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@sajith\_kumar](https://techcommunity.softwareag.com/u/sajith_kumar)\
**Post date:** [November 3, 2014, 8:06am UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/11 "2014-11-03T08:06:45Z")

</div>

Thanks Steve,

---

<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:28pm UTC](https://techcommunity.softwareag.com/t/check-the-type-of-value-in-a-field/171243/12 "2021-04-02T15:28:52Z")

</div>


