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

Export internal table from Function Module to the calling environment

Former Member
0 Likes
4,100

Hi GURUs

We have scenario where we export the table name (say USR02) and Primary Key Value to the function module from main program.

So in this program i need to export the internal table from the funtion module to the main program...

we've declared a variable, say t_result of type any as a export variable in FM. we

MOVE <t_table> TO t_result..

here we are getting error saying "t_result is not a internal table"

pls help..

thnx in advance..

9 REPLIES 9
Read only

Former Member
0 Likes
1,480

Hi,

Please ellaborate our Question................

But Since i understand you want to export the UR02 Structure from FM to Main Program....

There are 2 solutions for that ...

1. Create a structure and enter the fields u want in FM and export in by calling in Mai Program.

2. Use Field Symbols Concept.

Affable

Arbind

Read only

Former Member
0 Likes
1,480

If i understand correctly, u r calling a FM in your main program and passing the table name, primary key as input parameters. This FM will return the mentioned table data as output right... If yes, then u can declare the table same as the function module output parameter type and use the output table directly in ur main program.

Read only

Former Member
0 Likes
1,480

hi,

thank for the reply.

we tried using a field sybmols.

we are trying to take any table name and this is the following code what we tried .

FUNCTION y713301_table.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(T_NAME) TYPE C

*" VALUE(PRIMARY_ID) TYPE C

*" VALUE(PRIMARY_VALUE) TYPE C

*" EXPORTING

*" VALUE(FNAME) TYPE C

*" REFERENCE(T_RESULT) TYPE ANY

*"----


DATA:lt_dd03l TYPE STANDARD TABLE OF dd03l,

ls_dd03l TYPE dd03l.

DATA: my_table TYPE REF TO data.

FIELD-SYMBOLS: <it_tname> TYPE STANDARD TABLE.

SELECT * FROM dd03l INTO TABLE lt_dd03l

WHERE tabname EQ t_name.

CREATE DATA my_table LIKE TABLE OF lt_dd03l.

ASSIGN my_table->* TO <it_tname>.

MOVE <it_tname> TO t_result[].

ENDFUNCTION.

" MOVE <it_tname> TO t_result[]." on this line we are getting a error.

please provide the solution for this.

Read only

0 Likes
1,480

Hi,

I have worked...

Please find the solution....


  DATA : it_dd03l TYPE TABLE OF dd03l.

  DATA: w_tabname TYPE tabname VALUE 'DD03L',

  w_dref TYPE REF TO data.

  FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.

  CREATE DATA w_dref TYPE TABLE OF (w_tabname).

  ASSIGN w_dref->* TO <t_itab>.


  SELECT *

      FROM (w_tabname) UP TO 20 ROWS

      INTO TABLE <t_itab>.

  MOVE <t_itab> TO it_dd03l.

Please let me know for any more solutions..........

Read only

Former Member
0 Likes
1,480

hi,

Arbind Prasad,

i'm trying to fetch the records from the specified table with a specific primary key value.

so only one record will be retrieved from the table.

i'm creating a field symbol of type table.

once the records r fetched assign the rows to the export variable.

Read only

0 Likes
1,480

Hi,

It's Simple my Friend



data :  w_dref TYPE REF TO data,
           w_tabname type tabname.

w_tabname = Import Parameter.
 
FIELD-SYMBOLS: <t_itab> TYPE ANY .
 
CREATE DATA w_dref TYPE  (w_tabname).
 
  ASSIGN w_dref->* TO <t_itab>.
 
 
  SELECT *
 
      FROM (w_tabname)  
      INTO  <t_itab>.
 
  MOVE <t_itab> TO it_dd03l.

Just try to manipulate the same code.

It will work

Affable

Arbind

Read only

Former Member
0 Likes
1,480

hi Arbind,

the above code u mentioned ll work when ur trying to retreive the rows of the table in the main program.

i tried the following with somes changes which works fine in the main prg.

but when i'm trying to execute code in FM with some changes, it doesn't work.

so request u to help me out to get out this black hole....

thank u.

Read only

0 Likes
1,480

Hi Srimal,

I have done the same ..

It works for me....

Since u r using Field Symbols after getting the values in FM u have to move it to a structure , so make a structure in se11 and move it.

it works.

Please try and let me know if there some probelm ......

Regards

Arbind

Read only

Former Member
0 Likes
1,480

hi Arbind,

As u told to create a structure in se11, but the problem is we don't know the structure(components), the table will be know at only runtime(dynamic). so how to handle in that case..?