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

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

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

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

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:

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):

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