# Calculate field length

**URL:** <https://techcommunity.softwareag.com/t/calculate-field-length/90327>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [June 3, 2009, 4:57pm UTC](https://techcommunity.softwareag.com/t/calculate-field-length/90327 "2009-06-03T16:57:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hezi](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@Hezi](https://techcommunity.softwareag.com/u/Hezi)\
**Post date:** [June 3, 2009, 4:57pm UTC](https://techcommunity.softwareag.com/t/calculate-field-length/90327/1 "2009-06-03T16:57:16Z")

</div>

Hi,

In a local : 1 a (a80)  
in my program I want to keep the size of a: b=80.  
Is there a way to calculate the length (a as a redefition)?

---

<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:** [June 3, 2009, 5:20pm UTC](https://techcommunity.softwareag.com/t/calculate-field-length/90327/2 "2009-06-03T17:20:27Z")

</div>

If I understand you correctly, you can use the following code:

```auto
define data local
1 #dyn (A) dynamic
1 #a (A80)
end-define
#dyn := #a
write 'length of #a in byte:' *LENGTH(#dyn)
end
```

---

<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:** [June 3, 2009, 8:40pm UTC](https://techcommunity.softwareag.com/t/calculate-field-length/90327/3 "2009-06-03T20:40:02Z")

</div>

if you are just looking for the length of the text in the fixed length field (Matthias’ example will always return “80” as the length), then take a look at the EXAMINE statement with the GIVING LENGTH clause.

EXAMINE #a FOR ’ ’ GIVING LENGTH #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:57pm UTC](https://techcommunity.softwareag.com/t/calculate-field-length/90327/4 "2021-04-02T14:57:06Z")

</div>


