Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Count rows in table with condition using build in BAPI

daphneo
Explorer
0 Likes
1,498

Hi

Is it possible to count the number of rows in a filtered table using a build-in FM or BAPI call?

EM_GET_NUMBER_OF_ENTRIES seems to only count total rows in table, but I would like to count, for example, the records in USR02 where GLTGV > '2020-01-01'.

It is possible when working in SE16n by pressing F7, and I'm hoping to do the same but by calling a standard FM or BAPI (without downloading all rows in the table)

Hi

Is it possible to count the number of rows in a filtered table using a build-in FM or BAPI call?

EM_GET_NUMBER_OF_ENTRIES seems to only count total rows in table, but I would like to count, for example, the records in USR02 where GLTGV > '2020-01-01'.

It is possible when working in SE16n by pressing F7, and I'm hoping to do the same but by calling a standard FM or BAPI (without downloading all rows in the table)

3 REPLIES 3
Read only

ashiqali_ratnani
Explorer
0 Likes
1,323

The FM you listed above itself uses a Select Count statement.

Since you need to have a custom filter condition, you will mostly have to write your own Select Count query to get the required count.

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,323

Can't you use SQL?

SELECT COUNT(*) FROM USR02 WHERE GLTGV > '20200101' INTO @DATA(counter).
Read only

daphneo
Explorer
0 Likes
1,323

I need to use a RFC Enabled BAPI or FM as the call will come from an external system. I.e. can't do ABAP. Thanks!