Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] HTML Report with Excel and PDF options

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] HTML Report with Excel and PDF options
 Login/Join
 
Member
posted
Hi,
I have a selfservice app with several drill-down reports. All reports are displayed in html format like this..
-HTMLFORM BEGIN
{html}
{head} {title}{/title}{/head}
{body}
{center}
!IBI.FIL.COMREP1;
{br}
{a href="http://wfdevrp01/approot/commisson/comcac01.htm" target="_blank"}Report Definitions{/a}
{/center}
{/body}
{/html}
-HTMLFORM END

Now the requirement is to show excel and pdf gifs in the header of each report, so that the users can click the gif and re-run the same report in the format of their choice.

I will appreciate any help on how to get this done. If possible without or minimum javascript code.

Thanks

This message has been edited. Last edited by: Kerry,
 
Posts: 20 | Location: Michigan | Registered: November 23, 2004Report This Post
Expert
posted Hide Post
You will require JavaScript code to do this. You should have none or very minimal changes to make, which I can give you a hand with.

Function fnRunReport is called when clicking on an output gif image, the output type is passed. The function takes the URL of the current HTML report and calls function fnReplaceParmValue to replace the value of the OUTPUT parameter with the new setting.
(The nice thing about fnReplaceParmValue is that it can be used to replace the value of any parameter with a new value and if the parameter does not exist, it adds it to the end of the URL.)

The JavaScript:
<script language="JavaScript">
// Rerun the report replacing WebFOCUS variables -----------
function fnRunReport(vOutput)
{
// Determine if the report is run from a WebFOCUS Dashboard
vWorpPostion1 = document.URL.indexOf('Controller;jsessionid');
vWorpPostion2 = document.URL.indexOf('&IBIMR_action=MR_RUN_FEX');

if (vWorpPostion1 == -1)
{
vURL = document.URL;
}
else
{
vURL =
document.URL.substring(0,vWorpPostion1) +
'WFServlet?' +
document.URL.substring(vWorpPostion2,document.URL.length);
}

vNewURL = fnReplaceParmValue(vURL,'OUTPUT',vOutput);
vNewURL = fnReplaceParmValue(vNewURL,'RANDOM',Math.floor((Math.random()*100000)));

// Construct the FormattedReport window's features
var vFeatures =
"menubar=yes,toolbar=no,status=yes,resizable=yes,scrollbars=yes" +
",width=" + (screen.availWidth - 90) +
",height=" + (screen.availHeight - 150) +
",screenX=30,screenY=30,top=30,left=30";

// Open a new window and run the URL
FormattedReport = window.open(vNewURL,"FormattedReport",vFeatures);
}

// Function to replace the value of a selected WebFOCUS Parm with another value
function fnReplaceParmValue(vURL,vParm,vValue)
{
vParmString = '&' + vParm + '=';

vStringPosition = vURL.indexOf(vParmString);

if (vStringPosition == -1)
{
vNewURL = vURL + vParmString + vValue;
}
else
{
vNextParmPosition = vURL.indexOf("&", vStringPosition + 1);

vURLBeforeParm = vURL.substring(0, vStringPosition);

if (vNextParmPosition == -1)
vURLAfterParm = "";
else
vURLAfterParm = vURL.substring(vNextParmPosition, vURL.length);

vNewURL = vURLBeforeParm + vParmString + vValue + vURLAfterParm;
}
/*
alert("Old URL: " + "\n" + vURL + "\n" +
"New URL: " + "\n" + vNewURL);
*/
return vNewURL;
}
</script>

The HTML:
<table border="0">
<tr>
<td>
<a href="java_script:fnRunReport['PDF');" class="Navigation">
<IMG SRC="/approot/app1/media/as_pdf.gif" align="middle"></a>

<a href="java_script:fnRunReport['EXL2K');" class="Navigation">
<IMG SRC="/approot/apop1/media/as_xls2k.gif" align="middle"></a></td>
</tr>
</table>

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Member
posted Hide Post
Thank you Francis.

It worked like a charm. Since I am working outside the Dashboard, I have modified the function fnRunReport.

function fnRunReport(vOutput)
{
vURL = document.URL;
vNewURL = fnReplaceParmValue(vURL,'OUTPUT',vOutput);

// Construct the FormattedReport window's features
var vFeatures =
"menubar=yes,toolbar=no,status=yes,resizable=yes,scrollbars=yes" +
",width=" + (screen.availWidth - 90) +
",height=" + (screen.availHeight - 150) +
",screenX=30,screenY=30,top=30,left=30";

// Open a new window and run the URL
FormattedReport = window.open(vNewURL,"FormattedReport",vFeatures);
}
 
Posts: 20 | Location: Michigan | Registered: November 23, 2004Report This Post
Expert
posted Hide Post
Those were sixty-four dollar JavaScript functions!

I'm glad it worked out.

Cheers,
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
A complete example, with annotation (remove the alerts after JavaScript functions have been understood:

-SET &ECHO=ALL;

-? &

-DEFAULT &OUTPUT = 'H';
-DEFAULT &COUNTRY = 'FOC_NONE';

-SET &OUTPUT_CMD = DECODE &OUTPUT (
- 'H' 'ON TABLE HOLD AS HOLDREP1 FORMAT HTMTABLE'
- 'P' 'ON TABLE PCHOLD FORMAT PDF'
- 'E' 'ON TABLE PCHOLD FORMAT EXL2K'
- ELSE 'ERROR');

TABLE FILE CAR
SUM
SALES
BY COUNTRY

WHERE COUNTRY EQ '&COUNTRY'

&OUTPUT_CMD

END
-RUN
-IF &OUTPUT EQ 'H' GOTO REP_HTML;

-EXIT

-REP_HTML

-HTMLFORM BEGIN
<HTML>
<HEAD>
<TITLE>WebFOCUS Report</TITLE>

<script language="JavaScript">

// Replace the Output parameter with the selected format and rerun the same URL -----
function fnRerunReport(vOutput)
{
// Capture the URL of the WebFOCUS request -----------------
vURL = document.URL;
// Replace the Output parameter with the selected format ---
vNewURL = fnReplaceParmValue(vURL,'OUTPUT',vOutput);
// Replace the RANDOM parameter with a new value -----------
vNewURL = fnReplaceParmValue(vNewURL,'RANDOM',Math.floor((Math.random()*100000)));

// Construct the FormattedReport window's features ---------
var vFeatures =
"menubar=yes,toolbar=no,status=yes,resizable=yes,scrollbars=yes" +
",width=" + (screen.availWidth - 90) +
",height=" + (screen.availHeight - 150) +
",screenX=30,screenY=30,top=30,left=30";

// Open a new window and run the URL -----------------------
FormattedReport = window.open(vNewURL,"FormattedReport",vFeatures);
}

// Function to replace the value of a selected WebFOCUS Parm with another value -----
function fnReplaceParmValue(vURL,vParm,vValue)
{
alert('1 Parm name/value to replace: ' + vParm + ' / ' + vValue);

// Set up the parm string --------------------------------------------
vParmString = '&' + vParm + '=';

// Determine the beginning position of the parm in the URL string ----
vStringPosition = vURL.indexOf(vParmString);
alert('2 Beginning position of the parm in the URL string: ' + vStringPosition);
// If the parm string was not found, add it to the end of the URL string ---
if (vStringPosition == -1)
  {
  vNewURL = vURL + vParmString + vValue;
  }
else
  {
  // Determine the beginning position of the next parm in the URL string
  vNextParmPosition = vURL.indexOf("&", vStringPosition + 1);
  alert('3 Beginning position of the next parm in the URL string: ' + vNextParmPosition);
  // Determine the URL string before the selected parm ---------------
  vURLBeforeParm = vURL.substring(0, vStringPosition);
  alert('4 URL string before the selected parm: ' + vURLBeforeParm);

  // If the selected parm is the last parm in the URL string, do nothing
  if (vNextParmPosition == -1)
    {
    vURLAfterParm = "";
    }
  // If the selected parm is not the last parm in the URL string, ----
  // determine the URL string after the selected parm
  else
    {
    vURLAfterParm = vURL.substring(vNextParmPosition, vURL.length);
    alert('5 URL string after the selected parm: ' + vURLAfterParm);
    }

  // Build the new URL string ------------------------------
  vNewURL = vURLBeforeParm + vParmString + vValue + vURLAfterParm;
  alert('6 Old URL: ' + vURL);
  alert('7 New URL: ' + vNewURL);
  }

return vNewURL;
}
</SCRIPT>
</HEAD>

<BODY>
<DIV>
<FORM>
<input type="button" class="cssButton" value="Close" onClick="window.close[);">
<input type="button" class="cssButton" value="PDF"   onClick="fnRerunReport['P');">
<input type="button" class="cssButton" value="Excel" onClick="fnRerunReport['E');">
</FORM>
</DIV>

!IBI.FIL.HOLDREP1;
</BODY>
</HTML>
-HTMLFORM END

This message has been edited. Last edited by: Francis Mariani,


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Silver Member
posted Hide Post
Very cool, Francis. This is probably pie in the sky, but is there any way to add this to a stylesheet, so it could be done automatically for any report?

WF7.6 BI Dashbaord/Windows XP


Jeff Elam
WF 8 in Windows
 
Posts: 44 | Location: St. Louis | Registered: September 17, 2004Report This Post
Expert
posted Hide Post
I just stick most of this -HTMLFORM in a -INCLUDE and then use it when necessary.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
I should mention that this technique will only work when the form that originally submitted the WebFOCUS request has a METHOD of GET. One could probably use AJAX to do this for FORM METHOD POST but I haven't looked in to that.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] HTML Report with Excel and PDF options

Copyright © 1996-2020 Information Builders