This section discusses about changing DataWindows dynamically. This may
involve changing SQL statements or DataWindow attributes, and it might also
involve recreating the DataWindow dynamically.
Dynamic Assignments
As you learned previously, DataWindow control and DataWindow object are two
different things. One can link a DataWindow object to many DataWindow controls,
and also, link and de-link these two objects at run time.
For example, say, you need to create 10 different reports. One solution is
to create ten different windows, one for each report, which is a straight
forward method. Another solution is to create a window, and change the
DataWindow object in the DataWindow control, depending on the report. We can
dynamically assign a DataWindow object to a DataWindow control, using the DataObject
attribute. Since all events and scripts are associated with a DataWindow
control, it will operate on any DataWindow object that is assigned to the
DataWindow control, if the code is generic enough. For example:
dw_product.DataObject =
"d_product_custom_query"
dw_product.SetTransObject( SQLCA )
dw_product.Retrieve()
dw_product.Print(TRUE)
After changing the DataObject, you need to set the 'transaction
object' by calling either SetTransObject() or SetTrans(), before performing any
operation related to the database. This method is typically used to allow the
user to select from a list of reports and then display the selected report in a
single DataWindow control or a standard user object of this type.
If you are dynamically assigning DataWindow objects, make sure to add a
corresponding entry in the resource file. For example:
C:\WORKDIR\PRODUCT.PBL(d_product_custom_query)
You will learn more on resource files, in the "Application
Deployment" session.
No comments:
Post a Comment