‎2011 Jan 12 8:05 AM
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.
‎2011 Jan 18 4:55 AM
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
‎2011 Jan 12 8:34 AM
‎2011 Jan 18 3:05 AM
‎2011 Jan 18 4:55 AM
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