The functionality exist in the menu.
Edit -> Calculate -> Count
If you find out grey out then you just need to specify a column to make the count, you could use an existing one or create a new one
gt_alv-count = '1'.
Then in the layout use this field (COUNTFNAME) new the new field COUNT or any other. You dont need to add the COUNT field to your catalog.
layout-countfname = 'COUNT'.
If you needed in a button just add one to your toolbar with this function code &COUNT
Regards