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: 

Select Query

Former Member
0 Kudos

Hi Freinds,

I have a small doubt.

What I am doing is....I have a custom table,which will contain entries this way.

<u>CONDITION</u> <u>TABLE NAME</u>

A MARA

B VBAK

C EKKO

So,based on the condition I need to fire a Select Query on the respective table.

I am doing the selection in a subroutine.

Now,I am Selecting from v_tabname...v_tabname contains table name.

But,this is an error, coz Select query always allows to select from DB table.

Is there any way to dynamically get the table name in Select Query.

Any Object Programming ?

Eg., SELECT FROM <u>TABNAME</u>

Regards,

Imran.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

U can refer these links:

<u>http://www.sap-img.com/abap/how-can-we-give-dynamic-table-name-in-select-statement.htm</u>

<u>http://help.sap.com/saphelp_nw2004s/helpdata/en/67/93b80914a911d2953c0000e8353423/content.htm</u>

Thanks

Vasudha

2 REPLIES 2

varma_narayana
Active Contributor
0 Kudos

hi.

sample code:

REPORT ZSEL_BGJOB.

DATA : REF_TAB TYPE REF TO DATA.

FIELD-SYMBOLS: <FTAB> TYPE TABLE.

DATA: L_TABNAME TYPE DD02L-TABNAME VALUE 'EKPO'.

CREATE DATA REF_TAB TYPE TABLE OF (L_TABNAME).

ASSIGN REF_TAB->* TO <FTAB>.

SELECT * FROM (L_TABNAME) INTO TABLE <FTAB>.

DESCRIBE TABLE <FTAB>.

WRITE:/ SY-TFILL.

Reward if Helpful.

Former Member
0 Kudos

Hi

U can refer these links:

<u>http://www.sap-img.com/abap/how-can-we-give-dynamic-table-name-in-select-statement.htm</u>

<u>http://help.sap.com/saphelp_nw2004s/helpdata/en/67/93b80914a911d2953c0000e8353423/content.htm</u>

Thanks

Vasudha