Applicable Versions: 2.01.0152 and above



When the application object is created it runs through an initialisation routine. Depending on your configuration, this routine may involve several AppServer calls and as such can be costly in terms of performance if repeated unnecessarily. As such, it is good practice to make sure that your application creates a single DataPA.Application object, which is used by all procedures that use PAReports or DataPA Automation objects. To achive this we simply need to create a single DataPA Application object when we start our application (usually when the user logs in) and share this single object globally in our project.


Assigning an Application Object to a DataPA Reports Control
The DataPA Reports Control has a property called Application that references the DataPA.Application object it uses. This property can be assigned a value BEFORE the Initialise method is called on the DataPA Reports Control. If this property has been assigned to a valid DataPA.Application object when the Initialise method is called, the DataPA Reports Control will use that DataPA.Application object throughout its life. Otherwise, the DataPA Reports Control  Object will create its own instance of the DataPA.Application object when the Initialise method is called.


Example VB 2005
For example, the code in our example initialise procedure can use a globally shared DataPA.Application object returned by a function:


Dim myApp As DataPA.Application
 
myApp = getSharedDataPAApplication()
PAReports.ApplicationObject = myApp
PAReports.Initialise()


Example Progress 4GL
For example, the code in our example initialise procedure can use a globally shared DataPA.Application object returned by a function:


DEFINE VARIABLE hApp AS COM-HANDLE      NO-UNDO.
 
ASSIGN PAReports = chCtrlFrame:PAReports.
hApp = DYNAMIC-FUNCTION(""GetApplication"").
PAReports:ApplicationObject = hApp.
PAReports:Initialise.