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

FM exporting table

Former Member
0 Likes
1,019

Hi, I want to export a table from a FM.

What is the best method? Define the table under the EXPORT screen or TABLES screen?

What should the code in the FM be, if my internal table is named it_tableTOexport?

Thanks!

8 REPLIES 8
Read only

Former Member
0 Likes
937

Hi Rune,

Always it's better to define tables in tables only.

-Anu

Read only

Former Member
0 Likes
937

Hi,

If it is table then you need to export it in tables.

Hope this helps.

Read only

Former Member
0 Likes
937

Hi,

If you have a table type created in the DDIC you can use the EXPORTING parameter.

If you have structure only then you can use the TABLES parameter..

THanks,

Naren

Read only

Former Member
0 Likes
937

When you say EXPORT, hope you mean download to pc.

The best is to pass the table as a TABLE parameter and the code can be to use the FM Gui_download.

Call Function 'Gui_download'

exporting

filename = p_file

filetype = 'ASC'

tables

data_table = it_tabletoexport.

Read only

Former Member
0 Likes
937

Hello,

Under TABLES only. Use the option IMPORT, CHANGING and EXPORT only for variables or strucrures.

Regs,

Venkat Ramanan N

Read only

uwe_schieferstein
Active Contributor
0 Likes
937

Hello Rune

The only way to differentiate between semantically different TABLES parameters is by using naming convention. I use the following conventions:

(1) Importing TABLES parameter (i.e. this is only input for the function module, the itab entries are not changed) = <b>IT_<itab name></b>

(2) Exporting TABLES parameters (i.e. this is only output of the function module) = <b>ET_<itab name></b> [In addition, one of the first line of coding in the function module is: REFRESH: et_<itab name>]

(3) Changing TABLES parameters (i.e. this is input and output at the same time) = <b>XT_<itab name></b> [usually there will be no REFRESH statement using this TABLES parameter]

Note that the differentiation between importing, exporting and changing is purely <b>semantic</b> because technically all TABLES parameters are the same.

Regards

Uwe

Read only

0 Likes
937

Thanks for all replies.

This is in my FM:

EXPORTING

*" VALUE(T_RESULT_EXPORT) LIKE ZT_RESULT STRUCTURE

*" ZTKG_RESULT

I have the parameter name T_RESULT_EXPORT in the Export section. How can I fill the table with data? I get an compiler error saying "T_RESULT_EXPORT is not an internal table - the OCCURS n specification is missing".

All I want to do is filling my export table.

Read only

0 Likes
937

The exporting parameter cannot be filled like an internal table unless it points to a table type. Which is to say, the structure ZT_RESULT STRUCTURE should be a table type.

In your case, the error occurs because ZT_RESULT STRUCTURE is a structure and hence, T_RESULT_EXPORT is also a structure and not an itab.

2 solutions:

1. Create T_RESULT_EXPORT under tables instead of exporting

OR

2. Creat ZT_RESULT STRUCTURE as a table type instead of structure.

Hope this helps.

Sudha