Multiple-Section Reports

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Multiple-Section Reports

Previous pageReturn to chapter overviewNext page

 

A report is a collection of one or more sections, each section owns one data source (rpDataSource) object.  In turn, the rpDataSource owns and manages one or more table level (rpSQLQuery and rpRDDTable) objects.  The rpSQLQuery object provides a wrapper for a SQL query which is sent to a server via an ODBC driver.  The rpRDDTable object provides a class wrapper for RDD based tables.

 

Due to the complexity of this hierarchical structure, reports containing multiple-sections present a challenge when trying to set runtime options at the data source or table level.   For example, to change the sort order of the third section of a multiple-section report, you must traverse the report's section list to find the proper section before you can set its sort order.

 

In most cases, the <aDbfSwap> parameter of the RpReport:Init() can be used to substitute tables and indexes at runtime, however, it may be necessary to traverse a report's section list to set other options.  The following code demonstrates how to traverse the section list to access the data source and table level objects:

 

LOCAL aSections, aTables AS ARRAY

LOCAL oSection AS rpSection

LOCAL oDataSource AS rpDataSource

 

aSections := oRpReport:Sections

nLen := alen(aSections)

FOR nLp := 1 UPTO nLen

   // get the next section so we can change some

   // settings on it.  See the rpSection class.

   oSection := aSections[nLp]

 

   // get the section's datasource so we can 

   // interrogate and change some settings

   // on the tables it contains

   oDataSource := oSection:DataSource

 

   // Now, we want to loop through the tables of

   // the data source to get/set the table

   // filename

   nLen2 := aLen(oDataSource:Tables)

   FOR nLp2 := 1 UPTO nLen2

      ? oDataSource:aTables[nLp2]:cTable

   NEXT Lp2

NEXT nLp

 

Generally, you should not modify rpSection, rpDataSource, rpSQLQuery or rpRDDTable object attributes after the RpReport:Connect2Source() method has been called.  This method opens the RDD tables and executes the SQL Queries contained in a report.  Making changes after the method is called will either have no effect or will cause unpredictable results.  The Connect2Source() method is called automatically by other methods of the RpReport class including Print(), PrintPreview() and ExpressionBuilder().  If you need to modify section or data source attributes, you should do so immediately after instantiating the RpReport object.  An exception to this rule is if you need to get the value of a ReportPro user defined variable.  In this case, the data source must be connected to retrieve the proper value from the variable.