BAdI: Customer-defined Functions in Formula Builder
This Business Add-In (BAdI) is used in the formula builder transformation library. You use this BAdI to integrate user-defined functions into the transformation library of the formula builder. In this way, you can make special functions that are not contained in the transformation library available for regular use.
The technical name of a user-defined function
- Can contain only alphanumeric characters ( ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_) (lower-case letters, empty spaces and special characters are not allowed)
- Can be a maximum of 61 characters long.
The BAdI can be used repeatedly. Is it not filter-dependent.
After you have called up the IMG activity, a dialog box appears in which you enter a name for implementation.
If implementations have already been created for this BAdI, a dialog box appears in which the existing implementations are displayed. In this dialog box, choose Create and proceed as follows:
1. In the Implementation field, enter a name for the implementation of the BAdIs and choose Create.
2. The initial screen for creating BAdI implementations appears.
3. In the initial screen, in the Short Text for Implementation field, enter a short text for the implementation.
4. Choose the Interface tab index.
5. On the tab page, the field Name of Implemented Class is filled automatically, since the system assigns a class name based on the name of your implementation.
6. Save your entries and assign the implementation to a development class.
7. Position the cursor on the method and double-click on it to reach the method editing screen.
8. Between the statements method ~. and endmethod. the coding for your implementation.
9. Save and activate your coding and return to the Change Implementation screen.
10. Save your entries on the Change Implementation screen.
Note: You can create an implementation for a BAdI and activate it later. If this is the case, close the editing screen now.
11. Choose Activate.
When you execute the application program, the coding you defined in the method is run through.
Read User-Defined Functions
The ABAP methods specified under class and method in the function description are later called up in the maintenance and evaluation for formulas. For this reason, the customer-defined functions must be implemented as methods in a separate class, in additional to BAdI implementation. These methods must have the following properties:
- They need to be declared static and public.
- The are only allowed importing-, exporting- and returning parameters. Changing parameters are not allowed.
- They are only allowed one exporting or returning parameter.
- Exporting parameters are not allowed to have a generic type.
Note: The system does not check to see whether the class or method specified in BAdI implementation actually exists. If the class or method does not exist, a runtime error occurs when using the functions in the Formula Builder.
|I_KEY||Importing parameters: Key with function category|
|C_OPERANDS||Changing parameters: Table with function description|
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/7941665/viewspace-970848/，如需转载，请注明出处，否则将追究法律责任。