Adding Fields to Reports

NOTE This topic is intended for programmers who are familiar with the syntax of Progress OpenEdge Advanced Business Language (ABL).

Standard Apprise reports can be modified by end-users with programming experience to add new fields and tables.

You can do the following:

  1. Add fields to standard report tables. You can optionally define labels for fields.

  2. Add tables to a report dataset. A table name must be prefixed with report-.

  3. Loop through standard report table and access records. Data in standard columns cannot be changed but can be accessed.

  4. Loop through newly added custom table and access records (and change data in columns).

  5. Access values from custom-table.

  6. Change the name of the RPT file that is going to be used. The RPT file must be placed in the user's report working directory or loaded via AppriseCenter to the database.

  7. Determine the name of existing tables/fields in a report dataset in Excel Format Maintenance. Newly added columns will appear in Excel Format Maintenance, but without labels.

Available Objects

Reports can be customized using the following two objects that have public methods:

Creating Custom Report Files

To create a custom report file:

  1. Create a file that has the same name as a standard report program (.p) file, but with suffix -cstm and place the file in the PROPATH. For example, Customer Report uses arcustrp.p. So, you must create arcustrp-cstm.p.

  2. At the top of the newly created file, include {CustomReportInitialize.i}.

  3. Change the schema of report tables by adding new fields or tables. Use the rptSchemaManager object instance.

  4. Call the rptSchemaManager:FinalizeSchema() method.

  5. Fill columns/tables with data by writing Progress queries and using an API. Use the rptDataManager object instance.

Updating Schema (Methods of rptSchemaManager)

  1. CreateCustomReportTable (tableName)

  2. AddTableField (tableName,fieldName,dataType) - The Data type must be one of the following: character, logical, date, integer, decimal.

  3. AddTableField (tableName,fieldName,datatype,label)

  4. CustomReportFileName property - set the name of the custom RPT file to be used (e.g., CustomerListCustom.rpt)

Working with Data (methods of rptDataManager)

  1. OpenQuery (tableName) - open the query of a report dataset table name

  2. CloseQuery (tableName) - close an opened query. OpenQuery() must be used before this.

  3. GetNext (tableName) - returns FALSE when there is no other record to loop through. OpenQuery() must be used before this.

  4. GetFieldValue (tableName,fieldName) - can be called despite the field data type. It always returns character. GetNext() must be used before this. Options: GetFieldValueDate, GetFieldValueDec, GetFieldValueInt, GetFieldValueLog

  5. GetCustomTableFieldValue(tableName,fieldName,fieldKey,systemId) - Access fields from the custom-table table

  6. CreateRow (tableName) - create rows in a newly added report table

  7. SetFieldValue (tableName, fieldName, fieldValue ) - update columns. This must be used after the GetNext() or CreateRow() methods.

  8. ReleaseRow (tableName) - release the newly created row and commit the changes to the report dataset table. 

Example Custom Report

The following is an example of a custom report file:

{CustomReportInitialize.i}

 

/*---- Modify the schema of report-dataset ----*/

 

/* Extend an existing table by adding a column*/

rptSchemaManager:AddTableField("report-data","active","logical","Active").

 

/* Add a new table and its columns */

rptSchemaManager:CreateCustomReportTable("report-contacts").

rptSchemaManager:AddTableField("report-contacts","contact-name","character", "Contact Name").

rptSchemaManager:AddTableField("report-contacts","can-email","logical","Can Email").

rptSchemaManager:AddTableField("report-contacts","contact-address1","character","Contact Address").

 

/* Optional - Override the RPT file name used */

rptSchemaManager:CustomReportFileName = "CustomerListCustom.rpt".

 

/*---- Finalize dataset creation ----*/

rptSchemaManager:FinalizeSchema().

 

/*---- Example: FILLING IN NEWLY ADDED COLUMN TO EXISTING TEMP-TABLE ----*/

rptDataManager:OpenQuery("report-data").

REPEAT WHILE rptDataManager:GetNext("report-data"):

   FOR EACH custname WHERE

            custname.system-id = get-sysid("") AND

            custname.cust-code = rptDataManager:GetFieldValue("report-data","customer-code")

            NO-LOCK:

      rptDataManager:SetFieldValue("report-data","active",custname.active).

   END.

END.

rptDataManager:CloseQuery("report-data").

 

/*---- Example: FILLING IN NEWLY ADDED TEMP-TABLE ----*/

FOR EACH contact WHERE

         contact.system-id = get-sysid("")

         NO-LOCK:

   rptDataManager:CreateRow("report-contacts").

   rptDataManager:SetFieldValue("report-contacts","contact-name",contact.contact-name).

   rptDataManager:SetFieldValue("report-contacts","can-email",contact.can-email).

   rptDataManager:SetFieldValue("report-contacts","contact-address1",contact.contact-address1).

   rptDataManager:ReleaseRow("report-contacts").

END.

Template

{CustomReportInitialize.i}

/*---- Modify the schema of report-dataset ----*/

/*---- Finalize dataset creation ----*/

rptSchemaManager:FinalizeSchema().

/*---- Create custom data or loop through standard/custom data ----*/