0% found this document useful (0 votes)
76 views41 pages

3 RF ProgDataSource

The Progress Data Source Program Reporting Framework Training Course aims to teach participants how to develop and deploy a Progress 'Proxy' Data Source Program within a .NET UI environment. Key components include handling metadata and data requests, defining data sets, and implementing retrieval logic using dynamic queries. The course also covers the structure of the code required for creating metadata, managing temporary tables, and utilizing helper procedures for efficient data handling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views41 pages

3 RF ProgDataSource

The Progress Data Source Program Reporting Framework Training Course aims to teach participants how to develop and deploy a Progress 'Proxy' Data Source Program within a .NET UI environment. Key components include handling metadata and data requests, defining data sets, and implementing retrieval logic using dynamic queries. The course also covers the structure of the code required for creating metadata, managing temporary tables, and utilizing helper procedures for efficient data handling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Progress Data Source Program

Reporting Framework Training Course


Session Objectives
You will learn how to:
• Develop a Progress “Proxy” Data Source
Program
• Deploy the data source program into the
run-time environment

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

.NET UI Client AppServer


Reporting Framework
Reporting Progress
Progress Program Data Source
Framework Open
(RunReport.p and (.p program)
Client Client
GetReportMeta.p)

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}

/* Report data set definition block */

/* TODO Insert your data set code here */

/* 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}

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.
Continued …

RF-PDS-080
Overall Code Structure – Page 2
… Continued
/* 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 dsReportResults:handle. */

end procedure.

/* This delete is to prevent a memory leak of the data set */


delete object phReportResults no-error.

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]

index SalesHeaderIdx is primary so_nbr


.

define temp-table ttSoLine


field sales_order_number like so_mstr.so_nbr
field sales_detail_line like sod_det.sod_line
field sales_detail_item like sod_det.sod_part
field sales_detail_unit_measure like sod_det.sod_um
field sales_detail_due_date like sod_det.sod_due_date

index SoLineIdx is primary sales_order_number sales_detail_line.


.

define dataset dsReportResults for ttSalesHeader, ttSoLine


data-relation drLine for ttSalesHeader, ttSoLine
relation-fields (so_nbr, sales_order_number)

RF-PDS-100
2. Table Emptying Code - Example

/* Empty temp-table block */


empty temp-table ttSalesHeader no-error.
empty temp-table ttSoLine no-error.

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:

run CreateBufferHeader in reportHandle


("ttSalesHeader", "Sales Orders").

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. */

run CreateField in reportHandle


(bufferName,
"so_nbr",
getLabel("SALES_ORDER"),
"character",
"x(8)",
"gplu239.p",
true,
false,
true,
false,
true,
false,
true,
"",
{&ParameterOperator_Equals},
{&ParameterValueType_Constant},
"",
{&ParameterValueType_Constant}).

RF-PDS-190
Metadata: CreateFieldForDBField -
Example
/* The following field will have some of its metadata
attributes */
/* driven from the so_cust database field. */

run CreateFieldForDBField in reportHandle


(bufferName,
"so_mstr",
"so_cust",
true,
false,
true,
false,
true,
false,
true,
"",
{&ParameterOperator_Equals},
{&ParameterValueType_Constant},
"",
{&ParameterValueType_Constant}).

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. */

run CreateFieldLikeDBField in reportHandle


(bufferName,
"order_date",
"so_mstr",
"so_ord_date",
true,
false,
true,
false,
true,
false,
true,
"",
{&ParameterOperator_Equals},
{&ParameterValueType_Constant},
"",
{&ParameterValueType_Constant}).

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.

statusValueList = "New,1,In Process,2,Completed,3".

run SetFieldMetaParam in ReportHandle(


bufferName,
"status",
"valueList",
statusValueList)
.

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 SOQuery:handle.

queryString = "for each so_mstr no-lock "


+ " where so_mstr.so_domain = " +
QUOTER(global_domain).

run FillQueryStringVariable in reportHandle (input


"ttSalesHeader", input "so_nbr", input-output queryString).

run FillQueryStringVariable in reportHandle (input


"ttSalesHeader", input "so_cust", input-output queryString).

run FillQueryStringVariable in reportHandle (input


"ttSalesHeader", input "order_date", input-output
queryString).

queryString = queryString + ":".

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.

• Input parameters include:


- bufferName (temp-table name)
- fieldName (field name in temp-table)
- queryString (dynamic query string)

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").

- If no static conditions are needed, add a


dummy one ("where true") so that and-ed
dynamic conditions are appended properly
• For static sorting, add a ‘by’-clause at the
end of the query string
- Example: Sort records by customer
queryString = queryString + " by so_cust:".
RF-PDS-310
GetFilterValue Function
• Helper procedure from ReportHelper.p
• Used to retrieve filter values from input
request
• Call signature:
FUNCTION GetFilterValue returns character
(input ipBufferName as character,
input ipFieldName as character,
input defaultValue as character):

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

define var orderLineFilterValue as integer no-undo.

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].

for each sod_det no-lock


where sod_det.sod_nbr = so_mstr.so_nbr:

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

• Example propath for compilation:

propath = propath + "," +


"/qad/web/server/docs/93/ebdesktop2/dev93ui/com/qad/shell/report/
reports".

propath = propath + "," +


"/qad/web/server/docs/93/ebdesktop2/dev93ui".

propath = propath + "," +


"/qad/web/server/docs/93/ebdesktop2/dev93ui/com/qad/shell/report".

propath = propath + "," +


"/qad/mfgpro/93/stage".

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

You might also like