QAD 2017 Enterprise Edition > User Guides > Reporting Framework > Implementing a Progress Data Source Program > Developing the Data Source Program Code
  
Developing the Data Source Program Code
A data source program comprises four blocks of code:
A data set definition (consisting of one or more temp-tables) that defines the data set structure for the report
Statements to empty the temp-table(s) in the data set
Metadata definition that defines attributes for the fields in the data set
Data retrieval logic that populates the data set
In order for the program to be invoked properly by RunReport.p, it must have a specific structure. The following sample code illustrates this structure, showing where the four blocks of code should be inserted:
/* UserGuideReportSkeleton.p - Progress Report Data Source program skeleton */
/* Copyright 2012 QAD Inc. All rights reserved. */
/* */
 
{mfsubdirs.i}
{{&US_BBI}mfdeclre.i}
{{&US_BBI}gplabel.i}
 
{com/qad/shell/report/dsReportRequest.i}
{com/qad/shell/report/ReportConstants.i}
 
/* Report data set definition block */
 
/* TODO Insert your data set code here */
 
/* Main Block */
define input parameter runReport as logical no-undo.
define input parameter reportHandle as handle no-undo.
define input parameter dataset for dsReportRequest.
define output parameter dataset-handle phReportResults.
 
{com/qad/shell/report/reporting.i}
 
define variable bufferName as character no-undo.
 
/* Empty temp-table block */
 
/* TODO empty the temp-table(s) */
 
for first ttReportRequest no-lock:
 
run FillMetaData.
 
if runReport then do:
run RunReport
(output dataset-handle phReportResults).
end.
 
end.
 
/* Metadata definition block */
procedure FillMetaData:
 
/* TODO Insert your metadata code here */
 
end procedure.
 
/* Data retrieval logic block */
procedure RunReport:
 
define output parameter dataset-handle phReportResults.
 
/* TODO Insert your data retrieval code here */
 
/* Assign phReportResults to your dataset here */
/* phReportResults = dataset <your dataset>:handle. */
 
end procedure.
 
/* This delete is to prevent a memory leak of the data set */
delete object phReportResults no-error.
 
The code contains several comments starting with TODO. These comments indicate where the code blocks should be inserted. The following sections will discuss how to write the code blocks to be inserted into the above structure.