# how to get number of records of an adabas file using natural

**URL:** <https://techcommunity.softwareag.com/t/how-to-get-number-of-records-of-an-adabas-file-using-natural/60458>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [January 23, 2006, 3:12am UTC](https://techcommunity.softwareag.com/t/how-to-get-number-of-records-of-an-adabas-file-using-natural/60458 "2006-01-23T03:12:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hakan](https://avatars.discourse-cdn.com/v4/letter/h/f1d935/32.png) [@hakan](https://techcommunity.softwareag.com/u/hakan)\
**Post date:** [January 23, 2006, 3:12am UTC](https://techcommunity.softwareag.com/t/how-to-get-number-of-records-of-an-adabas-file-using-natural/60458/1 "2006-01-23T03:12:48Z")

</div>

how to get number of records of an adabas file using natural or direct call??

---

<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:** [January 23, 2006, 1:51pm UTC](https://techcommunity.softwareag.com/t/how-to-get-number-of-records-of-an-adabas-file-using-natural/60458/2 "2006-01-23T13:51:12Z")

</div>

You could issue a FIND NUMBER specifying a search-range including all records.

But beware, for large files that’ll be expensive.

---

<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:** [January 23, 2006, 3:05pm UTC](https://techcommunity.softwareag.com/t/how-to-get-number-of-records-of-an-adabas-file-using-natural/60458/3 "2006-01-23T15:05:51Z")

</div>

There’s more than one way to do it:

The fist way is like Wolfgang Winter said: A FIND NUMBER including all records. But maybe you won’t get all records because of NULL-Value supression in the descriptor.

Another way is:

- Use an empty view (i.e. with no fields) for the regarding file.
- make a read physical.
- use the internal field \*COUNTER after the read.

Advantages:  
 → should always work (even if no suitable descriptor is available)  
 → uses less memory (doesn’t create ISN-Lists like FIND NUMBER)  
Disadvantages:  
 → can be very time consuming  
 → Maybe makes many I/Os to disk

Here’s an example:

```auto
define data local
*
01 view1 view of ddm_name
*
end-define
*
label-view1.
read view1
end-read
display *COUNTER(label-view1.)
* 
end
```

Maybe there’s a third way if you got a special Descriptor with less possilbe values. A good example is a logical field with two possible values (TRUE OR FALSE):

```auto
define data local
*
01 view2 view of ddm_name
  02 yes_no_field (L)
*
end-define
*
label-view2.
histogram view2 for yes_no_field
  #sum := #sum + *NUMBER(label-view2.)
end-histogram
display #sum
* 
end
```

---

<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/how-to-get-number-of-records-of-an-adabas-file-using-natural/60458/4 "2021-04-02T14:40:25Z")

</div>


