Application Development 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: 

Returning a table in a Function Module

Former Member
0 Kudos

Hi All,

My requirement is to return a table from a function module.

The table has two columns.

Could you please guide me how can I achieve this.

Actually I am not able to fill in the export tab in the function module screen.

What should be

Parameter name

Type spec

& Associated type.

Kindly help me.

Regards.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

which function module it is?

Satish

9 REPLIES 9

Former Member
0 Kudos

which function module it is?

Satish

0 Kudos

Hi Satish,

its a custom function module am trying to create.

Regards.

0 Kudos

this is just example try like this

import parameter : I_KUNNR type KUNNR - Customer Number

Table Parameter: T_DATA like KNA1 - Customer table.

Source code

Select * from kna1 into table t_data where kunnr = i_kunnr.

<b>Reward points for helpful answers</b>

Satish

0 Kudos

1. You need to crate a table type for your internal table if you want to assign it in export parameter.

To create a table type:

go to Se11..select the data type.. give your table type name.. press create

Select table type in the next popup..assign your type into Line type.

save and activate...

2. now in FM, in your exporting parameter just mainting

ITAB         TYPE            YOUR_TABLE_TYPE

Regards,

Naimesh Patel

Former Member
0 Kudos

1) You need to create a Table type with the same <Line type> in the data dictionary.

2) Specify the 2 fiels in the KEYS tab of the table type.

3) Then in the exporting parameter you can specify any <Tabname> Type <DDICTTYPE>.

Hope it helps.

Lokesh

Message was edited by:

Lokesh Aggarwal

Former Member
0 Kudos

Hi,

It is not compulsory to fill

Parameter name,

Type,

Associated type.

Leave it blank ..with in tables tab just specify table name like 'itab'...

Message was edited by:

Sudhakar G

Former Member
0 Kudos

Hi,

If you want to return multiple rows to calling program, you should use Table Parameter .

Create custom structure using SE11 transaction and use the same in Function module to declare table parameter.

e.g. If you want to return KUNNR and NAME1 fields to calling application. Create structure ZKUNNR with the above fields. declare table parameter as

T_CUST LIKE ZKUNNR

in source code you can append record in the table parameter.

select kunnr name from kna1 into table t_cust.

I hope it will give you better idea about table parameter.

Regards,

Naren

0 Kudos

Hi All,

Thanks for your kind responses, I did as suggested(Created a table in se11).

Now in the source code when I am trying to insert records to it I am getting an error like <b>ITAB is not an internal table - the "Occurs n" specification is missing?</b>

Kindly advise how can I proceed from here.

Regards.

0 Kudos

YOu need to create a explicit work area for that:

like:

Data: wa_itab type your_type.

loop at itab into wa_itab.
* access wa_itab for your changes...
endloop.

Regards,

Naimesh Patel