11-11-2008 11:52 AM
Hi all,
How can I get the number of entries of the database table residing in the SAP database programmatically.
regards
samarendra
11-11-2008 12:01 PM
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
11-11-2008 11:56 AM
Hi,
Use Count(*) addition in Select to get total number of records.
Thanks & Regards,
Navneeth K.
11-11-2008 11:59 AM
Dear Navneeth,
Can i use any function module in this regard.
regards
samarendra
11-11-2008 12:02 PM
Sorry i dont think so there is any function module, I suggest you to use select statement, since its a very easy approach.
11-11-2008 12:04 PM
11-11-2008 11:58 AM
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
11-11-2008 11:58 AM
11-11-2008 11:59 AM
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
11-11-2008 11:59 AM
Hi
Select * from <DBTABLE> into <ITAB>.
describe table <ITAB> lines lin.
regards
Kumar M
11-11-2008 11:59 AM
11-11-2008 12:01 PM
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
11-11-2008 12:05 PM
Hi,
Thankyou for the FM.
Can i get the table in which the details of the database table gets stored.
regards
samarendra
11-11-2008 12:13 PM
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
11-11-2008 12:07 PM
11-11-2008 12:12 PM
Hi,
1) Table DD02L: SAP tables with the Activation status .
2) Table TADIR: Give the Object type as TABL.
Regards,
Swati