Application Development and Automation 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: 
Read only

delcare table base on parameter field

Former Member
0 Likes
1,171

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

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
Read only

Former Member
0 Likes
1,106

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

Read only

0 Likes
1,106

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?

Read only

0 Likes
1,106

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

Read only

0 Likes
1,106

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

Read only

0 Likes
1,106

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?

Read only

0 Likes
1,106

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

Read only

0 Likes
1,106

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

Read only

Former Member
0 Likes
1,106

try this

PARAMETER: p_tablen TYPE tabname.

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

regards

shiba dutta

Read only

Former Member
0 Likes
1,106

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

Read only

Former Member
0 Likes
1,106

Dynamic Internal table -weblog in sdn

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

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

Minal

Read only

Former Member
0 Likes
1,106

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

Read only

varma_narayana
Active Contributor
0 Likes
1,106

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>