11-13-2007 2:46 PM
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.
11-13-2007 2:49 PM
11-13-2007 2:49 PM
11-13-2007 2:51 PM
Hi Satish,
its a custom function module am trying to create.
Regards.
11-13-2007 3:15 PM
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
11-13-2007 3:16 PM
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
11-13-2007 3:13 PM
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
11-13-2007 3:15 PM
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
11-13-2007 3:24 PM
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
11-13-2007 4:29 PM
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.
11-13-2007 4:34 PM
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