01-07-2015 8:00 AM
I have internal table "itabfinal" with fields "pernr, werks, btrtl, plan, ansal, Persk".
now i need to pass "itabfinal" into the functional module and get back the all of "itabfinal" field from the function module into the program.
for this i am creating the funtional module " ZFM1"
inside the functional module i have given the import as "itab1-type-table"
inside the functional module i have given the export as "itab2-type-table".
inside the functional module i have given the changing as "itab3-type-table"
inside the functional module i have given the Table as "itab4-type-ZFM1_STRU_T"
where "ZFM1_STRU_T" is the table type with reference to itabfinal.
in my program i am calling the functional module as below.
CALL FUNCTION 'ZFM1'
EXPORTING
itab1 = itabfinal
IMPORTING
ITAB2 = itab4
changing
itab3 = itab4.
But in functional module i had given the code as below :
FUNCTION zfm1.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(ITAB1) TYPE TABLE
*" EXPORTING
*" REFERENCE(ITAB2) TYPE TABLE
*" TABLES
*" ITAB4 TYPE ZFM1_STRU_T
*" CHANGING
*" REFERENCE(ITAB3) TYPE TABLE
*"----------------------------------------------------------------------
data: wa type ZFM1_STRU.
clear wa.
loop at itab1 into wa.
move wa to itab4.
modify itab4.
endloop.
ENDFUNCTION.
please help me to get the itabfinal into the program using above funtional module
01-07-2015 8:44 AM
You don't need importing and exporting if they are of same type. You can just create the FM using changing. Any change in the changing parameters will be reflected back once it comes out of FM.
01-07-2015 9:18 AM
Hi Adithya can u please help me with the basic example or tell me the what is the source code to be written if you use only changin option in the fm.
01-07-2015 9:28 AM
Hi Vishnu,
No code is required if you use CHANGING parameter. It will remain same. If you want to change content of your internal table then you can use statement like APPEND, MODIFY, INSERT to change content of your internal table.
Regards,
Sid
01-07-2015 9:44 AM
Thanks once again adihtya,
inside the functional module i have given the changing as "itab3-type-table"
and no source code given.
But now in the program i am calling the functional module.so how i need to call it exactly?
I had given like this please tell me we can do it or not
CALL FUNCTION 'ZFM1'
CHANGING
itab2 = itabfinal.
I have a doubt with out exporting the itabfinal inside the functional module how we can use the change option?
01-07-2015 11:02 AM
Hi Vishnu,
In changing parameter you can pass the internal table to function module and if you do any changes on the same internal table in function module, then after execution same changes will reflect in calling program.
Many Thanks / Himanshu Gupta