# packed decimal

**URL:** <https://techcommunity.softwareag.com/t/packed-decimal/61629>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux\
**Created:** [October 27, 2006, 12:05pm UTC](https://techcommunity.softwareag.com/t/packed-decimal/61629 "2006-10-27T12:05:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![YSRR](https://avatars.discourse-cdn.com/v4/letter/y/74df32/32.png) [@YSRR](https://techcommunity.softwareag.com/u/YSRR)\
**Post date:** [October 27, 2006, 12:05pm UTC](https://techcommunity.softwareag.com/t/packed-decimal/61629/1 "2006-10-27T12:05:02Z")

</div>

hi

i want to do validation for packed decimal(p5,2).

iam using EM edit mask iam getting error

thanks in advance

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [October 27, 2006, 5:17pm UTC](https://techcommunity.softwareag.com/t/packed-decimal/61629/2 "2006-10-27T17:17:44Z")

</div>

The Natural Help says, that the following should work (but it’s not recommended):

```auto
define data local
01 #a4 (A4) init <H'1234567D'> /* packed -12345.67
01 redefine #a4
  02 #p5_2 (P5.2)
end-define
*
if #p5_2 = MASK (NNNZ)
  write 'packed'
else
  write 'not packed'
end-if
*
end
```

---

<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:** [October 30, 2006, 2:45pm UTC](https://techcommunity.softwareag.com/t/packed-decimal/61629/3 "2006-10-30T14:45:05Z")

</div>

It must be MASK(NNNNNNZ), as N checks a digit (not a byte), whereas Z checks a byte for a signed digit (so in total 4 bytes / 7 digits are checked). This check is the only way to check a packed value for a correct value and thus, of course, recommended. What is not recommended, is the redefinition of a alpha string, but in Natural we are used to do this.

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [November 1, 2006, 10:38pm UTC](https://techcommunity.softwareag.com/t/packed-decimal/61629/4 "2006-11-01T22:38:00Z")

</div>

[quote="Wilfried B

---

<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:40pm UTC](https://techcommunity.softwareag.com/t/packed-decimal/61629/5 "2021-04-02T14:40:55Z")

</div>


