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: 

delcare table base on parameter field

Former Member
0 Kudos

Hi all

Is there a way to declare the table base on the parameter?

eg.

PARAMETER: p_tablen TYPE tabname.

data : it_st like table of <b>p_tablen</b> with header line.

thks

12 REPLIES 12

Former Member
0 Kudos

Hi,

You can just create

PARAMETER: p_tablen TYPE <b>tabname.</b>

data : it_st like table of <b>tabname.</b> with header line.

Regards,

Atish

0 Kudos

I receive a syntax error

"TABNAME" must be a flat structure. You cannot use a structure or

internal table as a component.

PARAMETER: p_tablen TYPE tabname.

data : it_st like table of tabname with header line.

What can be change?

0 Kudos

Hi Gary ,

I am not able to understand the need to have a table/structure as a paramterer , could you please share some more info on your requirement .

Regards

Arun

0 Kudos

Hi,

The TABNAME should be a valid type in SAP.

Can you tell me as what is your requirement,. why do you want declaration like this?

Regards,

Atish

0 Kudos

I gt many table in my database, the user can enter a tablename to the paramater.

So i need to declare the table for my sql statement.

Hw to declare the table base on the parameter value?

0 Kudos

Hi,

I think you are looking for dynamic internal tables.

Just search forum with dynamic internal table and you will get lots of idea on it.

Regards,

Atish

0 Kudos

Hi Gray ,

If your requirement some thing like this , that the user enters a table name and you have to preocess data from the table .

If that is the case then i feel you need a paramtere which as input the name of table , you can define it using the data type TABNAME, please check the table DD02L .

and as per the post by Shiba , you can create a dynamic internal table to retreive the data and store it

feel free to revert back in case you still have any further queries.

Regards

Arun

Former Member
0 Kudos

try this

PARAMETER: p_tablen TYPE tabname.

data : it_st like table of dd03l-tabname with header line.

regards

shiba dutta

Former Member
0 Kudos

sorry for wrong understanding . I think you are talking about dynamic int table . if it is so then pls check this blog by rich heilman.

<a href="/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap">/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap</a>

regards

shiba dutta

Former Member
0 Kudos

Dynamic Internal table -weblog in sdn

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

Rewards if useful..........

Minal

former_member1345686
Active Participant
0 Kudos

Dear Gary,

IMHO we can't use a structure type as a parameter ,

especially when the structure does not consist of string fields only.

This is the case why there is the need to define several select-options in the selection screen pointing to the same table ( ie : s_vbeln for vbak-vbeln, s_auart for vbak-auart ) .

In case of yours, if the parameter has a basic type, then the internal table definition should be just fine .

====

I have just read this thread again and find out that your requirement is to define a dynamic table .

In that case, you can ignore this reply

Rgds,

Tuwuh Sih Winedya

Message was edited by:

TUWUHSIH WINEDYA

varma_narayana
Active Contributor
0 Kudos

Hi Gary..

This is the Sample code for ur ReQ:

DATA : REF_TAB TYPE REF TO DATA.

FIELD-SYMBOLS: <FTAB> TYPE TABLE.

parameters : 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.

<b>REWARD IF HELPFUL.</b>