Focal Point
[CLOSED] Flex reports without Enable/InfoAssist

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/633100813

December 15, 2009, 11:52 AM
Norb Eckert
[CLOSED] Flex reports without Enable/InfoAssist
Hi All,

Is anyone creating Flex reports without using IB's Flex Enable and InfoAssist? That is, just writing Flex code in an HTML file and calling WebFocus in a similar fashion as writing HTML/Javascript/Ajax code making calls to WebFocus as needed from within the page?

Apparently InfoAssist needs to be licensed along with the Flex Enable product and this is cost prohibitive at this time. However, I would like to leverage Flex's capabilities to create some very Flexy WebFocus reports. If anyone is doing this could you send me some code examples to get me started? I am poring over the Flex Builder product at this time.

I hop everyone is having a wonderful holiday season in spite of the horrendous state of the world. Merry Christmas!

Norb

This message has been edited. Last edited by: Kerry,


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
December 15, 2009, 02:15 PM
Waz
I've created one app, that has some lists, pei charts, and drill downs.

For the same reason, I decided to build it my self.

The only real issue I had was parsing WebFOCUS's XML output, as it is just HTML in a wrapper.

I created a custom XML output for my data, and things worked quite well.

It is not as functionally rick as Enable but does the job.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

December 15, 2009, 02:29 PM
Norb Eckert
Hi Waz,

Thanks for the prompt reply. Good to hear that I have an alternative to using the Flex product. Can you point me to any quick start references for Flex. I'm using the trial right now. Or can you provide some brief code examples?

Thanks,

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
December 15, 2009, 02:51 PM
Waz
As for references, I only used the Flex Help, and a lot of Googling. Most of the time there were examples of what I needed.

I have a utility that will return any hold file/datasource to Flex an XML document with proper tags.

I could send it to you.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

December 15, 2009, 11:36 PM
dhagen
I did some testing with this as well. I wrote a java filter that essentially takes over the http servlet response of webfocus, and applies an xslt against the proprietor XML response thereby converting it to style of XML I want. I actually use ON TABLE PCHOLD FORMAT XMLR because that xml output keeps the column titles, report heading and footing. It's kind of neet, because you can just build the report like any other, and the xslt does the rest. All I have to do is send a single parameter to the WFServlet that is the name of the xslt I want it to use.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
December 16, 2009, 01:49 AM
Tony A
Think about it Guys, who ever said that the response from an XMLHTTP request had to be XML?

Why bother with parsing the output? Why not just send back pure HTML and dump the response into a DIV or SPAN ID? I do this alot on my own websites (admittedly using ASP but the principles the same) and it works very well. Careful construction of the JavaScript and you can have interactivity to your hearts desire!

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
December 16, 2009, 09:40 AM
dhagen
Tony,

That is a good point. When you consider that json is the most popular response type for an XMLHTTP requests these days, you are not alone in this thought. For me it all comes down to performance. I know that you know xsl(t), so you also know that using an xslt is a high performance way to transform an xml document. From a webfocus standpoint, there seems to be little to no difference between the html and xml output types (although the xml output will be smaller for larger answer sets). Now push that transformation work to the application server (tomcat, websphere etc.) that can be tuned to handle it, and will scale to support large scale deployments. It just strikes me as a more consistent approach for consuming data in a flex/ajax type environment.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
December 16, 2009, 12:55 PM
Norb Eckert
I've never heard of the XMLR output so I need to take a look at that. I usually just write my own XML output as it's easier for me to understand and then apply.

What is an "xslt"? I'm sorry but I haven't heard of that before.


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
December 16, 2009, 12:58 PM
Norb Eckert
I guess that, for me anyway, it's just clearer to parse the XML with javascript and then do what you wanna do? No?

But what you're doing certainly works as well and perhaps better and cleaner depending on the circumstances.


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
December 16, 2009, 03:04 PM
Tony A
quote:
What is an "xslt"?

Sort of style sheet for XML. It is actually more styling "rules", but will format XML for you.

I did post an example many moons ago here

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
December 16, 2009, 03:41 PM
Waz
Keep in mind that if you are Flex to do some bells and whistles, it seems to be very good and quick at parsing XML, Well Formed XML.

The XML returned by PCHOLD FORMAT XML, is difficult to use as is.

Flex likes XML with tags that are column names, not TABLE, TR, TD, etc.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

December 17, 2009, 10:04 AM
dhagen
I agree. The way I did this, the process becomes pretty simple.

The fex:
-DEFAULT &COUNTRY = 'FOC_NONE'
SET PAGE=NOPAGE
SET LINES=99999

TABLE FILE GGSALES
HEADING
"THIS IS A HEADING as of <+0> &YYMD"
SUM 
DOLLARS BUDDOLLARS
COMPUTE VARIANCE/D12 = BUDDOLLARS - DOLLARS; AS 'Variance'
BY REGION
FOOTING
"THIS IS A FOOTING"
ON TABLE PCHOLD FORMAT XMLR
END  


The URL:
http://localhost:8080/ibi_apps/WFServlet?IBIF_ex=carinstxml2&IBIAPP_app=ibisamp


The response:
<?xml version="1.0" encoding="ISO-8859-1"?>
<fxf version="2.0" data="report">
	<report records="4317" lines="4" columns="4" rows="4">
		<created by="Information Builders, Inc." focexec="@0000001"/>
		<target format="" version="" type="" destination=""/>
		<settings>
			<setting name="cdn" value="off"/>
			<setting name="grid" value="on"/>
			<page units="inches" orientation="portrait" size="letter" leftmargin="0.250" rightmargin="0.250" topmargin="0.250" bottommargin="0.250"/>
		</settings>
		<color_desc>
			<color colornum="0" textcolor="000000" backcolor="FEFFFF"/>
		</color_desc>
		<style_desc>
			<style fontnum="0" size="10" style="0" colornum="0" face="DEFAULT-PROPORTIONAL"/>
		</style_desc>
		<field_desc>
			<field fieldnum="0" focus_format="A11" fieldname="REGION" alias="E05" title="Region" description="Region code"/>
			<field fieldnum="1" focus_format="I08" fieldname="DOLLARS" alias="E11" title="Dollar Sales" description="Total dollar amount of reported sales"/>
			<field fieldnum="2" focus_format="I08" fieldname="BUDDOLLARS" alias="E13" title="Budget Dollars" description="Total sales quota in dollars"/>
			<field fieldnum="3" focus_format="D12" fieldname="VARIANCE"/>
		</field_desc>
		<column_desc>
			<col colnum="h0" class="heading" leftmargin="0" width="11" titlealign="none"/>
			<col colnum="h1" class="heading" leftmargin="13" width="12" titlealign="none"/>
			<col colnum="ch2" fieldnum="0" class="title" leftmargin="0" width="11" titlealign="none"/>
			<col colnum="ch3" fieldnum="1" class="title" leftmargin="13" width="12" titlealign="none"/>
			<col colnum="ch4" fieldnum="2" class="title" leftmargin="27" width="14" titlealign="none"/>
			<col colnum="ch5" fieldnum="3" class="title" leftmargin="43" width="15" titlealign="none"/>
			<col colnum="ch6" fieldnum="0" class="titleunderline" leftmargin="0" width="11" titlealign="none"/>
			<col colnum="ch7" fieldnum="1" class="titleunderline" leftmargin="13" width="12" titlealign="none"/>
			<col colnum="ch8" fieldnum="2" class="titleunderline" leftmargin="27" width="14" titlealign="none"/>
			<col colnum="ch9" fieldnum="3" class="titleunderline" leftmargin="43" width="15" titlealign="none"/>
			<col colnum="c10" fieldnum="0" class="data" leftmargin="0" width="11" titlealign="none"/>
			<col colnum="c11" fieldnum="1" class="data" leftmargin="13" width="12" titlealign="none"/>
			<col colnum="c12" fieldnum="2" class="data" leftmargin="27" width="14" titlealign="none"/>
			<col colnum="c13" fieldnum="3" class="data" leftmargin="43" width="15" titlealign="none"/>
			<col colnum="f14" class="footing" leftmargin="0" width="11" titlealign="none"/>
		</column_desc>
		<table pagenum="1">
			<thead>
				<tr linenum="0" linetype="heading">
					<td colnum="h0" class="heading" id="0" fontnum="0">THIS IS A HEADING as of</td>
					<td colnum="h1" class="heading" id="1" fontnum="0"> 20091216</td>
				</tr>
				<tr linenum="1" linetype="heading">
					<td colnum="ch2" class="title" id="2" fontnum="0">Region</td>
					<td colnum="ch3" class="title" id="3" fontnum="0">Dollar Sales</td>
					<td colnum="ch4" class="title" id="4" fontnum="0">Budget Dollars</td>
					<td colnum="ch5" class="title" id="5" fontnum="0">Variance</td>
				</tr>
				<tr linenum="2" linetype="heading">
					<td colnum="ch6" class="titleunderline" id="6" fontnum="0">------</td>
					<td colnum="ch7" class="titleunderline" id="7" fontnum="0">------------</td>
					<td colnum="ch8" class="titleunderline" id="8" fontnum="0">--------------</td>
					<td colnum="ch9" class="titleunderline" id="9" fontnum="0">--------</td>
				</tr>
			</thead>
			<tbody>
				<tr linenum="3" linetype="data">
					<td colnum="c10" class="data" id="10" fontnum="0">Midwest</td>
					<td colnum="c11" class="data" id="11" rawvalue="11400665" fontnum="0">11400665</td>
					<td colnum="c12" class="data" id="12" rawvalue="11194373" fontnum="0">11194373</td>
					<td colnum="c13" class="data" id="13" rawvalue="-206292" fontnum="0">-206,292</td>
				</tr>
				<tr linenum="4" linetype="data">
					<td colnum="c10" class="data" id="14" fontnum="0">Northeast</td>
					<td colnum="c11" class="data" id="15" rawvalue="11392300" fontnum="0">11392300</td>
					<td colnum="c12" class="data" id="16" rawvalue="11576921" fontnum="0">11576921</td>
					<td colnum="c13" class="data" id="17" rawvalue="184621" fontnum="0">184,621</td>
				</tr>
				<tr linenum="5" linetype="data">
					<td colnum="c10" class="data" id="18" fontnum="0">Southeast</td>
					<td colnum="c11" class="data" id="19" rawvalue="11710379" fontnum="0">11710379</td>
					<td colnum="c12" class="data" id="20" rawvalue="11807971" fontnum="0">11807971</td>
					<td colnum="c13" class="data" id="21" rawvalue="97592" fontnum="0">97,592</td>
				</tr>
				<tr linenum="6" linetype="data">
					<td colnum="c10" class="data" id="22" fontnum="0">West</td>
					<td colnum="c11" class="data" id="23" rawvalue="11652946" fontnum="0">11652946</td>
					<td colnum="c12" class="data" id="24" rawvalue="11641513" fontnum="0">11641513</td>
					<td colnum="c13" class="data" id="25" rawvalue="-11433" fontnum="0">-11,433</td>
				</tr>
			</tbody>
			<tfoot>
				<tr linenum="8" linetype="footing">
					<td colnum="f14" class="footing" id="26" fontnum="0">THIS IS A FOOTING</td>
				</tr>
			</tfoot>
		</table>
	</report>
</fxf>


Now, I change the url to identify an XSLT (I use xform as the parm name):
http://localhost:8080/ibi_apps/WFServlet?IBIF_ex=carinstxml2&IBIAPP_app=ibisamp&xform=wf_xmlr_transform  


The response:
<?xml version="1.0" encoding="UTF-8"?>
<root>
	<heading>THIS IS A HEADING as of  20091216 </heading>
	<footing>THIS IS A FOOTING </footing>
	<columns>
		<column align="left" type="alpha" title="Region">REGION</column>
		<column align="right" type="numeric" title="Dollar Sales">DOLLARS</column>
		<column align="right" type="numeric" title="Budget Dollars">BUDDOLLARS</column>
		<column align="right" type="numeric" title="Variance">VARIANCE</column>
	</columns>
	<data>
		<REGION>Midwest</REGION>
		<DOLLARS>11400665</DOLLARS>
		<BUDDOLLARS>11194373</BUDDOLLARS>
		<VARIANCE>-206292</VARIANCE>
	</data>
	<data>
		<REGION>Northeast</REGION>
		<DOLLARS>11392300</DOLLARS>
		<BUDDOLLARS>11576921</BUDDOLLARS>
		<VARIANCE>184621</VARIANCE>
	</data>
	<data>
		<REGION>Southeast</REGION>
		<DOLLARS>11710379</DOLLARS>
		<BUDDOLLARS>11807971</BUDDOLLARS>
		<VARIANCE>97592</VARIANCE>
	</data>
	<data>
		<REGION>West</REGION>
		<DOLLARS>11652946</DOLLARS>
		<BUDDOLLARS>11641513</BUDDOLLARS>
		<VARIANCE>-11433</VARIANCE>
	</data>
</root>
  


The XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format " xmlns:urldecoder="xalan://java.net.URLDecoder" exclude-result-prefixes="urldecoder">

	<!--  
		XSL Name: wf-xmlr-transform
		Purpose: To transform a standard PCHOLD FORMAT XMLR output format to a standardized XML output
			that can be easily consumed by FLEX or JS Frameworks for standardized object deployment.
	-->
	
	<!-- Load the column titles and fieldnames into a variable for later use. -->
	<xsl:variable name="title" select="/fxf/report/table/thead/tr/td[@class='title']"/>
	<xsl:variable name="fieldname" select="/fxf/report/field_desc/field/@fieldname"/>
	
	<!-- main template  -->
	<xsl:template match="/fxf/report">
		<xsl:element name="root">
			<xsl:element name="heading">
				<xsl:apply-templates select="table/thead/tr/td[@class='heading']"/>
			</xsl:element>
			<xsl:element name="footing">
				<xsl:apply-templates select="table/tfoot/tr/td[@class='footing']"/>
			</xsl:element>
			<xsl:element name="columns">
				<xsl:apply-templates select="field_desc/field"/>		
			</xsl:element>
			<xsl:apply-templates select="table/tbody/tr"/>
		</xsl:element>
	</xsl:template>
	
	<!-- heading builder. -->
	<xsl:template match="table/thead/tr/td[@class='heading']">
		<xsl:for-each select=".">
			<xsl:value-of select="concat(text(),' ')"/>
		</xsl:for-each>
	</xsl:template>

	<!-- footing builder. -->
	<xsl:template match="table/tfoot/tr/td[@class='footing']">
		<xsl:for-each select=".">
			<xsl:value-of select="concat(text(),' ')"/>
		</xsl:for-each>
	</xsl:template>
	
	<!-- column builder - includes titles, fieldnames, and alignment option. -->
	<xsl:template match="field_desc/field">
		<xsl:variable name="titlecount" select="position()"/>
		<xsl:element name="column">
			<xsl:attribute name="align">
				<xsl:call-template name="alignment">
					<!-- <xsl:value-of select="@focus_format"/> -->
					<xsl:with-param name="format" select="@focus_format"/>
				</xsl:call-template>
			</xsl:attribute>
			<xsl:attribute name="type">
				<xsl:call-template name="column_type">
					<xsl:with-param name="format" select="@focus_format"/>
				</xsl:call-template>
			</xsl:attribute>
			<xsl:attribute name="title">
				<xsl:value-of select="$title[$titlecount]"/>
			</xsl:attribute>
			<xsl:value-of select="@fieldname"/>
		</xsl:element>
	</xsl:template>
	
	<!-- data builder w/ dynamic element names to match the fieldnames. -->
	<xsl:template match="table/tbody/tr">
		<xsl:element name="data">
			<xsl:for-each select="td">
				<xsl:variable name="colpos" select="position()"/>
				<xsl:element name="{$fieldname[$colpos]}">
					<xsl:choose>
						<xsl:when test="@rawvalue">
							<xsl:value-of select="@rawvalue"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="text()"/>
						</xsl:otherwise>
					</xsl:choose>
					<!-- <xsl:value-of select="text()"/> -->
				</xsl:element>
			</xsl:for-each>
		</xsl:element>
	</xsl:template>
	
	<!-- determine alignment to be set based on the actual focus format (Note: DMY will result in incorrect format setting). -->
	<xsl:template name="alignment">
		<xsl:param name="format"/>
		<xsl:choose>
			<xsl:when test="starts-with($format,'D') or starts-with($format,'I') or starts-with($format,'P') or starts-with($format,'F')">
				<xsl:text>right</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>left</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<!-- determine alignment to be set based on the actual focus format (Note: DMY will result in incorrect format setting). -->
	<xsl:template name="column_type">
		<xsl:param name="format"/>
		<xsl:choose>
			<xsl:when test="starts-with($format,'D') or starts-with($format,'I') or starts-with($format,'P') or starts-with($format,'F')">
				<xsl:text>numeric</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>alpha</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
</xsl:stylesheet>
  


To add some extra value, if I flag the output to be JSON, then 1 line of java is used to convert the XML document to a JSON document

Json url:
http://localhost:8080/ibi_apps/WFServlet?IBIF_ex=carinstxml2&IBIAPP_app=ibisamp&xform=wf_xmlr_transform&xout=json  


The response:
{"root":
	{
		"data": 
			[
				{"VARIANCE":-57545,"BUDDOLLARS":3866856,"CITY":"Chicago","REGION":"Midwest","DOLLARS":3924401},
				{"VARIANCE":-34299,"BUDDOLLARS":3680679,"CITY":"Houston","REGION":"Midwest","DOLLARS":3714978},
				{"VARIANCE":-114448,"BUDDOLLARS":3646838,"CITY":"St. Louis","REGION":"Midwest","DOLLARS":3761286},
				{"VARIANCE":110411,"BUDDOLLARS":3818397,"CITY":"Boston","REGION":"Northeast","DOLLARS":3707986},
				{"VARIANCE":50153,"BUDDOLLARS":3832202,"CITY":"New Haven","REGION":"Northeast","DOLLARS":3782049},
				{"VARIANCE":24057,"BUDDOLLARS":3926322,"CITY":"New York","REGION":"Northeast","DOLLARS":3902265},
				{"VARIANCE":147480,"BUDDOLLARS":4247587,"CITY":"Atlanta","REGION":"Southeast","DOLLARS":4100107},
				{"VARIANCE":2922,"BUDDOLLARS":3689979,"CITY":"Memphis","REGION":"Southeast","DOLLARS":3687057},
				{"VARIANCE":-52810,"BUDDOLLARS":3870405,"CITY":"Orlando","REGION":"Southeast","DOLLARS":3923215},
				{"VARIANCE":-102519,"BUDDOLLARS":3669484,"CITY":"Los Angeles","REGION":"West","DOLLARS":3772003},
				{"VARIANCE":46605,"BUDDOLLARS":3916863,"CITY":"San Francisco","REGION":"West","DOLLARS":3870258},
				{"VARIANCE":44481,"BUDDOLLARS":4055166,"CITY":"Seattle","REGION":"West","DOLLARS":4010685}
			],
		"columns":
			{
				"column":
					[
						{"content":"REGION","title":"Region","align":"left","type":"alpha"},
						{"content":"CITY","title":"City","align":"left","type":"alpha"},
						{"content":"DOLLARS","title":"Dollar Sales","align":"right","type":"numeric"},
						{"content":"BUDDOLLARS","title":"Budget Dollars","align":"right","type":"numeric"},
						{"content":"VARIANCE","title":"Variance","align":"right","type":"numeric"}
					]
			},
		"footing":"THIS IS A FOOTING",
		"heading":"THIS IS A HEADING as of  20091216"
	}
}  



"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
December 18, 2009, 04:31 PM
Norb Eckert
Thanks for the code listing Darryl. Lots of stuff there and at this point I don't understand most of it. However, as I root around in the Flex world I'm sure it's gonna gel and THEN make lots of sense.

Appreciate your post.

Norb


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
December 18, 2009, 04:33 PM
Norb Eckert
Hi Waz,

I'll be noodling through the Flex help and power Googling as you did to learn this stuff. Thanks - I didn't expect a magic bullet (like in Mario Kart) but just wanted to make sure I wasn't missing something.

Thanks,

Norb

P.S. Hi Tony! ;-)


prod:7.6.9, win2k3 mre, caster, bid, devstudio 7.6.9
December 18, 2009, 05:49 PM
Tony A
Hey Norb,

Have a great Christmas!

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
December 18, 2009, 07:59 PM
dhagen
quote:
Originally posted by Norb Eckert:
Thanks for the code listing Darryl. Lots of stuff there and at this point I don't understand most of it. However, as I root around in the Flex world I'm sure it's gonna gel and THEN make lots of sense.


Norb,

Just remember the stuff I didn't post is all the java code to make this work, and the instructions to add it to WebFOCUS. The posted stuff above will only get you so far. If you get comfortable with the xslt stuff then drop me a line to get the rest.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
April 30, 2010, 06:37 PM
Dan Pinault
Hey all,

I tried my first Flex application using WebFOCUS generated XML and ran in to the same issues discussed here. I will definitely try dhagen's XSLT method.

Just curious, I understand IBI is working on getting the v4 Flex SDK components certified. Does anybody know if there are plans to make changes to the XML output format so those of us who don't have Flex Enable can use the data without going through all these machinations?

Otherwise, any improvements or enhancements to the technique? The last post on this was over 4 months ago.

Thanks,

Dan


7.7.05M/7.7.03 HF6 on Windows Server 2003 SP2 output to whatever is required.