Application Development 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: 

number of entries of a database table

Former Member
0 Kudos

Hi all,

How can I get the number of entries of the database table residing in the SAP database programmatically.

regards

samarendra

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

you can use:

1) Select count(*) from table and sy-dbcnt for number of records

2) USe Function Module 'TABLECOUNT'. Pass the table name and client

Regards,

Swati

14 REPLIES 14

Former Member
0 Kudos

Hi,

Use Count(*) addition in Select to get total number of records.

Thanks & Regards,

Navneeth K.

0 Kudos

Dear Navneeth,

Can i use any function module in this regard.

regards

samarendra

0 Kudos

Sorry i dont think so there is any function module, I suggest you to use select statement, since its a very easy approach.

0 Kudos

hi,

use this function module.

TABLECOUNT

Former Member
0 Kudos

Run this;

data lv_count type int4.
Select count(*) into lv_count from TFDIR.
Write : 'Total records :', lv_count.

Also the system field SY-DBCNT will be populated with the number of entries fetched by the select query so you can also use it instead of above write.

Write : 'Total records :', sy-dbcnt.

Hope this will solve your problem.

Regards

Karthik D

Former Member
0 Kudos

For example:

SELECT COUNT(*) FROM employees

Former Member
0 Kudos

Hi Samrendra,

You can calculate the total number of records like this. Just go through the following code snippet.

TABLES : ztable.

DATA cnt type I.

Select count( * ) into cnt FROM ztable.

write: cnt.

Thanks.

Nitesh

Former Member
0 Kudos

Hi

Select * from <DBTABLE> into <ITAB>.

describe table <ITAB> lines lin.

regards

Kumar M

rthoodi
Active Participant
0 Kudos

Hi,

select count( * ) from MARA into y_v_count.

Thanks

RK

Former Member
0 Kudos

Hi,

you can use:

1) Select count(*) from table and sy-dbcnt for number of records

2) USe Function Module 'TABLECOUNT'. Pass the table name and client

Regards,

Swati

0 Kudos

Hi,

Thankyou for the FM.

Can i get the table in which the details of the database table gets stored.

regards

samarendra

0 Kudos

DDIF_TABL_GET - u can get the table details

CALL FUNCTION 'DDIF_TABL_GET'

EXPORTING

NAME = TABLES-TABNAME

STATE = STATE

LANGU = LANGU

IMPORTING

GOTSTATE = GOTSTATE

DD02V_WA = DD02V

  • dd09l_wa = dd09l

TABLES

DD03P_TAB = DD03P_A

DD05M_TAB = DD05M_A

DD08V_TAB = DD08V_A

EXCEPTIONS

OTHERS = 1.

RSSDOCTB program - u can get the documentation of the fields in the table

Former Member
0 Kudos

Hi,

Use this FM CATT_GET_TABLE_ENTRIES

Thanks.

Nitesh

Former Member
0 Kudos

Hi,

1) Table DD02L: SAP tables with the Activation status .

2) Table TADIR: Give the Object type as TABL.

Regards,

Swati