Printing and viewing reports

The Action Pane for each Report List contains items that allow the user to view or print the selected report. To handle viewing and printing, you must register a procedure trigger for the PrintReport procedure of the syReportList form. The following example shows the registration for this trigger from the sample integrating application.

l_result = Trigger_RegisterProcedure(script PrintReport of form syReportList, TRIGGER_AFTER_ORIGINAL, script IG_ReportList_PrintReport);
if l_result <> SY_NOERR then
	warning "Procedure trigger registration failed.";
end if;

The trigger processing procedure must handle both of these cases for your reports. It must have the following parameters:

in syReportData RptData;
in ReportDestOptions RptDestOpts;
in boolean fPreview;

The fPreview flag is a boolean value passed into the procedure that is true if the user chose View or false if the user chose Print. If View was chosen, the report should be displayed on the screen. For reports that use report options, override any destination settings for the option and print the report to the screen.

If Print was chosen, the action required depends on the type of report. Simple reports should always be printed to the printer. For reports that use report options, the destination should be set as indicated by the ReportDestOptions composite that was passed into the trigger processing procedure. The values for this composite were set when the report option was retrieved for the report. They may have been updated by the user if the “Ask Each Time” flag had been set for the report option.

For reports that use report options, you should always retrieve the option specified in the syReportData composite. Use the information in the report option to control sorting, restrictions, and other characteristics for the report.

For reports that print from a window, the trigger processing procedure must open the window from with the report will be run.

The following example is the trigger processing procedure that handles viewing and printing reports for the sample integrating application. It demonstrates how to print a simple report to the screen or to the printer. It also shows how a report that uses a report option processed. Finally, it demonstrates how a report generated from an window is processed.

in syReportData RptData;
in ReportDestOptions RptDestOpts;
in boolean fPreview;

local boolean ToScreen, ToPrinter;
local integer ExportType;
local string ExportName;
local string report_name;

{Print the specified report, based on the information passed in}

if RptData:'Product ID' = IG_PROD_ID then
	{It's one of our reports to print}
	if RptData:'Report ID' = ReptID_LeadsSimple then
		if fPreview = true then
			run report IG_Leads destination true, false;
		else
			run report IG_Leads destination false, true;
		end if;
	end if;

	if (RptData:'Report ID' = ReptID_LeadsWithOptions) or  (RptData:'Report ID' = ReptID_LeadsList) then
		{It's the Leads or Leads List report which uses a report option.}
		report_name =  GetReport(RptData:'Report ID') of form IG_Leads_Reports;

		{Retrieve the option.}
		'Report ID' of table IG_Leads_ROPT = integer(RptData:'Report Option ID');
		'Report Option Name' of table IG_Leads_ROPT = RptData:'Report Option Name';

		get table IG_Leads_ROPT;
		if err() = OKAY then

			{Did the user ask for a preview (to View the report)?}
			if fPreview = true then
				{Print the report using the options, but always to the screen}
				ToScreen = true;
				ToPrinter = false;
				ExportType = 0;
				ExportName = "";
			else
				ToScreen = RptDestOpts:'Print to Screen';
				ToPrinter = RptDestOpts:'Print to Printer';
				ExportType = RptDestOpts:'Export Type';
				ExportName = RptDestOpts:'File Export Name';
			end if;

			if 'Sort By' of table IG_Leads_ROPT = 1 then {Lead ID}
				run report with name report_name sort by 'Lead ID' of table IG_Leads_MSTR legends "Lead ID" destination ToScreen, ToPrinter, ExportType, ExportName;
			end if;

			if 'Sort By' of table IG_Leads_ROPT = 2 then {Name}
				run report with name report_name  sort by 'Lead Name' of table IG_Leads_MSTR legends "Name" destination ToScreen, ToPrinter, ExportType, ExportName;
			end if;

			if 'Sort By' of table IG_Leads_ROPT = 3 then {State}
				run report with name report_name  sort by 'State' of table IG_Leads_MSTR legends "State" destination ToScreen, ToPrinter, ExportType, ExportName;
			end if;
		else
			error "Could not retrieve report option " + RptData:'Report Option Name' + ".";
		end if;
	end if;

	if RptData:'Report ID' = ReptID_LeadsQuick then
		call IG_Leads_QuickReport, REPORTDEST_TO_SCREEN;
	end if;

	if RptData:'Report ID' = ReptID_ContactHistory then
		open form IG_Contact_History;
	end if;
end if;


Documentation Feedback