‎2006 Oct 30 4:51 AM
Hi,
How we can pass a table parameter as a input parameter to FM and get the output as a table?Please give me some example code.
Anu.
‎2006 Oct 30 4:57 AM
Hi Anu,
chk this.
You can pass a table as an import parameter in a Function Module.
Just create a table type in SE11 of the table.
Then in SE37, in the import parameters, just give the parameter as
<b>parameter type table type_name.</b>
This will work.
Let me cite an example to justify my point.
Suppose you want to display the material number and description using a Function Module.You are selecting the required records and storing it in internal table ITAB with header line. You are calling a Function Module FUNCTION_MAKT.
FUNCTION_MAKT contains an import parameter which is a table type of table MAKT.
In the Function Module, you are displaying the MATNR & MAKTX values.
Just write this code in the source code tab of the Function Module.
COde
-
data: wa_mytab type makt.
loop at mytable into wa_mytab.
write : wa_mytab-matnr,wa_mytab-maktx.
endloop.
In the main program, just write the code.
code
-
tables: makt.
data: itab type table of makt with header line.
start-of-selection.
select * from makt into table itab up to 3 rows.
CALL FUNCTION 'ZSHAIL_FMTABLE1'
EXPORTING
mytable = itab[]
.
Hope your query is solved.
Regards,
anver
if hlped pls amrk points
‎2006 Oct 30 4:57 AM
Hi,
Along with the IMPORT EXPORT we also have TABLES parameters in the interface of the FM's. If you got SE37 the Function builder you can see a tab TABLES aong with IMPORT and EXPORT . You can enter you parameter name there and the structre of that table as the component type. Please make sure the strucutre is GLOBAL.
You can call the FM as follows.
CALL FUNCTION <FM_NAME>
EXPORTING
para1 = val1
IMPORTING
para2 = val2
TABLES
para3 = val3.
Regards,
Sesh
‎2006 Oct 30 4:57 AM
You can use the "Tables " options for this purpose.
call fm <function name>
tables : <table name>
Here you can pass the table by filling it.The output will be the same table after the operations conducted on it within your FM.