01-10-2008 5:01 PM
hi experts,
what is Export and Import parameters used in any function module?
will find helpful with example..
thanks in advance..
01-10-2008 5:05 PM
Function modules can have the following interface parameters:
Import parameters. These must be supplied with data when you call the function module, unless they are flagged as optional. You cannot change them in the function module.
Export parameters. These pass data from the function module back to the calling program. Export parameters are always optional. You do not have to receive them in your program.
Changing parameters. These must be supplied with data when you call the function module, unless they are flagged as optional. They can be changed in the function module. The changed values are then returned to the calling program.
Tables parameters. You use these to pass internal tables. They are treated like CHANGING parameters. However, you can also pass internal tables with other parameters if you specify the parameter type appropriately.
Calling Function Modules in ABAP
To call a function module, use the CALL FUNCTION statement:
CALL FUNCTION [EXPORTING f1 = a 1.... f n = a n] [IMPORTING f1 = a 1.... f n = a n] [CHANGING f1 = a 1.... f n = a n] [TABLES f1 = a 1.... f n = a n] [EXCEPTIONS e1 = r 1.... e n = r n [ERROR_MESSAGE = r E] [OTHERS = ro]].
You can specify the name of the function module either as a literal or a variable. Each interface parameter is explicitly assigned to an actual parameter . You can assign a return value to each exception . The assignment always takes the form = . The equals sign is not an assignment operator in this context.
After EXPORTING, you must supply all non-optional import parameters with values appropriate to their type. You can supply values to optional import parameters if you wish.
After IMPORTING, you can receive the export parameters from the function module by assigning them to variables of the appropriate type.
After CHANGING or TABLES, you must supply values to all of the non-optional changing or tables parameters. When the function module has finished running, the changed values are passed back to the actual parameters. You can supply values to optional changing or tables parameters if you wish.
Check this link ..
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
Regards,
maha
01-10-2008 5:03 PM
Import parameters in function module is like parameters or select options which will take input from us and based on the logic we have written in source code of the FM we can output the result in Export parameters.
ex: import parameters.
x = 2.
y = 3.
export parameters.
z = 6.
source code.
z = x * y.
01-10-2008 5:05 PM
Function modules can have the following interface parameters:
Import parameters. These must be supplied with data when you call the function module, unless they are flagged as optional. You cannot change them in the function module.
Export parameters. These pass data from the function module back to the calling program. Export parameters are always optional. You do not have to receive them in your program.
Changing parameters. These must be supplied with data when you call the function module, unless they are flagged as optional. They can be changed in the function module. The changed values are then returned to the calling program.
Tables parameters. You use these to pass internal tables. They are treated like CHANGING parameters. However, you can also pass internal tables with other parameters if you specify the parameter type appropriately.
Calling Function Modules in ABAP
To call a function module, use the CALL FUNCTION statement:
CALL FUNCTION [EXPORTING f1 = a 1.... f n = a n] [IMPORTING f1 = a 1.... f n = a n] [CHANGING f1 = a 1.... f n = a n] [TABLES f1 = a 1.... f n = a n] [EXCEPTIONS e1 = r 1.... e n = r n [ERROR_MESSAGE = r E] [OTHERS = ro]].
You can specify the name of the function module either as a literal or a variable. Each interface parameter is explicitly assigned to an actual parameter . You can assign a return value to each exception . The assignment always takes the form = . The equals sign is not an assignment operator in this context.
After EXPORTING, you must supply all non-optional import parameters with values appropriate to their type. You can supply values to optional import parameters if you wish.
After IMPORTING, you can receive the export parameters from the function module by assigning them to variables of the appropriate type.
After CHANGING or TABLES, you must supply values to all of the non-optional changing or tables parameters. When the function module has finished running, the changed values are passed back to the actual parameters. You can supply values to optional changing or tables parameters if you wish.
Check this link ..
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
Regards,
maha
01-10-2008 5:24 PM
Hi Jagmohan,
If in your program you are using a Function module..say a Function Module to add two numbers...to have the input(i.e the two numbers to be added) , the function module uses IMPORT . the same way to pass the result from that function module after summation to the program...the function module uses EXPORT to send the sum to your program..
Reward points if helpful..
Regards,
Goutham.
01-10-2008 6:45 PM
Hi Jagmohan,
Export parameters:- These are the parameters which the function module exports to the calling program.
Import parameters:- These are the parameters which the function module imports from the program where this function module is called.
Ex:-
REPORT PROGRAM TEST1
DATA : b VALUE 8
CALL FM_X
EXPORTING
y = b.
IMPORTING
it_return = it_ret.
END OF REPORT PROGRAM
****************************************************
Here we are passing b from the report program to the function module and we are getting the values in the table it_ret from the function module.
Reward if useful.
01-10-2008 6:51 PM
Hi Jagmohan,
Export parameters are used to give the input to the Function Module.
Import parameters are used to get the output from the Function Module.
The follwowing code will explain about them clearly.
Here num1 is to be be rounded off and it should be displayed.This work is done by the function module.
Num1 is fed to the function moduleas input.It goes into if_float.
Now the num1 is rounded off and it it present in EF_PACKED.Now this value is fed into num2 as output.
Now num2 contains the rounded off number.
DATA: num1 TYPE p value '19567.468323',
num2 TYPE N .
CALL FUNCTION 'MURC_ROUND_FLOAT_TO_PACKED'
EXPORTING
if_float = num1
IF_SIGNIFICANT_PLACES = 15
IMPORTING
EF_PACKED = num2
Reward if helpfull.
Thanks,
Kashyap