a5w_report_saveas Function


filenameOut as C = a5w_report_saveAs(C LayoutName [,C Saveas_format [,C Filter [,C Order [,C Filename [,P globalVariables [,P PrintOptions [,SQL::Arguments Arguments [,P Options ]]]]]]])



The report to print. The report must include a fully qualified path to the report location. If specifying a SSRS report, use the format reportName.ssrs.a5rpt. See examples below.


Type of file to create. Can be one of the following values:


Creates a PDF file.


Exports report as an Excel file.


Creates an HTML report.


Creates an RTF file.


Creates a text file.


Filter expression to apply to report. Specify an empty string for no filter. Not supported for SSRS reports.


Order expression to apply to report detail. Specify an empty string for no order. Not supported for SSRS reports.


Name of file to create.


A pointer to the global variables. Pass in global_variables() if you do not need to define your own global variables. Not supported for SSRS reports. See explanation below for more information.


Default = null_value(). PDF Driver options. Not supported for SSRS reports. See Report.SaveAs() for more details.


Default = null_value(). Optional SQL Arguments (if required by the report data source.) See Report.SaveAs() for more information.


Default = null_value(). Additional options. See Report.SaveAs() for available options.




The a5w_report_saveas() method prints LayoutName to file in PDF, HTML, RTF, or TXT formats. If no format is specified, the PDF format is used. If a report needs to get access to global variables defined in a .a5w page, you must call this function, and not Report.SaveAs()


The a5w_report_saveas function generates a Report from the Application Server.

a5w_report_saveAs("customer List@[PathAlias.ADB_Path]\myalphaworkspace.alb","PDF","","","c:\data\custlist.pdf",global_variables())
[PathAlias.ADB_Path] is an alias for the application webroot.

 Specifying the Report to Print

Reports can be defined in the workspace library or as individual report files on the Web Projects Control Panel. The LayoutName must include a fully qualified path to the location of the report file. Depending on where the report is located, you can specify the path as follows:

Report Location
Layout Name
Workspace Library (*.alb)


Project Report (*.a5rpt)


Use Project Reports (*.a5rpt) in web and mobile applications when creating reports.

The example below shows how to use the [PathAlias.ADB_Path] placeholder when specifying the location of the workspace library.

'Print a report stored in the workspace library:

The next example shows how to use the context.request.applicationRoot property when specifying the location of a Project Report (a report saved as a *.a5rpt file.)

'Print a Project Report:
a5w_report_saveAs(a5_removeTrailingBackslash(context.request.applicationRoot) + chr(92) + "myReport.a5rpt","PDF","","","myReport.pdf",global_variables())

 Global Variables in Web Applications

In a desktop application, global variables are accessible throughout the application. Passing a pointer to the global variables is not necessary.

In a web application, global variables are variables defined on on the .a5w page and exist for the duration of the page. They are not accessible to other .a5w pages. You can use the global_variables() method to create a pointer to the global variables defined in an .a5w page

dim globalvars as p
globalvars = global_variables()
globalvars.userName = "John Smith"

If you have global variables that are used by the report, you must create and pass the global variable to the a5w_report_saveas method in a web application.

dim globalvars as p
globalvars = global_variables()
globalvars.myglobal1 = "foo"

dim layout_name as c
layout_name = a5_removeTrailingBackslash(context.request.applicationRoot) + chr(92) + "customerList.a5rpt"


 Printing SSRS Reports

Reports created using SQL Server Reporting Services can be generated from Xbasic using the a5w_report_saveAs() function. If the SSRS report has any parameters, they can be specified using the Arguments parameter. For example:

dim reportName as c
reportName = "customersbystate.ssrs.a5rpt"

dim args as sql::Arguments

dim filename as c

filename = a5w_report_saveAs(reportname,"pdf","","","c:\pdf\report1.pdf",null_value(),null_value(),args)
sys_open( filename)

Not all parameters are supported for SSRS reports. Specifically, you cannot use the filter, order, global variables or print options parameters.

See Also