cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Internal Table to a function

Former Member
0 Kudos

Hi ,

Can we pass an internal table along with its header to a function.

Regards.

Arun

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Arun,

Of course you can pass an internal table to a Function Module. When you define the Function Module in SE37, define a TABLES parameter with the same structure as the internal table ( which should again be a dictionary structure).

In the program, when you call this function module, pass the internal table to the tables parameter you have defined for the function module.

Please note that:

1. Tables parameters are always passed by reference. so, you need to be very careful in their usage. Also, use as few tables parameters as necessary.

2. Whenever you pass a tables parameter, the system will automatically create a header line for the tables parameter which can be used in the Function Module logic.

3. However, the table header will not get passed automatically along with the table body (from the calling program). You have to pass it explicitly. For that, you need to define an exporting parameter of the line type of the table.

In my experience, it has never been necesasary to pass the table header to the function module. In general, the contents of the table header would be present as one of the lines in the internal table, right?

Hope this information helps.

Regards,

Anand Mandalika.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

just to correct point 3 of the above answer.

TABLES are used to declare so called table parameters. Table parameters are obsolete formal parameters that are typed as internal standard tables with header lines.

If an internal table without header line or a table body is transferred as an actual parameter to such a formal parameter, then an empty local header line is generated in the procedure. If an internal table with header line is used as the actual parameter, then <b>both the table body and the header line</b> are passed to the procedure. For formal parameters defined with TABLES, no pass by value is possible.

Regards

Horst