Focal Point
[CLOSED] First line of ON TABLE PCHOLD FORMAT ALPHA missing

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

September 15, 2011, 07:53 AM
Wep5622
[CLOSED] First line of ON TABLE PCHOLD FORMAT ALPHA missing
Hello all,

I'm scratching my head over this one. I have some FOCUS code that's generating parts of a Javascript data-structure and the first line of results from the TABLE FILE goes missing. I'm using ON TABLE PCHOLD FORMAT ALPHA to get the TABLE FILE output directly in my code.

However, if I write it to an ALPHA file first and then -INCLUDE that, the first line is there!

Can anyone explain what is going on here?!?

My code is thus:
-HTMLFORM BEGIN
<html>
<body>
<pre>
var masters = {
-HTMLFORM END


-* Collect hold file info
APP QUERY ibisamp HOLD
DEFINE FILE FOCAPPQ
	UPDATED/A22		= EDIT(DATE, '99-$99-$9999') | ' / ' | EDIT(TIME, '99:$99');
	LEN/I2			= ARGLEN(70, FILENAME, LEN);
	UPFILNAM/A70	= UPCASE(70, FILENAME, UPFILNAM);
	STEM0/A70		= TRIM('T', UPFILNAM, LEN, '.MAS', 4, 'A70');
	STEM1/A70		= TRIM('T', UPFILNAM, LEN, '.FOC', 4, 'A70');
END
MATCH
 FILE FOCAPPQ
  PRINT
	UPDATED AS 'MASTER_DATE'
	UPFILNAM AS 'MASTER'

  BY STEM0 AS 'STEM'

  WHERE UPFILNAM LIKE '%.MAS';
 RUN
 FILE FOCAPPQ
  PRINT
	UPDATED AS 'FOC_DATE'
	UPFILNAM AS 'FOCFIL'

  BY STEM1 AS 'STEM'

  WHERE UPFILNAM LIKE '%.FOC';
 AFTER MATCH HOLD OLD-OR-NEW
END
-RUN

DEFINE FILE HOLD
	LINE/A511 = STEM || ': { file: "' || MASTER || '", created: "' || MASTER_DATE ||
				'", focfile: { file: "' || FOCFIL || '", created: "' || FOC_DATE ||
				'" }},';
END
TABLE FILE HOLD
PRINT
	LINE
BY HIGHEST MASTER_DATE NOPRINT
BY STEM NOPRINT
-*ON TABLE HOLD AS TMP_MASTERS FORMAT ALPHA
ON TABLE PCHOLD FORMAT ALPHA
END
-RUN


-HTMLFORM BEGIN
-*-INCLUDE TMP_MASTERS
};


-HTMLFORM END


Note that the CAR.MAS master file isn't listed.

It works if I change the bottom section to:
...
BY STEM NOPRINT
ON TABLE HOLD AS TMP_MASTERS FORMAT ALPHA
-*ON TABLE PCHOLD FORMAT ALPHA
END
-RUN

-HTMLFORM BEGIN
-INCLUDE TMP_MASTERS
};
...


But I'd rather not have the extra hold file...

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


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
September 15, 2011, 05:45 PM
Waz
I guess it is something to do with what happens with format ALPHA.

With a FORMAT ALPHA, a master file is also returned describing the file.

Perhaps this is corrupting the first line.

I would suggest using your workaround.


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!

September 16, 2011, 04:24 AM
Wep5622
I thought I'd try with some other formats as well, and found that this doesn't just happen with FORMAT ALPHA, but with FORMAT TAB as well.

I suppose some people would call this a bug - I call it a dung beetle.

Time to tell IBI to fix this, I suppose.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
February 20, 2018, 06:13 AM
Gaurav
quote:
With a FORMAT ALPHA, a master file is also returned describing the file.


Any solution for this yet???


WebFOCUS 8.1.05
Windows, All Outputs
February 20, 2018, 07:22 AM
Wep5622
I seem to recall that the fix is to not switch between content types all the time.

The proper way to do this is to create the ALPHA files first and only then "include" them in the -HTMLFORM using !IBI.FIL.TMP_MASTERS;

That's actually cleaner to read too, and you can check whether you have any results before you enter HTML-space.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
February 20, 2018, 07:34 AM
Gaurav
Below is my code to create bar chart. It is skipping first line. The work around I do is to add a dummy line at the beginning. Client is Ok with it but it irks my eyes. Can you please tweak my code.

Thanks in advance.

  -HTMLFORM BEGIN

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
      google.charts.load('current', {'packages':['bar']});
      google.charts.setOnLoadCallback(drawChart);

	  function drawChart() {
	  		var data = google.visualization.arrayToDataTable([ ['Car', 'Dcost', 'Rcost', 'Sales'],

-HTMLFORM END

SET NODATA = 'null'
SET HOLDLIST = PRINTONLY

-* Generate Javascript data

DEFINE FILE CAR
	COM/A2 = ', ';
END
TABLE FILE CAR
SUM
	COMPUTE LINESTART/A80 = '[''' || CAR || ''''; AS ''

		COM AS ''
		DEALER_COST AS ''
		COM AS ''
		RETAIL_COST AS ''
		COM AS ''
		SALES AS ''

	COMPUTE LINEEND/A3 = '],'; AS ''
BY CAR NOPRINT
ON TABLE PCHOLD FORMAT ALPHA
END
-RUN

-HTMLFORM BEGIN

]);						
						var options = {
							          chart: {
							          title: 'Company Performance',
							          subtitle: 'Sales, Expenses, and Profit: 2014-2017',
							          			},
				          			  bars: 'horizontal'
						    		  };

        var chart = new google.charts.Bar(document.getElementById('barchart_material'));
		chart.draw(data, google.charts.Bar.convertOptions(options));
	}

</script>
<div id="barchart_material" style="width: 900px; height: 500px;"></div>
-HTMLFORM END

-EXIT 



WebFOCUS 8.1.05
Windows, All Outputs
February 21, 2018, 06:34 AM
Wep5622
SET NODATA = 'null'
SET HOLDLIST = PRINTONLY

-* Generate Javascript data

DEFINE FILE CAR
	COM/A2 = ', ';
END
TABLE FILE CAR
SUM
	COMPUTE LINESTART/A80 = '[''' || CAR || ''''; AS ''

		COM AS ''
		DEALER_COST AS ''
		COM AS ''
		RETAIL_COST AS ''
		COM AS ''
		SALES AS ''

	COMPUTE LINEEND/A3 = '],'; AS ''
BY CAR NOPRINT
ON TABLE HOLD AS JSDATA FORMAT ALPHA
END
-RUN

-HTMLFORM BEGIN

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
      google.charts.load('current', {'packages':['bar']});
      google.charts.setOnLoadCallback(drawChart);

	  function drawChart() {
	  		var data = google.visualization.arrayToDataTable([ ['Car', 'Dcost', 'Rcost', 'Sales'],


!IBI.FIL.JSDATA;
]);						
						var options = {
							          chart: {
							          title: 'Company Performance',
							          subtitle: 'Sales, Expenses, and Profit: 2014-2017',
							          			},
				          			  bars: 'horizontal'
						    		  };

        var chart = new google.charts.Bar(document.getElementById('barchart_material'));
		chart.draw(data, google.charts.Bar.convertOptions(options));
	}

</script>
<div id="barchart_material" style="width: 900px; height: 500px;"></div>
-HTMLFORM END

-* EXIT is a bad idea if the code gets wrapped by other procedures (ie. an RCaster job), as it's a HARD exit.
-*-EXIT



WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
February 21, 2018, 06:55 AM
Gaurav
Thanks Man Smiler
You are the BEST!


WebFOCUS 8.1.05
Windows, All Outputs