How to improve the performance of user-defined Report Writer functions in Microsoft Dynamics GP 9.0 or in Microsoft Great Plains


INTRODUCTION


This article describes how to improve the performance of user-defined Report Writer functions in Microsoft Dynamics GP 9.0 or in Microsoft Business Solutions - Great Plains.

More Information


In Microsoft Dynamics GP, you can add the prefix "RW_" to a function to create a user-defined Report Writer function. However, when you use a user-defined Report Writer function in a report, you may experience a decrease in performance when you run the report. This decrease in performance is more likely to occur if the following conditions are true:
  • The user-defined Report Writer function is used in the body of the report.
  • The user-defined Report Writer function opens a table that is not directly attached to the report.
A decrease in performance occurs because the table is opened and then closed for each record that is displayed in the body of the report. To improve the performance of the user-defined Report Writer function, set the table to be opened only one time. Then, set the table to remain open until the report has finished running. To do this, follow these steps:
  1. In the same dictionary in which the function is located, create a form that has no windows. Attach the appropriate table or tables to this form. To attach a table to the form, use the Options command in the Form Definition window.

    Note Make sure that each table is set to open during the Form Open operation.
  2. Create a form procedure that is named "Close," and then add the following script to this procedure.
    close form <form_name>
  3. Add the following FORM_PRE script to this procedure.
    call background Close of form <form_name>
  4. Add the following entries to the start of the function.
    if not isopen(form <form_name>) then
    open form <form_name>
    end if
When you run the function, the following actions occur:
  • The function opens the form. This form automatically closes when the report has finished running.
  • The form opens the attached tables during the Form Open operation. These tables remain open when the form is being generated. Therefore, Dexterity in Microsoft Dynamics GP can access these tables more quickly.
  • If the form closes before the report has finished running, the function automatically reopens the form.
Note In Microsoft Dynamics GP, reports run in the background on a First In First Out (FIFO) basis. Therefore, if a request for background processing is submitted when a report is running, this request is not processed until the report has finished running.