10-16-2009 11:48 AM
Hi Gurus
I'm trying to create a very simple report to display table descriptions and their DB number of records:
Ex:
MARA 50000
MARD 123000
... .....
I can't compile this piece of code:
field-symbols: <table>.
assign (DD02T-TABNAME) to <table>.
clear n.
*SELECT COUNT( * )*
INTO n
FROM <table>.
The problem here is that <table> is not defined in the ABAP dictionary as a a table , projection view or databse view.
1. Is there a way of defining <table> with a field-symbol data statement to make it work?
2. Alternatively, how can you produce a list of all table DB entry counts for a dynamic list of transparent tables?
Thanks
Nuno
10-16-2009 12:14 PM
With the code you have field symbol will "point" to a table contained in DD02T-TABNAME , not its name.
What you need is to get the table name , not table itself
field-symbols: <table_name>.
assign DD02T-TABNAME to <table>. "get table name, not its content
clear n.
SELECT COUNT( * )
INTO n
FROM (<table>).
or simply without field symbol
SELECT COUNT( * )
INTO n
FROM (DD02T-TABNAME).
Regards
Marcin
10-16-2009 11:56 AM
Hi,
Try using
Field-symbols : <table> type any
Hope this will serve your purpose.
Cheers and Happy Diwali.
Regards
Ram
10-16-2009 11:58 AM
Hello,
Try this
PARAMETERS P_TABLE TYPE DD02T-TABNAME.
DATA N TYPE I.
select COUNT(*)
FROM (P_TABLE)
into N.
WRITE N.Regards
10-16-2009 11:59 AM
Not sure what you are trying to do here exactly but in this case you will need to put <table> in between '( )' , like this:
FROM (<table>).
10-16-2009 12:07 PM
Hi,
Please try the following code,
FIELD-SYMBOLS <table> TYPE ANY.
DATA: li_table TYPE TABLE OF ddcdim,
lw_table TYPE ddcdim.
assign (DD02T-TABNAME) to <table>.
lw_table-tabname = <table>.
APPEND lw_table TO li_table.
CALL FUNCTION 'EM_GET_NUMBER_OF_ENTRIES'
TABLES
it_tables = li_table.
After the FM call, li_table will give you the number of records.
Regards,
Nilesh.
10-16-2009 12:14 PM
With the code you have field symbol will "point" to a table contained in DD02T-TABNAME , not its name.
What you need is to get the table name , not table itself
field-symbols: <table_name>.
assign DD02T-TABNAME to <table>. "get table name, not its content
clear n.
SELECT COUNT( * )
INTO n
FROM (<table>).
or simply without field symbol
SELECT COUNT( * )
INTO n
FROM (DD02T-TABNAME).
Regards
Marcin
10-16-2009 12:42 PM
You cannot fulfill your requirment with the approach you have followed
Follow the below sample code.
field-symbols : <fs_sflight> type TABLE .
data : tablename type string.
PARAMETERS : TABNAME TYPE CHAR8.
tablename = TABNAME.
CONDENSE tablename.
DATA: dref TYPE REF TO data.
CREATE DATA dref TYPE table of (TABNAME).
assign dref->* to <fs_sflight>.
SELECT * FROM (TABNAME) INTO TABLE <fs_sflight>.Thanks & Regards,
Murthy.
10-16-2009 1:06 PM
TYPE ANY TABLE
TYPE STANDARD TABLE
TYPE INDEX TABLE
TYPE SORTED TABLE
TYPE HASHED TABLE
not
TYPE ANY.
matt
10-17-2009 1:48 PM