Sage 100 Reporting Object

SOLVED

I use this reporting object frequently to print custom reports from button scripts in Sage.   Below is an example of the object being used.

Set report = CreateObject("Sage100ERP.Reporting.Report")

report.Load("C:\MYREPORT_custom.RPT")
report.PrinterName = "My Printer"
report.PrintToPrinter 1, 0, 0, 0, 0

Does anyone know if there is a method available that will let you know export the report (to PDF or otherwise)?  I've used actual reporting objects in Sage (i.e. SO Printing) to export using methods like the below, but I believe these are completely different objects that the reporting object.  Any help would be greatly appreciated!

soPrint.nReportType = 6

if not cbool(soPrint.nInitReportEngine()) then
MSGBOX("Init report engine: " + soPrint.sLastErrorMsg)
end if

if not cbool(soPrint.nSetExportOptions(5, file1)) then
MSGBOX("Set export options: " + soPrint.sLastErrorMsg)
end if


if not cbool(soPrint.nProcessReport("EXPORT")) then
MSGBOX CSTR("Process report: " + soPrint.sLastErrorMsg)
end if

Parents Reply Children
  • 0 in reply to David Speck

    Thanks so much for the links/info David.

  • 0 in reply to Justin K

    FYI, Had a reason to test some of format types in the table from SAP today and not every entry in the table is accurate. Probably best to stick with the format types in the script example.

  • 0 in reply to David Speck

    Another update. Below are the valid export options and recommended extensions. I couldn't decide which approached i liked more but both work if you find yourself having to change formats and want a legend for the available options.

    aExportFormat_CrystalReports = 				Array(1, 	"rpt", 		"Crystal Reports (RPT)"					)
    aExportFormat_MSWordRTF = 					Array(2, 	"rtf", 		"Microsoft Word (97-2003)"				)
    aExportFormat_RTF = 						Array(3, 	"rtf", 		"Rich Text Format (RTF)"				)
    aExportFormat_MSExcel = 					Array(4, 	"xls", 		"Microsoft Excel (97-2003)"				)
    aExportFormat_PDF = 						Array(5, 	"pdf", 		"Portable Document Format"				)
    aExportFormat_RecordToMSExcel = 			Array(8, 	"xls", 		"Microsoft Excel (97-2003) Data-only"	)
    aExportFormat_Text = 						Array(9, 	"txt", 		"Text"									)
    aExportFormat_CommaSeparatedText = 			Array(10, 	"csv", 		"Comma Separated Values"				)
    aExportFormat_TabSeparatedText = 			Array(11, 	"ttx", 		"Tab Separated Values"					)
    aExportFormat_EditableRTF = 				Array(12, 	"rtf", 		"Microsoft Word (97-2003) - Editable"	)
    aExportFormat_XML = 						Array(13, 	"xml", 		"XML"									)
    aExportFormat_RPTR = 						Array(14, 	"rpt", 		"Crystal Reports Read Only (RPTR)"		)
    aExportFormat_RecordToMSExcelWorkbook = 	Array(15, 	"xlsx", 	"Microsoft Excel Workbook Data-only"	)
    
    aExportFormat = aExportFormat_RecordToMSExcel ' Set to one of the nExportFormat_* variables from the above list.
    oReport_Rpt.nSetExportOptions aExportFormat(0), sReportExportPath & "\" & sReportExportName & " (" & aExportFormat(0) & "=" & aExportFormat(2) & ")" & "." & aExportFormat(1)
    oReport_Rpt.nExport False ' Use False to suppress export options dialogue.

    Dim aReportExportOptions(13)
    aReportExportOptions(1 ) = Array("Crystal Reports (RPT)"				, "rpt" , 1 )
    aReportExportOptions(2 ) = Array("Crystal Reports Read Only (RPTR)"		, "rpt" , 14)
    aReportExportOptions(3 ) = Array("Microsoft Excel (97-2003) Data-only"	, "xls" , 8 )
    aReportExportOptions(4 ) = Array("Microsoft Excel (97-2003)"			, "xls" , 4 )
    aReportExportOptions(5 ) = Array("Microsoft Excel Workbook Data-only"	, "xlsx", 15)
    aReportExportOptions(6 ) = Array("Microsoft Word (97-2003) - Editable"	, "rtf" , 12)
    aReportExportOptions(7 ) = Array("Microsoft Word (97-2003)"				, "rtf" , 2 )
    aReportExportOptions(8 ) = Array("Portable Document Format"				, "pdf" , 5 )
    aReportExportOptions(9 ) = Array("Rich Text Format (RTF)"				, "rtf" , 3 )
    aReportExportOptions(10) = Array("Tab Separated Values"					, "ttx" , 11)
    aReportExportOptions(11) = Array("Text"									, "txt" , 9 )
    aReportExportOptions(12) = Array("XML"									, "xml" , 13)
    
    nExportFormat = 5 ' Set to one of the aReportExportOptions array indexes from the above list.
    oReport_Rpt.nSetExportOptions aReportExportOptions(nExportFormat)(2), sReportExportPath & "\" & sReportExportName & " (" & aReportExportOptions(nExportFormat)(2) & "=" & aReportExportOptions(nExportFormat)(0) & ")" & "." & aReportExportOptions(nExportFormat)(1)
    oReport_Rpt.nExport False ' Use False to suppress export options dialogue.