FUNCTION MODULES: SAP function modules are procedures with interfaces that are defined in Function groups. R/3 system consists of a number of predefined function modules , besides we can create our own function modules to reuse any specific functionality in our programs. We can define function modules from simple calculations to complex reports in SAP.
Function group : Function groups act as containers for function modules. A group of related function modules can be defined under one Function Group. We can assign our newly defined function module to an existing function group or can define our own function group. Function groups are o f program type F . Function modules that are in the same function group share global data of the group.
1) Importing parameter : These are export parameters that has to be supplied with data to the function module. They have to be supplied with data unless they are flagged as optional. We cannot change these parameter values in the function module. We have another type called changing parameters for them.
2) Exporting parameters : The calling program receive result as export paramaters from the function module.
3) Changing : Changing parameters performs both the functions like importing and exporting data to and from the function module. The supplied variable can be changed in the function module and returned to the calling program.
4) Tables : Table parameters are especially used to pass internal tables. They also function like changing parameters. They have to be supplied with values unless they are marked as optional.
5) Exceptions: Exceptions are for handling situations where in which normal execution of program becomes difficult. For example if there are not entries in the table TAB1 that meet the selection criteria. We need NOT_FOUND exception for this.
SELECT * FROM MARA INTO TABLE I_MARA WHERE MATNR = mat1.
IF SY-SUBRC NE 0.
MESSAGE E007(AT) RAISING NOT_FOUND.
ENDIF.
6) Source code : The coding between FUNCTION and ENDFUNCTION STATEMENT is called the source code of the function module.
7) SELECT * FROM SPFLI INTO TABLE ITAB WHERE CARRID = ID.
IF SY-SUBRC NE 0.
MESSAGE E007(AT) RAISING NOT_FOUND.
ENDIF.
Popularity: 1% [?]