Applicable Versions: 3.05.0014 onwards
Reports can be stored in a Progress table like any other binary object using the RAW data type. The example code below uses a temp-table to store and load the report. This temp table could be passed to a server if required, and stored in a database table. The example works equally well if you are using the report designer embedded in a GUI window, or using the managed report ActiveX server.
The example code should be prefaced with one of the following code sections:
Embedded Report Designer:
DEFINE VARIABLE PAReports AS COM-HANDLE NO-UNDO.
ASSIGN PAReports = chCtrlFrame:PAReports.
PAReports:Initialise.
ActiveX Server:
CREATE ""DataPAReportsEng.ManagedReport"" PAReportEngine NO-ERROR.
ASSIGN PAReports = chCtrlFrame:PAReports.
PAReports:Initialise.
The following section of code shows how to take a report on disk and load it into a temp-table:
/* Parameters Definitions --- */
DEFINE INPUT PARAMETER ipcReportFile AS CHARACTER NO-UNDO.
/* Local Variable Definitions --- */
DEFINE VARIABLE rawData AS RAW NO-UNDO.
DEFINE VARIABLE iChunk AS INTEGER NO-UNDO.
DEFINE VARIABLE iLoops AS INTEGER NO-UNDO.
DEFINE VARIABLE iChunkSize AS INTEGER NO-UNDO.
DEFINE VARIABLE iStart AS INTEGER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
DEFINE VARIABLE iRemain AS INTEGER NO-UNDO.
/* Local Variable Definitions --- */
DEFINE TEMP-TABLE ttfile
FIELD reportName AS STRING
FIELD idxfield AS INTEGER
FIELD rawData AS RAW
INDEX idx-1 IS PRIMARY IS UNIQUE reportName idxField.
iChunk = PAReports:ChunkSize.
INPUT FROM VALUE(ipcReportFile) BINARY NO-MAP NO-CONVERT.
ASSIGN LENGTH(rawData) = iChunk.
REPEAT:
IMPORT UNFORMATTED rawData.
icount = icount + 1.
CREATE ttfile.
ASSIGN ttfile.reportName = ipcReportFile
ttfile.idxfield = STRING(icount)
ttfile.rawdata = rawdata.
END.
INPUT CLOSE.
The following code section illustrates how to open the report from this temp-table:
PAReports:CLEAR().
FOR EACH ttFile WHERE ttFile.reportName = ipcReportFile:
rawdata = ttfile.rawdata.
PAReports:AppendBytes(INPUT-OUTPUT rawData).
END.
PAReports:OpenReportFromBinary(FALSE).