Progress
Report Builder
Tutorial
Defining a User-defined Function
A user-defined function (UDF) is a function you create to process field values according to an expression that you define. The primary benefits of UDFs are that you can create them to perform complex operations that are not available with the built-in Report Builder functions and that you can use them in multiple reports. See the “Report Builder Functions” appendix in the Progress Report Builder User’s Guide for complete descriptions of the built-in Report Builder functions.
For this report, you will create a UDF that calculates the commission rate for each order. Although you can create a calculated field to perform the same calculations, if you did, you could not use it in other reports. By defining a UDF, you can use the calculation in other reports.
Follow these steps to create a user-defined function:
- Choose Calculations
User Defined Function. The New User Defined Function dialog box appears:
![]()
- Type Comm–Rate in the User Defined Function Name fill-in field.
- Choose the New button to create the parameters you need for the expression. The New Parameter dialog box appears:
![]()
User-defined functions, like the built-in functions, are not associated with a specific report definition. Therefore, you must use parameters instead of direct table and field references in the UDF expression. Parameters pass actual values from the database or user-defined fields into the UDF expression. This indirection allows you to use the UDF with multiple reports. For this expression, you want to pass in a value that is a total for an order.
- Type OrderTot in the Parameter Name fill-in field.
- Select numeric from the Parameter Type drop-down list, then choose OK. The New User Defined Function dialog box appears.
- Type IIF(OrderTot < 2000, .05, .1) in the Expression fill-in field.
This expression tests the value passed in through the OrderTot parameter to see if it is above or below $2,000. If it is below $2,000, then the commission rate is 5%. If the value is above $2,000, then the commission rate is 10%:
![]()
- Choose Verify to check the expression syntax. If there is an error in the expression (for example, if you did not leave a blank space between one of the expression elements), Report Builder displays an error message. When possible, it also positions the cursor to the place in the expression where the error occurred.
Edit the existing expression if it is not correct.
- When the expression is complete and correct, choose OK.
- Choose OK to create the function and return to the User Defined Functions dialog box:
![]()
- Choose Close to return to the report layout.
For a complete description of UDFs, see the user-defined functions chapter in the Progress Report Builder User’s Guide .
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |