| THE BLACK BOX | |||||
|
|
|||||||||||||||||||||||||||||
Discussed will be:
|
|||||||||||||||||||||||||||||
| Note 1 | The Four Components of Functions |
|
|||||||||||||||||||||||||||
| Ù
|
Conceptually
there are four components to an SAP Function.
|
|
|||||||||||||||||||||||||||
|
||||||
| Note 2 | Creation and Editing of Functions |
|
||||
| SE80 ð | ![]() |
Enter transaction /nSE80 in the command field to get to the Object Navigator. By double clicking on ZSAP as it does not exist results in the dialog Create Object popping up. | ||||
| SE37 ð | ![]() |
Or enter transaction /nSE37 to get to the Function Builder and select the menu path from Goto, choose "Function groups" and then "Create" | ||||
|
|
![]() |
To create a Function Module, click the Right Mouse Button with the Function Module Line highlighted. The Create dialog pops up and asks for details. |
| Note 3 | Interface Tabs of the Function |
|
| Ù |
|
The TAB screen shows Attributes,
Interface In/Out settings, Exception Handling and the Source Code for the
Function Module created. Remote-enabled module:- Allow logging in to an external system. To run this function requires a Destination Parameter to be supplied and the Login in details have to be maintained as a separate configuration step. Update module:- If the function module is involved with Table Updates, then this option will identify this Function Module to be considered in the LUW (Logical Unit of Work) from the calling program. |
| Note 4 | Import and Export Parameters |
|
| Ù | ![]() |
Note: One concept to realize involves the matching
of Import and Export Parameters between the calling ABAP program and the
Function Module. The ABAP call exports data into the Function and the
Function receives the data from the ABAP. Further the Function exports the
results out to the ABAP which is received under the Importing. |
|
||||||
| Note 5 | Data Scope and Data Visibility |
|
||||
| Ù | ![]() |
Globalize
Parameters: The point to be discussed here addresses
Scope and Visibility of the Data. From "Note 3" above you can
see the Global check box is not checked. This is the default taken for all
new Function Modules. The point around this is Import and Export
parameters are not visible to ABAP FORM definitions seen in the MAIN
program. When do you know you have this problem? If the syntax checker
Fails to resolve the parameter called and gives the message Parameter not
Found. |
||||
|
There are two solutions to this. One way the Parameters could be visible in this circumstance is by passing them via the Perform Call.
The second way is to set the "Globalize Parameters". The outcome of this is the Function Import and Export Parameters now have the Scope of Visibility across the code segments making up the Function.
Unless you have a reason to hide the Scope
of the Parameters then set the Globalize Parameters on as it makes for
cleaner code. |
||||||
| Note 6 | Overview on Function Types |
|
||||||||||
| Ù | ![]() |
Explanation: There are four entries possible
"Type of Parameter" when adding Import or Export Parameters.
They are,
|
||||||||||
|
||||||||||||
| Note 7 | EXCEPTION HANDLING |
|
||||||||||
| Ù | ![]() |
Exception Handling: When a function exits from a Raised Exception a Number value goes back to the Calling Program. As seen above in Note 3 the Return Value will be 1,2 or 3. This becomes the SY-SUBRC value. | |
![]() |
Raising Exceptions: The code here
shows how exceptions are managed with the Operator "RAISE". The
parameter values available to the "RAISE" call are given against
the "Exceptions" Tab seen below. Once an Exception is triggered
the code Flow becomes, "Stop, Set all EXPORT and TABLE parameters in
the Function Interface to Initial values, Exit and return a Number"
back to the Calling Program as a System Exception. |
||
| Note 8 | A WATCH OUT FOR |
|
|
| Ù
|
Keep in mind that any FORM reference in the MAIN Program can be
called from all the Function Modules. Therefore if you are fixing the call
"Perform Parse_BKPF_data" in the Function Module
"Z_TEST_CALL_MODULE1". Any code changes you put in will also affect module "Z_TEST_CALC_MODULE2" should this module contain the same Perform call. |
||
Note 9 |
Search Trick |
|
|||||||
| Ù
|
Say you
want to find the Functions that exist say against a "Z" Table. Why, to avoid reinventing some code. Go to transaction SE11, enter the Table, Display, then do a "where used" search. The resulting hit list could contain program references that contain SAPLxxxx. You have found the Functions. Then you can go to transaction SE84 and select Program > Function Modules and put in xxxx into the Function Group, hit F8 and see the resulting Hit List which contains the list of all Function Modules |
||||||||
|
|||||||||
|   |   | ||||||||









