3 RF ProgDataSource
3 RF ProgDataSource
RF-PDS-020
Reporting Framework Architecture
Report
Layout Pre-Render
Definition Engine
- Applies Report
Template Report
Render
- Translates
Labels
Engine
Data
Source
- Progress Program
- Browse
- Financial API
RF-PDS-030
Developing a Progress Data Source Program
• Program runs on the .NET UI Progress
Application Server tier
• Two types of client requests must be
supported
- Metadata request
• Information about data set tables and fields
• Field attributes drive client behavior on prompt page
- Data request
• Query business data, restricting by filter conditions
RF-PDS-040
Developing a Progress Data Source Program
• Generic entry progams: RunReport.p,
GetReportMeta.p
- All client requests go through GetReportMeta.p
for metadata
- All client requests go through RunReport.p for
data query
- RunReport.p and GetReportMeta.p delegate the
call to the specified data source program
RF-PDS-050
Program Call Structure
Database
RF-PDS-060
Progress Data Source Program
Calls
• A data source program requires four
blocks of code to be written:
- 1. A data set definition
• Consists of one or more temp-tables that define the
data set structure for the report
• Tables can be related (e.g. master-detail)
- 2. Statements to empty the temp-table(s) in
the data set
- 3. Metadata definition that defines attributes
for the fields in the data set
- 4. Data retrieval logic that populates the data
set according to filter conditions
RF-PDS-070
Overall Code Structure – Page 1
{mfsubdirs.i}
{{&US_BBI}mfdeclre.i}
{{&US_BBI}gplabel.i}
{com/qad/shell/report/dsReportRequest.i}
{com/qad/shell/report/ReportConstants.i}
/* Main Block */
define input parameter runReport as logical.
define input parameter reportHandle as handle.
define input parameter dataset for dsReportRequest.
define output parameter dataset-handle phReportResults.
{com/qad/shell/report/reporting.i}
RF-PDS-080
Overall Code Structure – Page 2
… Continued
/* Metadata definition block */
procedure FillMetaData:
end procedure.
end procedure.
RF-PDS-090
1. Data Set Definition Block -
Example
/* Temp-table definition block */
define temp-table ttSalesHeader
field so_nbr like so_mstr.so_nbr
field so_cust like so_mstr.so_cust
field so_ord_date like so_mstr.so_ord_date
field sales_order_slspsn1 like so_mstr.so_slspsn[1]
field sales_order_slspsn2 like so_mstr.so_slspsn[2]
field sales_order_slspsn3 like so_mstr.so_slspsn[3]
field sales_order_slspsn4 like so_mstr.so_slspsn[4]
RF-PDS-100
2. Table Emptying Code - Example
RF-PDS-110
ReportHelper.p Program
• Performs tasks common to all data source
programs
- Initializes Metadata data set
• Provides utility functions / procedures
- Makes specific data source program code more
succinct:
- Functions to assist in creating metadata
- Functions to assist with building dynamic filter
condition strings for ‘where’ clause
• Runs as a persistent procedure
- Handle is passed into data source program as
an input parameter
RF-PDS-120
3. Metadata Definition Code Block
• Needs to fill the metadata output data set
• Define Buffer Header (for each table)
- Use CreateBufferHeader from ReportHelper.p
• Define Field Metadata
- Use CreateField from ReportHelper.p (and
similar procedures)
- Specify Lookups
- Translation Considerations
• Field Labels
• Value Lists
• Logical-Typed fieldFormat
RF-PDS-130
Metadata: Using
CreateBufferHeader
• CreateBufferHeader procedure
- Creates the metadata that describes a table
- Must be run once for each temp-table in the
report data set
• Parameters:
- tableName
- tableLabel
• Example:
RF-PDS-140
Metadata: Using CreateField
• CreateField procedures
- Create the metadata that describes a field
- Three variants:
• CreateField – allows programmer to explicitly pass in
values of each metadata parameter.
• CreateFieldForDBField - can be used if field is similar
to one in business database
- Some metadata parameters will be determined by the
system based on database field.
- e.g. field label, data type, field format, and lookup name
• CreateFieldLikeDBField - similar to
CreateFieldForDBField
- Allows field name of the report field to be different from
that of the database field.
RF-PDS-150
Metadata: CreateField
CreateField input parameters include:
• bufferName • isSingleEntry
• fieldName • isOperatorChangeable
• fieldLabel • isRequiredCondition
• dataType • isEditable
• fieldFormat • defaultValue
• lookupName • defaultOperator
• isSearchField • defaultValueType
• isReadOnlySearch • defaultValue2
• isVisible • defaultValueType2
RF-PDS-160
Metadata: CreateFieldForDBField
CreateFieldForDBField parameters include:
• bufferName • isRequiredCondition
• tableName • isEditable
• fieldName • defaultValue
• isSearchField • defaultOperator
• isReadOnlySearch • defaultValueType
• isVisible • defaultValue2
• isSingleEntry • defaultValueType2
• isOperatorChangeable
RF-PDS-170
Metadata: CreateFieldLikeDBField
CreateFieldLikeDBField parameters include:
• bufferName • isOperatorChangeable
• fName • isRequiredCondition
• tableName • isEditable
• fieldName • defaultValue
• isSearchField • defaultOperator
• isReadOnlySearch • defaultValueType
• isVisible • defaultValue2
• isSingleEntry • defaultValueType2
RF-PDS-180
Metadata: CreateField - Example
/* The so_nbr field is set as a search field, so the seventh
parameter is True. */
RF-PDS-190
Metadata: CreateFieldForDBField -
Example
/* The following field will have some of its metadata
attributes */
/* driven from the so_cust database field. */
RF-PDS-200
Metadata: CreateFieldLikeDBField -
Example
/* The following field will be called order_date in the report
even though some */
/* of its metadata attributes will be driven from the
so_ord_date database field. */
RF-PDS-210
Metadata: Lookup Syntax
• Short-hand Notation:
- Can be used if the desired lookup is a browse
defined by Browse Maintenance
- Example:
“gplu239.p” – denotes browse gp239 as lookup
• Complete Notation:
- Must be used if the browse is from a different
server implementation (e.g. EE Financial query)
• <lookup provider type>:<lookupID>:<lookup
return field>:<lookup filter field>
- Example:
• BaseLibrary.Lookup.BLFLookupProvider:BJou
rnalSAO.SelectJournal:tcJournalCode:tJour
nal.JournalCode
RF-PDS-220
Metadata: Value Lists
• Allows values for a character –typed field to
be restricted to a discrete set of values
• Each value can be accompanied with a
user-facing label that can appear in two
places:
- List of values in filter condition (viewer prompt
page)
- Report output document
- The value is what is stored in the DB
• Use the valueList field metadata attribute
• Syntax:
- <Label 1>,<DB value 1>,<Label 2>,<DB value 2>, ...
RF-PDS-230
Metadata: Value Lists - Example
• Note: SetFieldMetaParam is a procedure in
ReportHelper.p that can be used to set
field metadata attributes
• One of the CreateField procedures must
first have been called to create the record
define variable statusValueList as character no-undo.
RF-PDS-240
Metadata: Translations
• Most translations for reports are done in
the page layout design (Report Resource
Designer)
• There are also some areas that may
require translated text in the metadata
returned by a data source program:
• Field Labels - fieldLabel metadata attribute
• Value Lists - valueList metadata attribute
• Logical-Typed value labels - fieldFormat metadata
attribute
RF-PDS-250
Metadata: Translations
• Use global_user_lang shared variable to
determine language to use for getting
translated labels
• Use getLabel() utility function in
ReportHelper.p
- Input: term key string
- Output: translated long label, using
global_user_lang
- Example: getLabel("SALES_ORDER")
- Function definition:
FUNCTION getLabel returns character (
input pTerm as character):
RF-PDS-260
4. Data Retrieval Logic Code Block
• Used to populate the report data set tables
• Must be implemented in procedure
RunReport
• Need to Use Dynamic Query
- To handle filter conditions from client request
- FillQueryStringVariable helper procedure
• Query Iteration and Temp Table Population
RF-PDS-270
Data Retrieval – Defining the
Query
define variable queryString as character no-undo.
define variable hSOQuery as handle.
define query SOQuery for so_mstr.
hSOQuery:query-prepare(queryString).
hSOQuery:query-open().
hSOQuery:get-next().
RF-PDS-280
FillQueryStringVariable Procedure
• Helper procedure from ReportHelper.p
• Used to add dynamic filter conditions to
the query string
• Will construct a where-clause segment and
append it to the query string with a logical
and
- Inspects client request data set to read filter
conditions
RF-PDS-290
FillQueryStringVariable Procedure
• Call signature:
PROCEDURE FillQueryStringVariable:
define input parameter bufferName as character no-undo.
define input parameter fieldName as character no-undo.
define input-output parameter queryString as character
no-undo.
RF-PDS-300
Static where-clause Conditions
• Static filter conditions can be hard coded
into beginning of query string
- Example: Filter query to only include orders for
“SITE1”
queryString = "for each so_mstr no-lock
where so_site = "
+ QUOTER("SITE1").
RF-PDS-320
GetFilterValue Function
• Input parameters include:
- ipBufferName (temp-table name)
- ipFieldName (field name in temp-table)
- defaultValue (value to return if none found in
request)
• Returns: Field value from filter conditions
in request
RF-PDS-330
GetFilterValue - Example
orderLineFilterValue =
integer(GetFilterValue("ttReportOptions", “sod_line",
"1")).
RF-PDS-340
Data Retrieval – Query Iteration
• Iterate over the query records and
populate the temp tables of the report
data set
• Example…
RF-PDS-350
Data Retrieval – Query Iteration
Example
repeat while not hSOQuery:query-off-end:
create ttSalesHeader.
assign
ttSalesHeader.so_nbr = so_mstr.so_nbr
ttSalesHeader.so_cust = so_mstr.so_cust
ttSalesHeader.so_ord_date = so_mstr.so_ord_date
ttSalesHeader.sales_order_slspsn1 = so_mstr.so_slspsn[1]
ttSalesHeader.sales_order_slspsn2 = so_mstr.so_slspsn[2]
ttSalesHeader.sales_order_slspsn3 = so_mstr.so_slspsn[3].
ttSalesHeader.sales_order_slspsn4 = so_mstr.so_slspsn[4].
create ttSoLine.
assign
ttSoLine.sales_order_number = sod_det.sod_nbr
ttSoLine.sales_detail_line = sod_det.sod_line
ttSoLine.sales_detail_item = sod_det.sod_part
ttSoLine.sales_detail_unit_measure = sod_det.sod_um
ttSoLine.sales_detail_due_date = sod_det.sod_due_date.
end.
hSOQuery:get-next().
end. /* Repeat query */
RF-PDS-360
Progress Data Source Deployment
• Progress data source programs are deployed
on the .NET UI Progress application server tier
- <desktop source code
directory>/com/qad/shell/report/reports
- <desktop source code directory> usually is:
/qad/web/server/docs/<ENVname>/ebdesktop2/
<WEBAPPNAME>/
• Compile the program and save
- Must be connected to qaddb and qadadm DBs
- Can use the mkdt program in <desktop source
code directory>
• ./mkdt compile
RF-PDS-370
Progress Data Source Deployment
Propath Example
RF-PDS-380
Exercise
1. Install and compile the sample .p data
source programs given in the course
materials
- HelloWorldReport.p
- SimpleItemReport.p
- TimeDelayReport.p
- UserGuideSampleReport.p
RF-PDS-390
Exercise
2. Import the XML layout definitions for the
sample reports
- Report Resource Import
3. Modify the SimpleItemReport.p program
to add a Unit of Measure field
- Add field to .p to contain pt_mstr.pt_um
- Add field to page layout in Designer
- Add it to the SimpleItemReport_Grouped layout
RF-PDS-400
Summary
In this section, you have learned how
to…
• Develop a Progress “Proxy” Data Source
Program
• Deploy the data source program into the
run-time environment
RF-PDS-410