Use the REPORT block language construct to format and display data output from a FUNCTION block. This output is typically table data, although any valid combination of HTML tags, macro variable references, and function calls can be specified. A table name can optionally be specified on the REPORT block. If you do not specify a table name, Net.Data uses the table data from the first output table in the parameter list of the FUNCTION block. If you do not specify a table on the FUNCTION block, Net.Data uses the default table data.
The REPORT block has three parts, each of which is optional:
Example:
%REPORT{
<H2>Query Results</H2>
<P>Select a name for details.
<TABLE BORDER=1>
<TR><TD>Name</TD><TD>Location</TD>
%ROW{
<TR>
<TD>
<a href="/cgi-bin/db2www/name.mac/details?name=$(V1)&location;=$(V2)">$(V1)</a></TD>
<TD>$(V2)</TD>
%}
</TABLE>
%}
Use the following guidelines when creating REPORT blocks:
SHIPDATE | RECDATE | SHIPNO | ------------------------------------- 25/05/1997 | 30/05/1997 | 1495194B | ------------------------------------- 25/05/1997 | 28/05/1997 | 2942821G | -------------------------------------
%REPORT{%}
The following example shows how you can customize report formats using special variables and HTML tags. It displays the names, phone numbers, and fax numbers from the table CustomerTbl:
%FUNCTION(DTW_SQL) custlist() {
SELECT Name, Phone, Fax FROM CustomerTbl
%REPORT{
<I>Phone Query Results:</I>
<BR>
=====================
<BR>
%ROW{
Name: <B>$(V1)</B>
<BR>
Phone: $(V2)
<BR>
Fax: $(V3)
<BR>
------------------------------
<BR>
%}
Total records retrieved: $(NUM_ROWS)
%}
%}
The resulting report looks like this in the Web browser:
Phone Query Results: ==================== Name: Doen, David Phone: 422-245-1293 Fax: 422-245-7383 ------------------------------ Name: Ramirez, Paolo Phone: 955-768-3489 Fax: 955-768-3974 ------------------------------ Name: Wu, Jianli Phone: 525-472-1234 Fax: 525-472-1234 ------------------------------ Total records retrieved: 3
Net.Data generated the report by:
You can specify multiple REPORT blocks within a single FUNCTION or MACRO FUNCTION block to generate multiple reports with one function call.
Typically, you would use multiple REPORT blocks with the DTW_SQL language environment with a function that calls a stored procedure, which returns multiple result sets (see Stored Procedures). However, multiple REPORT blocks can be used with any language environment to generate multiple reports.
To use multiple REPORT blocks, you must pass a Net.Data table variable in the function parameter list. If you pass more tables in the parameter list than the number of report blocks you have specified, and if DTW_DEFAULT_REPORT = "MULTIPLE", then default reports are generated for each table that is not associated with a report block. If no report blocks are specified, and if DTW_DEFAULT_REPORT = "YES", then only one default report will be generated. Note that for the SQL language environment only, a DTW_DEFAULT_REPORT value of YES is equivalent to a value of MULTIPLE.
The following examples demonstrate ways in which you can use multiple report blocks.
To display multiple reports using default report formatting:
Example 1: DTW_SQL language environment
%define DTW_DEFAULT_REPORT = "MULTIPLE"
%function (dtw_sql) myStoredProc (OUT table1, table2) {
CALL myproc %}
In this example, the stored procedure myproc returns two result sets, which are placed in table1 and table2. Because no REPORT blocks are specified, default reports are displayed for both tables, table1 first, then table2.
Example 2: DTW_REXX language environment
%define DTW_DEFAULT_REPORT = "YES"
%function (dtw_rexx) multReport (INOUT table1, table2) {
SAY 'Generating multiple default reports...<BR>'
%}
In this example, two tables are passed into the REXX function multReport. Since DTW_DEFAULT_REPORT="YES" is specified, Net.Data displays a default report for the first table only.
Example 3: MACRO_FUNCTION block
%define DTW_DEFAULT_REPORT = "MULTIPLE"
%macro_function multReport (INOUT tablename1, tablename2) {
%}
In this example, two tables are passed into the MACRO_FUNCTION multReport. Again, Net.Data displays default reports for the two tables in the order in which they appear in the MACRO FUNCTION block parameter list, table1 first, then table2.
To display multiple reports by specifying REPORT blocks for display processing:
Example 1: Named REPORT blocks
%function(dtw_sql) myStoredProc (OUT table1, table2) {
CALL myproc
%REPORT(table2) {
...
%row { .... %}
...
%}
%REPORT(table1) {
...
%row { .... %}
...
%}
%}
In this example, REPORT blocks have been specified for both of the tables passed in the FUNCTION block parameter list. The tables are displayed in the order they are specified on the REPORT blocks, table2 first, then table1. By specifying a table name on the REPORT block, you can control the order in which the reports are displayed.
Example 2: Unnamed REPORT blocks
%function(dtw_sql) myStoredProc (OUT table1, table2) {
CALL myproc
%REPORT {
...
%row { .... %}
...
%}
%REPORT {
...
%row { .... %}
...
%}
%}
In this example, REPORT blocks have been specified for both of the tables passed in the FUNCTION block parameter list. Because there are no table names specified on the REPORT blocks, reports are displayed for the two tables in the order in which they appear in the FUNCTION block parameter list, table1 first, then table2.
To display multiple reports using a combination of default reports and REPORT blocks:
Example: A combination of default reports and REPORT blocks
%define DTW_DEFAULT_REPORT = "MULTIPLE"
%function(dtw_system) editTables (INOUT table1, table2, table3) {
%EXEC{ /qsys.lib/mylib.lib/mypgm.pgm %}
%REPORT(table2) {
...
%row { .... %}
...
%}
%}
In this example, only one REPORT block is specified, and because it specifies a table name of table2, it uses this table to display its report. Because there are fewer REPORT blocks specified than tables passed in the FUNCTION parameter list, default reports are displayed for the remaining tables in the order in which they appear in the FUNCTION block parameter list; first, a default report for table1, then a default report for table3.
Use the following guidelines and restrictions when specifying multiple REPORT blocks in a FUNCTION or MACRO_FUNCTION block.
Guidelines:
Restrictions: