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:
Add fields to standard report tables. You can optionally define labels for fields.
Add tables to a report dataset. A table name must be prefixed with report-.
Loop through standard report table and access records. Data in standard columns cannot be changed but can be accessed.
Loop through newly added custom table and access records (and change data in columns).
Access values from custom-table.
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.
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.
Reports can be customized using the following two objects that have public methods:
rptSchemaManager – methods for updating the schema
rptDataManager – methods for looping through data, creating/updating records
To create a custom report file:
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.
At the top of the newly created file, include {CustomReportInitialize.i}.
Change the schema of report tables by adding new fields or tables. Use the rptSchemaManager object instance.
Call the rptSchemaManager:FinalizeSchema() method.
Fill columns/tables with data by writing Progress queries and using an API. Use the rptDataManager object instance.
CreateCustomReportTable (tableName)
AddTableField (tableName,fieldName,dataType) - The Data type must be one of the following: character, logical, date, integer, decimal.
AddTableField (tableName,fieldName,datatype,label)
CustomReportFileName property - set the name of the custom RPT file to be used (e.g., CustomerListCustom.rpt)
OpenQuery (tableName) - open the query of a report dataset table name
CloseQuery (tableName) - close an opened query. OpenQuery() must be used before this.
GetNext (tableName) - returns FALSE when there is no other record to loop through. OpenQuery() must be used before this.
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
GetCustomTableFieldValue(tableName,fieldName,fieldKey,systemId) - Access fields from the custom-table table
CreateRow (tableName) - create rows in a newly added report table
SetFieldValue (tableName, fieldName, fieldValue ) - update columns. This must be used after the GetNext() or CreateRow() methods.
ReleaseRow (tableName) - release the newly created row and commit the changes to the report dataset table.
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.
{CustomReportInitialize.i}
/*---- Modify the schema of report-dataset ----*/
/*---- Finalize dataset creation ----*/
rptSchemaManager:FinalizeSchema().
/*---- Create custom data or loop through standard/custom data ----*/