compile function test_brw( void ) //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // // This program is proprietary and is not to be used by or disclosed to others, // nor is it to be copied without written permission from Envizion Systems Pty Ltd. // // Name : // // Description: test printing BRW programatically // // * @package PowerForce // * @author Martin Drenovac (for Envizion Systems Pty Ltd) // * @copyright Copyright (c) 2007 - @present, Envizion Systems Pty Ltd // * @licence http://powerforcesoftware.com/user/license.html // * @link http://powerforcesoftware.com // * @since Version 1.0 // // History (Date, Initials, Notes) // 21/07/17 mpd Original programmer // 25/07/18 mpd change output dir to local to OI execution path // // Date: 2018/07/21 17:34:22 +1000 (Sat 21 Jul 2018) //------------------------------------------------------------------------------ // This is the best and apparently most up to date doco on BRW. // https://winwinsol.com/WebHelp/OpenInsight%20Banded%20Report%20Writer%20(BRW)%20Reference%20Guide/OpenInsight_Banded_Report_Writer_(BRW)_Reference_Guide.htm //------------------------------------------------------------------------------ #PRAGMA OUTPUT SYSLISTS mpd_test_brw $INSERT nv_copyright $INSERT nv_userprefs DECLARE function nv_error, RTI_BRW_GenerateReport, nv_utils DECLARE subroutine check_assignments check_assignments( void ) nv_version$$ = "[ver: i206]" IF void[1,5] _eqc ver$$ THEN RETURN nv_version$$ END retval = "" //------------------------------------------------------------------------------ // This from the docm as to how to call the routine // RTI_BRW_GenerateReport(rptFile, rptName, outputName, rptType, overrideListID, rptDetails, bUseGUI, overrideCfg) //------------------------------------------------------------------------------ a: DECLARE FUNCTION RTI_BRW_GENERATEREPORT, RTI_BRWSUPPORT //------------------------------------------------------------------------------ // rptFile is the name of the report group you saved the desired report(s) into and // rptName is the name of the specific report to run (or “*” to run all the reports in the group). // // You may also specify a semicolon-delimited list of report names if desired. //------------------------------------------------------------------------------ reportGroup = "GROUP_NAME" ; // reportName = "MPD_LHINFO" ; // // reportName = "*" ; // this will print every report in the group //------------------------------------------------------------------------------ // OutputName is the path and name of the file to save the output to (if producing a PDF, HTM, etc. document) – // Leave this blank to generate printed output // Required when printing to .pdf. It is a sub-directory relative to your OI directory where the oengine is running // The 'now' thing is just my debug so i can see new files being created as a run this 10x in a row. //------------------------------------------------------------------------------ now = OCONV(time(),"MT"):"-":time() CONVERT ":" TO "" IN now outputName = "pdfs\output-":now:".pdf" ; // 'pdfs" has to be relative to your OI directory // outputName = "" ; // this will go to c:\temp\sample.pdf if reportType = 'PDF' //------------------------------------------------------------------------------ // rptType is the type of output to generate, and can be PDF, TIFF, HTML, TEXT, XLS, or XLSX // (or PRINT to generate printed output, but that isn’t really needed if you leave outputName blank) //------------------------------------------------------------------------------ reportType = "PDF" ; // reportType = "PRINT" ; // //------------------------------------------------------------------------------ // interesting bit of BRW this next thing. Not required for printing //------------------------------------------------------------------------------ bLockFlag = 0 // rptdef = RTI_BRWSUPPORT("READ", reportGroup, bLockFlag) ; // allows you to programtically change your xml brw code * rptdef = RTI_BRWSUPPORT("DISPLAY", reportGroup, bLockFlag) Orientation = 0 ; // 1=Landscape,0=Portrait //------------------------------------------------------------------------------ // overrideListID is the ID of a saved list that contains the record keys you want this report generation to use. // If there is no overrideListID specified, but there is an active select list when RTI_BRW_GENERATEREPORT is called, // then the active list will be used instead. //------------------------------------------------------------------------------ overrideListID = "REPORT_KEYS" ; // this has '123' in <1>, and only line printed as @ID overrideListID = "" ; // this prints the whole file //------------------------------------------------------------------------------ // rptDetails is only used when the rptType is PDF – if desired, you can specify in rptDetails the access permissions // for the PDF, and the password(s) for PDF access. //------------------------------------------------------------------------------ rptDetails = "none":@rm:"PASSWORD" ; // you can password lock the .pdf file (if selected) rptDetails = "\\M6800\\Samsung" // rptDetails = "" //------------------------------------------------------------------------------ // bUseGUI is a flag that indicates whether you want report generation to occur with a GUI (set bUseGUI to “1”) or without a GUI, // i.e., silently (set bUseGUI to “0”). Note that if the output is going to the printer, // you can also set bUseGUI to “2” – in this case, you’ll get a full print preview window, // instead of just a printer control window as you would if bUseGUI is “1”. // Note that the default if bUseGUI is not specified is “0” (no GUI). //------------------------------------------------------------------------------ bUseGUI = "0" ; // // rslt = RTI_BRW_GenerateReport(rptFile, rptName, outputName, rptType, overrideListID, rptDetails, bUseGUI, overrideCfg) // rslt = RTI_BRW_GENERATEREPORT(reportGroup, reportName, outputName, reportType, overrideListID, rptDetails, bUseGUI) //------------------------------------------------------------------------------ // overrideCfg - // OECGI Invocation Only - Override configuration settings to be used for this instance of the BRW. // While the format of this setting uses the same attributes as the CFG_OIBRW configuration record, no defaults will be applied. // Therefore, each attribute will have to be explicitly populated (i.e., fully resolved) with the correct value. // See the notes regarding each attribute's default value in the the CFG_OIBRW Configuration article to understand how to resolve these values. // The purpose for an override setting is to ensure that systems like O4W can call the BRW with applicable configuration settings. // For instance, the default configuration might be to share the engine, but O4W systems require a new connection. //------------------------------------------------------------------------------ // rslt = RTI_BRW_GenerateReport(rptFile, rptName, outputName, rptType, overrideListID, rptDetails, bUseGUI, overrideCfg) talking_to_web = 1 ; // check reportType to see where it's going IF talking_to_web THEN GOSUB web_interface temp = "Content-type: text/plain":\0A0A\ temp := "rslt is : ":rslt:" :":quote(outputName):" -> rptDetails :":QUOTE(rptDetails):" -> reportType :":QUOTE(reportType) END ELSE rptDetails = "" reportType = "PDF" // RTI_BRW_GenerateReport(reportGroup, reportName, outputName, reportType, report_keys, rptDetails, bUseGUI, overrideCfg) rslt = RTI_BRW_GenerateReport(reportGroup, reportName, outputName, reportType, report_keys, rptDetails, bUseGUI) temp = "Content-type: text/plain":\0A0A\ temp := "rslt is : ":rslt:" :":quote(outputName):" -> rptDetails :":QUOTE(rptDetails):" -> reportType :":QUOTE(reportType) END RETURN temp //------------------------------------------------------------------------------ // ConnectMode : https://wiki.srpcs.com/display/BRWR/CFG_OIBRW+Configuration //------------------------------------------------------------------------------ web_interface: bUseGUI = 0 ; // 2=Screen,1=Printer,0=Direct ConnectMode = "." EngineServerPort="" // rv= RTI_BRW_GenerateReport(LabelName, LabelName, "", "", "REPORT_KEYS", LabPrinter:@VM:@VM:Orientation, bUseGUI,"") // RTI_BRW_GENERATEREPORT(reportGroup, reportName, outputName, reportType, overrideListID, rptDetails, bUseGUI) overrideCfg = ConnectMode ; // <1> ConnectMode overrideCfg<2> = EngineServerPort ; // <2> EngineServerPort overrideCfg<3> = "" ; // <3> EngineName overrideCfg<4> = "65" ; // <4> StartupFlags overrideCfg<5> = "1" ; // <5> ShutdownFlags overrideCfg<6> = "RTI_BRW_FILTER" ; // <6> FilterRoutine overrideCfg<7> = "" ; // <7> Unused overrideCfg<8> = "" ; // <8> UTF8 mode overrideCfg<9> = "ABRW_LOG" ; // <9> DebugLog [T]syslists / brw_log (doesn't work) report_keys = "" ; // "REPORT_KEYS" syslists/{record ids for this job} rslt = "" ; // send this msg back to web page bryan = "reportGroup :":reportGroup:@RM:"reportName :":reportName:@RM ; // Mr Schumsky wants the debug whilst helping me bryan :="outputName :":outputName:@RM:"reportType :":reportType:@RM bryan :="report_keys :":report_keys:@RM:"rptDetails :":rptDetails:@RM bryan :="overrideCfg :":overrideCfg CONVERT @FM TO "," IN bryan CONVERT @RM TO @FM IN bryan void = nv_utils('syslists', bryan, "BRYAN-":time()) ; // my internal code, just writes to 'syslists' rslt = RTI_BRW_GenerateReport(reportGroup, reportName, outputName, reportType, report_keys, rptDetails, bUseGUI, overrideCfg) RETURN //------------------------------------------------------------------------------ // this below is the online doco relating to how to call these routines above. // cut/pasted it here so it's onhand when i come back to this in 5 years time // //------------------------------------------------------------------------------ * CALL RTI_BRW_GENERATEREPORT(rptFile, rptName, outputName, rptType, overrideListID, rptDetails, bUseGUI) * where rptFile is the name of the report group you saved the desired report(s) into and rptName is the name of the * specific report to run (or "*" to run all the reports in the group). You may also specify a semicolon-delimited list of * report names if desired. * OutputName is the path and name of the file to save the output to (if producing a PDF, HTM, etc. document) - * leave this blank to generate printed output. * rptType is the type of output to generate, and can be PDF, TIFF, HTML, TEXT, XLS, or XLSX (or PRINT to generate * printed output, but that isn't really needed if you leave outputName blank). * overrideListID is the ID of a saved list that contains the record keys you want this report generation to use. If there * is no overrideListID specified, but there is an active select list when RTI_BRW_GENERATEREPORT is called, then * the active list will be used instead. * rptDetails is only used when the rptType is PDF - if desired, you can specify in rptDetails the access permissions for * the PDF, and the password(s) for PDF access. * bUseGUI is a flag that indicates whether you want report generation to occur with a GUI (set bUseGUI to "1") or * without a GUI, ie, silently (set bUseGUI to "0"). Note that if the output is going to the printer, you can also set * bUseGUI to "2" - in this case, you'll get a full print preview window, instead of just a printer control window as you * would if bUseGUI is "1". Note that the default if bUseGUI is not specified is "0" (no GUI). * * You can also call, during SET_PRINTER, the LOADREPORT call; this will "embed" generated BRW output into OIPI * output (this is only available when using VSPRINTER2, aka OIPI.NET). You'll pass in to the SET_PRINTER call the * name of the report group, the name of the report to include ("*" for all in the group, or a semicolon-delimited list), * the overrideListName, and a flag (0/1) to indicate whether the BRW report is appended to the current output (1) or * replaces the current output (0). * * Note that in both cases (LOADREPORT in OIPI.NET, or RTI_BRW_GENERATEREPORT) you can if desired pass in a * full report definition (which is just an XML string) in the "report group" parameter. In this way, you can actually * access the report definition and modify it, or create one entirely programmatically. * If this is something you wish to do, you can use the following to read an existing report definition: * rptdef = RTI_BRWSUPPORT("READ", reportGroupName, bLockFlag) * where reportGroupName is the name of the report group, and bLockFlag is a flag to indicate whether the record * should be locked (1) or left unlocked (0). * By default, the RTI_BRW_GENERATEREPORT routine can generate one or more documents of the same output type * (PDF, print, XLS, etc.) that are all contained in a single report group. For example, to invoke * RTI_BRW_GENERATEREPORT to build a PDF based on the report “Sample Report” in the report group “SAMPLES”: // // this is the sample code from which i generated this program // * DECLARE FUNCTION RTI_BRW_GENERATEREPORT * reportGroup = “SAMPLES” * reportName = “Sample Report” * outputName = “C:\TEMP\OUTPUT.PDF” * reportType = “PDF” * bUseGUI = “0” * rslt = RTI_BRW_GENERATEREPORT(reportGroup, reportName, outputName, reportType, ‘’, ‘’, bUseGUI) * If you wish to build multiple reports (contained in the same report group) of the same output type, multiple report * names can be specified in a single request, using the semicolon delimiter. For example, to build a PDF based on * the reports “Sample Report” and “Example Output”, both contained in the “SAMPLES” report group: * DECLARE FUNCTION RTI_BRW_GENERATEREPORT * reportGroup = “SAMPLES” * reportName = “Sample Report;Example Output” * outputName = “C:\TEMP\OUTPUT.PDF” * * OI BRW 9.4 Reference Guide Page 82 of 83 * Copyright © 2013, Revelation Software. All Rights Reserved. * reportType = “PDF” * bUseGUI = “0” * rslt = RTI_BRW_GENERATEREPORT(reportGroup, reportName, outputName, reportType, ‘’, ‘’, bUseGUI) * If you wish to generate multiple different output types (for example, both PDF and print output) or output from * different report groups, these can also be created with a single call to RTI_BRW_GENERATEREPORT by using the * record mark delimiter (@RM) to delimit each report file, report name collection, output name, report type, override * list name, and GUI flag. * For example, to build a PDF based on the report “Sample Report” in the report group “SAMPLES”, and an on-screen * display of the report “Display Report” in the report group “DISPLAYS”: * DECLARE FUNCTION RTI_BRW_GENERATEREPORT * reportGroup = “SAMPLES”:@rm:”DISPLAYS” * reportName = “Sample Report”:@rm:”Display Report” * outputName = “C:\TEMP\OUTPUT.PDF”:@rm:”” * reportType = “PDF”:@rm:”PRINT” * bUseGUI = “0”:@rm:”2” * rslt = RTI_BRW_GENERATEREPORT(reportGroup, reportName, outputName, reportType, ‘’, ‘’, bUseGUI) * * As seen in the above examples, the RTI_BRW_GENERATEREPORT stored procedure is a function that can return a * status value so the developer can determine the results from the request. Note that many of the available status * values (and the parameter modifications, described below) will only be set when the BRW is configured to use a * new engine to generate its output; when configured to ‘share’ the current engine (the default), most of these * values will not be returned. * The return values are: * 0: success * -1: Either parameter “reportFile” or “reportName” is null (“”) * 1: Report definition is null – specified report is not on file * 2: unable to open SYSLISTS table * : error returned by call to the BRW component * : error returned by call to the BRW component * In addition, the RTI_BRW_GENERATEREPORT routine may modify the passed-in parameters for “reportName” and * “outputName”. If multiple reports are specified in the reportName parameter (either by using the “*” wildcard, or * explicitly by using multiple report names separated by semicolons (“;”)), when the RTI_BRW_GENERATEREPORT * completes, the reportName parameter will be changed to a full list of all the individual report names that were * accessed (@VM delimited), and the outputName parameter will be changed to a full list of all the individual output * files that were generated (one per report name), @VM delimited. * RTI_BRWSUPPORT is a handy function with a few different actions. We've already discussed LAUNCH and READ; * you can also call it with the following actions: * DISPLAY: pass in the report group name and specific report name (in parameters 2 and 3) and the report will be * displayed via OIPI.NET; * REPORTS: this will return, as the result of the function call, an @VM delimited list of the report groups defined for * your application //------------------------------------------------------------------------------ // more doc whilst dbgging this code //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // when i was stuffing about - this was an interesting 'abend', so i'm collecting it here //------------------------------------------------------------------------------ // an alternate setup - when i sent the following thru, the oenginserver console responded and this came up on web page * ConnectMode = "localhost" * EngineServerPort= "8088" * //------------------------------------------------------------------------------ * // HTTP Error 502.2 - Bad Gateway * // The specified CGI application misbehaved by not returning a complete set of HTTP headers. * // The headers it did return are "RunCommand failed - request set to *-1* for script * // *RUN INET_TRUMPH ' * /cgi-bin/oecgi4.exe/INET_TRUMPH/ * * 0 * CGI/1.1 * off * text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng, * // *\/*;q=0.8 * gsScrollPos=0; _FrogBlog_session=UG8zUVBCQ0ZOZEZ0em9ORDQ2ZlVCM2pRdmpDNm1BeUxiQlpCZGV4MWZwL0dRdlZreTRjZkJRY0V4TjFSRmZhaUxkWGljdjNXVUNo * // emdqMzNQaDBMU2ZCVWtUYWVsb2FXYk1VTnA2L01hMDBuSk1BbkxtN0lvODJYb0xna1RmTEloSmgvKzlVZitqTXR0cEorZEtJdU9BPT0tLWRmT1Y3MDM4VzAvWkJRNmVhTEFEL1E9PQ%3D%3 * // D--0ef9d7ea390903ea9f2436933ce9c308d6449777; _test_polymorphic_association_session=amNGZm5rbjlwclNDSzc5ZVU4S2FEMkg1enN3OExGZnNtemh1cWVpYW5WOHhD * // RjVSUlJRd0dzTmtMWWF4aDlvOHVWT0hGcUNJYVpBQ05kSzArT0pJOENRYm9BMXhjVWRpb0pHYW5sVnZ5dUhUem1WUElyS2hpTS9heXBITW9ib0Z2eVpsVlVyaXZ6WGN0Qk5rbEFBNDdBPT0 * // tLTYzM3VGVDNDeityQTJHTE83K092dFE9PQ%3D%3D--6d4124b81f50061b560b8c4e37f5764519bf905e; io=W7sE1y3m429h2p68AAAA; _ga=GA1.1.1292261888.1522936142 * * * // * Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.4 Safari/537.36 * * // C:\inetpub\wwwroot\cgi-bin\oecgi4.exe\INET_TRUMPH\ * ::1 * ::1 * * * GET * /cgi-bin/oecgi4.exe * localhost * 80 * HTTP/1.1 * Microsoft-IIS/10.0 * // RegistryInfo=SOFTWARE\RevSoft\OECGI4 // &EngineName=&ServerURL=127.0.0.1&ServerPort=8088&ApplicationName=MMS&UserName=MMS&StartupFlags=1&ShutdownFlags=1 // &FilePath=&FilePathMapped=&FileMode=2&SysDownPage=&OILocation=&AdditionalValues=HTTP_AUTHORIZATION%2CHTTP_MEDIA_TYPE%2CHTTP_ACCEPT_ENCODING%2C // HTTP_ACCEPT_CHARSET%2CHTTP_ACCEPT_LANGUAGE * VERSION:OECGI4 * test=20 * * gzip, deflate, bren-US,en;q=0.9'". //------------------------------------------------------------------------------