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: 

field-symbol definition for a variable representing transparent tables

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos

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

8 REPLIES 8

former_member1245113
Active Contributor
0 Kudos

Hi,

Try using

Field-symbols : <table> type any

Hope this will serve your purpose.

Cheers and Happy Diwali.

Regards

Ram

Former Member
0 Kudos

Hello,

Try this

PARAMETERS P_TABLE  TYPE DD02T-TABNAME.

DATA  N TYPE I.

select COUNT(*)
  FROM (P_TABLE)
  into  N.

WRITE N.

Regards

Sm1tje
Active Contributor
0 Kudos

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>).

Former Member
0 Kudos

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.

MarcinPciak
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

matt
Active Contributor
0 Kudos

TYPE ANY TABLE

TYPE STANDARD TABLE

TYPE INDEX TABLE

TYPE SORTED TABLE

TYPE HASHED TABLE

not

TYPE ANY.

matt

Former Member
0 Kudos

Thank you for helping solving this one out.

Take care

Nuno