Producing BRW Reports from O4W (Reporting and Printing,Web)
Created at 24 NOV 2014 01:28PM
Producing BRW Reports from O4W
OpenInsight for Web (O4W) provides the ability to produce reports generated by the Banded Report Writer (BRW) as a PDF on the client browser. Once the PDF is generated in the browser, you can either save it or print the PDF to a local printer.
The first step is to create a banded report using the OI BRW.
This report must be assigned to a Report Group. In this example the report group is BOBPUTTHEGROUPNAMEHERE and the report name is Crew_TimeCards.
Once the report has been created in the BRW, you can directly call it from the browser after it is "published" for O4W (as described belo. However, many times your banded report will require additional input (for example, to specify a date range). If that is the case, the next step is to create a stored procedure using O4W API’s that will prompt for the report selection criteria, generate the select list that the banded report will use and then run the banded report which will generate a PDF.
SUBROUTINE O4W_ CREW_TIMECARD(CTLENTID, EVENT, REQUEST)
$INSERT O4WCOMMON
$INSERT O4WEQUATES
BEGIN CASE
CASE EVENT _EQC "CREATE"
O4WFORM()
OPEN "CALLS" TO CALL.FL ELSE
O4WError("Unable to access CALLS table")
RETURN 0
END
OPEN "LOCATIONS" TO LOC.FL ELSE
O4WError("Unable to access LOCATIONS table")
return 0
end
O4WHeader("Crewing Time Card Generation")
O4WBreak()
O4WBreak()
O4WSectionStart("mainSection", O4WMarkedOptions(1))
O4WTableStart("promptTable")
O4WText("Select show:")
O4WSetCell()
SHOWNAMES =
SHOWCODES =
call GET_SHOW_CODES("O4W_CREW_TIMECARD", shownames, showcodes)
O4WListbox(shownames, showcodes, "SHOW")
O4WSetCell("+1")
O4WText("Select location:")
locnames = ""
loccodes = ""
done = 0
call rlist("SELECT LOCATIONS BY @ID", 5)
LOOP
READNEXT ID ELSE DONE = 1
UNTIL DONE DO
READV NAME FROM LOC.FL, ID, 1 ELSE NAME = "UNKNOWN"
locnames<1,-1> = name
loccodes<1,-1> = id
REPEAT
O4WSetCell()
O4WListbox(locnames, loccodes, "LOC")
O4WSetCell("+1")
O4WText("Enter week ending date:")
O4WSetCell()
O4WDatePicker(oconv(date(), "D4/"), 20, "0", "/", "WEDATE", "WEDATE")
O4WSetCell("+1")
O4WButton("Generate…", "BTN_SEARCH")
O4WQualifyEvent("BTN_SEARCH", "CLICK")
O4WTableEnd("promptTable")
O4WSectionEnd("mainSection")
O4WSectionStart("resultSection", O4WMarkedOptions(0))
O4WSectionEnd("resultSection")
case event _eqc "CLICK"
O4WResponse()
OPEN "CALLS" TO CALL.FL ELSE
O4WError("Unable to access CALLS table")
RETURN 0
END
OPEN "SYSLISTS" TO LIST.FL ELSE
O4WError("Unable to access SYSLISTS table")
return 0
End
Open "TIME_CARD" To TIMECARD.FL Else
O4WError("Unable to access TIME_CARD table")
Return 0
End
show = o4wgetvalue("SHOW")
loc = o4wgetvalue("LOC")
wedate = o4wgetvalue("WEDATE")
IweDATE = ICONV(weDATE, "D")
IF IWEDATE = "" THEN
O4WError("Invalid date entered. Please retry")
end Else
* build work file based on these dates
IWSDATE = IWEDATE - 6
WSDATE = Oconv(IWSDATE, "D4/")
bfoundit = 0
* Logic to build Time Card record goes here
bfoundit = 1
If bfoundit then
* generate the pdf
SELSTMT = ''
SELSTMT = 'SELECT TIME_CARD WITH SHOW = "':SHOW:'" AND WITH LOCATION = "':LOC
SELSTMT = SELSTMT:'" AND WITH PERIOD_END_DATE = "':WEDATE:'" BY CREW_LNAME'
LISTID = O4WGenerateID("CREWTC")
CALL Rlist(SELSTMT, 4, LISTID)
url = "O4W_BRWREPORT?ReportName=CREW_TIMECARD&OverrideList=":LISTID:"&Attach=0"
O4WSectionStart("resultSection", O4WResponseOptions())
O4WText("Crew Time Card information selected. Press ")
O4WLink("here", O4W_LINKTYPE_NORMAL$, url, "CREWTS")
O4WText(" to generate the PDF.")
O4WSectionEnd("resultSection")
O4WDialog("resultSection", "Ready To Proceed", "Done", "BTN_DONE", "", @VM:"BTN_DONE")
end else
O4WError("No timecards available for this show/location/dates. Please retry.")
end
end
end case
return 0
Once your code is saved and compiled you must Register your O4W Procedure so that it is allowed to run.
After your O4W stored procedure is registered you will need to Register the Banded Report for use with O4W.
If we run the stored procedure we will display the following screen:
When we click the Generate button we will produce the following dialog box to the browser:
When we click the here link, the report output is produced in PDF format to the browser.