Focal Point
[SOLVED] HOLD 'Formatted' Output For Use In Listbox

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

July 08, 2010, 03:46 PM
Dan Pinault
[SOLVED] HOLD 'Formatted' Output For Use In Listbox
Hi all,

Consider this report output...
TABLE FILE CAR
BY COUNTRY NOPRINT AS ''
BY CAR AS ''
ON COUNTRY SUBHEAD
"---<+0><COUNTRY<+0>---"
ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
END


Ultimately I want to use this output to populate a listbox. I can't go directly to XML because I'll lose the subhead. Is there some format I can use to HOLD this output exactly as I want it and then output it to XML for my listbox?

Something like...
FILEDEF LSTHLD DISK test/LSTHLD.???
TABLE FILE CAR
BY COUNTRY NOPRINT AS ''
BY CAR AS ''
ON COUNTRY SUBHEAD
"---<+0><COUNTRY<+0>---"
ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE HOLD AS LSTHLD FORMAT ????????????
END
-RUN
TABLE FILE LSTHLD
PRINT *
ON TABLE PCHOLD FORMAT XML
END


I can't seem to find the right combination of the file extension in the FILEDEF statement and the format in the HOLD statement.

Thanks in advance for any help!

Dan

This message has been edited. Last edited by: Dan Pinault,


7.7.05M/7.7.03 HF6 on Windows Server 2003 SP2 output to whatever is required.
July 08, 2010, 04:00 PM
FrankDutch
How about creating the subhead (country names) as dummy CARs so you can mix them in the same XML file.
You may need to give these dummy cars a special sequenze to hold it as the first row per country.

what are you going to use the drop down box for?




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

July 08, 2010, 04:17 PM
Darin Lee
I'll go in the same direction as Frank. I might have a quicker answer by asking "What do you need as the contents/purpose of the list box?"
Having a subheading in a list box isn't the norm. Usually contents of a list box are selectable values.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
July 08, 2010, 04:19 PM
Dan Pinault
Interesting idea Frank. I tried doing something like
IF (COUNTRY NE LAST COUNTRY)...
but then I lost the first CAR item in the list. I'll have to give the numbering concept some think-time.

The listbox will be on an ad-hoc reporting screen. We want to display a list of fieldnames in the listbox but have them 'grouped' together by the segment name in our business view. The actual code will look more like this...
CHECK FILE CAR HOLD AS CARHLD
TABLE FILE CARHLD
BY SEGNAME NOPRINT
BY FIELDNAME AS ''
ON SEGNAME SUBHEAD
"---<+0><SEGNAME<+0>---"
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
END


I just thought it would be simpler to use the COUNTRY and CAR fields for the purpose of this thread.

Cheers!

Dan


7.7.05M/7.7.03 HF6 on Windows Server 2003 SP2 output to whatever is required.
July 08, 2010, 04:33 PM
Dan Pinault
quote:
Originally posted by Darin Lee:
Having a subheading in a list box isn't the norm. Usually contents of a list box are selectable values.


I agree Darin but the powers-that-be really want to see the list of selection items 'grouped' in some fashion. If I can get the list to work as shown above then perhaps I'll just add some javascript to not allow selection of the items whose content is like '---%'.

Not sure how else to approach this. I'm open to alternatives if you have any suggestions.

Thanks,

Dan


7.7.05M/7.7.03 HF6 on Windows Server 2003 SP2 output to whatever is required.
July 08, 2010, 05:45 PM
Darin Lee
This has got to be a near the top of my "Ugliest Code" list, but I just couldn't figure out how to get the titles in with the values. Working backwards, the only way was to have them both in the same column, but then they have to be re-sorted in the appropriate order. So here's something with the CAR file. You'll have to adjust the code accordingly to make it into a list box.

-SET &ECHO=ALL;
SET HOLDLIST=PRINTONLY
-*get all the values and assign sort orders for correlation
DEFINE FILE CAR
COUNTER/I9 WITH COUNTRY=COUNTER + 1;
NCOUNTRY/A30='-----'|COUNTRY||'-----';
END
TABLE FILE CAR
PRINT COUNTRY
     NCOUNTRY
     CAR/A30
     COUNTER
BY COUNTRY NOPRINT
BY CAR NOPRINT
ON TABLE HOLD 
END
-*get all the countries wit sort values
TABLE FILE HOLD
SUM NCOUNTRY 
    MAX.COUNTER
	COMPUTE ORDER/I1=0;
	COUNTRY
BY NCOUNTRY NOPRINT
ON TABLE HOLD AS HEADINGS FORMAT FOCUS
END
-*get all the cars with sort values
TABLE FILE HOLD
SUM CAR
	MAX.COUNTER
	COMPUTE ORDER/I1=1;
	COUNTRY
BY NCOUNTRY NOPRINT
BY CAR NOPRINT
ON TABLE HOLD AS DETAILS FORMAT FOCUS
END
-RUN
-*concatentate the hold files
USE 
DETAILS.FOC AS DETAILS
HEADINGS.FOC AS DETAILS
END
-RUN
-*read as a single file and output in sort orders
TABLE FILE DETAILS
PRINT CAR
BY COUNTRY NOPRINT
BY COUNTER NOPRINT
BY ORDER NOPRINT
BY CAR NOPRINT
END



Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
July 08, 2010, 06:00 PM
Francis Mariani
Old-fashioned non-XML method, using OPTGROUP:

SET HOLDLIST=PRINTONLY
SET HOLDFORMAT=ALPHA

TABLE FILE CAR
PRINT
COMPUTE OPTGROUP/A100 =
'<optgroup label="' || COUNTRY || '">'; NOPRINT

COMPUTE OPTVAL/A100 =
  '<option value="' || CAR || '">' || CAR || '</option>'; NOPRINT

COMPUTE OPTION/A200 =
IF COUNTRY NE LAST COUNTRY THEN OPTGROUP || OPTVAL ELSE OPTVAL;

BY COUNTRY NOPRINT
BY CAR NOPRINT

ON TABLE HOLD AS HLIST1
END
-RUN

-HTMLFORM BEGIN

<form>
<select>
!IBI.FIL.HLIST1;
</select>
</form>

-HTMLFORM END



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
July 08, 2010, 06:57 PM
Darin Lee
I would stick with the old-fashioned (Francis) as opposed to the uninformed (me) speaking of the code and not the author, of course Wink

Helps to know some more of the HTML tags. OPTGROUP would be the best/easiest way.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
July 09, 2010, 04:47 AM
GamP
But if Dan really really needs xml output, here's a way to do that:
FILEDEF HOLDCAR DISK HOLDCAR.FTM (APPEND

TABLE FILE CAR
SUM COMPUTE CFIELD/A30 = '------' | COUNTRY || '------';
BY  COUNTRY
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS HOLDCAR
END
TABLE FILE CAR
PRINT COMPUTE CFIELD/A30 = CAR;
BY COUNTRY
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS HOLDCAR
END

TABLE FILE HOLDCAR
PRINT CFIELD
BY COUNTRY NOPRINT
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE PCHOLD FORMAT XML
END



GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
July 09, 2010, 11:36 AM
Dan Pinault
GENIUS! Thanks GamP!

Yes, I really need XML. I'm trying to stay within the confines of the HTML Composer and add the least amount of extra code possible. This is great! I can use this code within the existing WebFOCUS listbox control.

This has made my day Smiler


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