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

Dynamic internal table in Function module

Former Member
0 Likes
3,397

Hi Guru's

I need to write a normal function module to read different tables data and pass back to the calling program.

My problems are:

How to define dynamic internal tables as parameters?

What is the best way to either Export or Table parameters? If yes could you suggest how to define.

After the definition. I have the internal tables with records.

I need to fill the result tables back to dynamically defined internal tables in parameters? How should i do?

If anybody have any code examples. could you please post.

that would really helpful to me.

Thanks for your help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,479

Hi

I assume u will pass the table name to your FM and it will retun a table filled with data from the table name passed.

If yes, here is the code for that:

Create 1 importing parameter "TAB_NAME" of type "DD02L-TABNAME" in your FM.

Create 1 exporting parameter "TAB_DATA" of type "ANY TABLE" in your FM.

Source code:

data it_general type ref to data.

field-symbols <it_general_tab> type any table.

create data it_general type table of (tab_name).

assign it_general->* to <it_general_tab>.

select * from (tab_name)

into table <it_general_tab>

up to 10 rows. " you can set your own selection ceiteria

tab_data = <it_general_tab>.

This FM cannot be tested from SE37 due to dynamic parameter. To test it, you need to call it in your program.

Regards

Vishal Kapoor

Edited by: vishal kapoor on Jan 18, 2011 10:26 AM

3 REPLIES 3
Read only

Former Member
0 Likes
1,479

This message was moderated.

Read only

Former Member
0 Likes
1,479

This message was moderated.

Read only

Former Member
0 Likes
1,480

Hi

I assume u will pass the table name to your FM and it will retun a table filled with data from the table name passed.

If yes, here is the code for that:

Create 1 importing parameter "TAB_NAME" of type "DD02L-TABNAME" in your FM.

Create 1 exporting parameter "TAB_DATA" of type "ANY TABLE" in your FM.

Source code:

data it_general type ref to data.

field-symbols <it_general_tab> type any table.

create data it_general type table of (tab_name).

assign it_general->* to <it_general_tab>.

select * from (tab_name)

into table <it_general_tab>

up to 10 rows. " you can set your own selection ceiteria

tab_data = <it_general_tab>.

This FM cannot be tested from SE37 due to dynamic parameter. To test it, you need to call it in your program.

Regards

Vishal Kapoor

Edited by: vishal kapoor on Jan 18, 2011 10:26 AM