Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

I had a requirement to produce a report that showed dates and times of certain events in a table. The main problme I had is that the timestamps were stored on teh server as UTC timestamps, which means when I displayed the timestamps the time was not displayed in the timezone the logged in user was in. In order to convert the timestamps to the timezone that the user was, I had to somehow get the timezone from the user's computer or webbrowser (since all time related dimensions were specific to the timezone of the WEBI server).

I was able to get the timezone from the browser using Javascript, but this was in HTML, which does not print.

It occurred to me that since we can run javascript in a WEBI report, that we could use an http redirect to launch a report and pass in any data accessible through javascript along with that redirect to a target report.

So I created a proof of concept!

Step 1: Create an empty report with no universe

Step 2: Create an empty cell in which all the Javascript will reside

Step 3: Set the cell to read as HTML

Step 4: Within the cell, add javascript to get the Timezone of the host browser

I created a variable that just gets the Current date, it is formated in the way that the Date() javascript function needs:

Date = FormatDate(CurrentDate();"Mmmm d, yyyy HH:mm:ss")

Step 5: Once we have the timesone offset, add an html redirect to launch a new report and pass the offset as a parameter to an invisible prompt

var offset = newDate.getTimezoneOffset()/60; //gets the offset in hours

window.parent.location.href = '/BOE/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID="+[DocID]+"&sType=wid&sRefresh=Y&sWindow=New&lsSOFFSET='+offset;

Full Javascript:

="<script type=\"text/javascript\">

    function convertUTCDateToLocal(date) {

        if(date != null && date != \"\") {

            var newDate = new Date(date);


            var offset = newDate.getTimezoneOffset()/60;

          //launch the target report passing in the offset as a prompt parameter

            window.parent.location.href = '/BOE/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID="+[DocID]+"&sType=wid&sRefresh=Y&sWindow=New&lsSOFFSET='+offset;



//get the date/timestamp       

var date = '"+[Date]+"';





We use window.parent.location.href so that the current report is replaced by the launched report, and so that we don't load the bobj environment inside the existing bobj environment (can produce an infinite loop)

The resulting experience is as follows:

User launches a report

User sees a blank page inside the bobj window for ~1 second

The bobj window then instantly refreshes and the target report is displayed, with the timezone offset passed as a parameter, and fully usable to for variable usage and none of the html non-printable issues we see when showing web content in a report.

Labels in this area