# Validations with MASK

**URL:** <https://techcommunity.softwareag.com/t/validations-with-mask/76517>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [April 9, 2008, 4:31am UTC](https://techcommunity.softwareag.com/t/validations-with-mask/76517 "2008-04-09T04:31:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabian](https://avatars.discourse-cdn.com/v4/letter/f/f6c823/32.png) [@Fabian](https://techcommunity.softwareag.com/u/Fabian)\
**Post date:** [April 9, 2008, 4:31am UTC](https://techcommunity.softwareag.com/t/validations-with-mask/76517/1 "2008-04-09T04:31:16Z")

</div>

Hi,  
I must validate a field A4, that contains the hour in format Hour(2) Minute(2) HHMM. As MM is interpreted as Month, I used  
IF NOT

---

<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:** [April 9, 2008, 10:15am UTC](https://techcommunity.softwareag.com/t/validations-with-mask/76517/2 "2008-04-09T10:15:55Z")

</div>

In a MASK clause, an H represents a hexadecimal digit, not an hour; there is no character to represent a minute.

For the hour value, test for 0-23. For the minute value, test for 0-59.

```auto
DEFINE DATA LOCAL  
1 #A (A4) INIT <'1230'>  
1 #T (T)  
1 #M (A25)  
END-DEFINE  
*  
REPEAT  
  INPUT #A (AD=MDLT)  
     // #T (AD=O ZP=F)  
     // #M (AD=O)  
  IF #A = MASK (00-23)  
   AND #A = MASK (..00-59)  
    THEN  
      MOVE EDITED #A TO #T (EM=HHII)  
      RESET #M  
    ELSE  
    ASSIGN #M = 'invalid time value'  
    RESET #T  
  END-IF  
END-REPEAT  
END
```

[url][http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat424mf/pg/pg\_furth\_lcc.htm#Mask\_Characters[/url]](http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat424mf/pg/pg_furth_lcc.htm#Mask_Characters%5B/url%5D)

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [April 9, 2008, 2:40pm UTC](https://techcommunity.softwareag.com/t/validations-with-mask/76517/3 "2008-04-09T14:40:53Z")

</div>

You can also use

```auto
 IF #A = MASK (00-2300-59) ... 
```

---

<div class="post-metadata">

**Author:** ![Fabian](https://avatars.discourse-cdn.com/v4/letter/f/f6c823/32.png) [@Fabian](https://techcommunity.softwareag.com/u/Fabian)\
**Post date:** [April 9, 2008, 6:27pm UTC](https://techcommunity.softwareag.com/t/validations-with-mask/76517/4 "2008-04-09T18:27:11Z")

</div>

Ralph/ Wilfried:  
Thank you very much for your comments. Both them were pretty useful for me, included the link to the documentation.  
Regards, Fabi

---

<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, 2:49pm UTC](https://techcommunity.softwareag.com/t/validations-with-mask/76517/5 "2021-04-02T14:49:20Z")

</div>


