Focal Point
[SOLVED] display columns as rows.

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

January 18, 2010, 07:32 PM
Prash1983
[SOLVED] display columns as rows.
Hi All,

I have the following data in my input file:
col1 col2 col3 (This line is not present in the file. I have shown it for convinience sake)
A1 B1 C1
A2 B2 C2
A3 B3 C3

Now, I want my output as follows:

col1 A1
col2 B1
col3 C1

-----Page break-------

col1 A2
col2 B2
col3 C2

-----Page break-------

col1 A3
col2 B3
col3 C3

Please provide some information/link where I can dig into!!
Thanks!

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


webFOCUS 7.6.x,
z/OS(Mainframes),
Excel and HTML
January 18, 2010, 08:57 PM
Don Garland
Prash1983, I'm not familar with Mainframe WebFOCUS but here is an example I worked up on Windows using a DEFINE with the CAR data source. Not sure I would recomend this with a large file and if its something that needs to run quick due to the DEFINE. Also, I'm using < br > for the new lines and that's probably only going to work for HTML. Also, I had to strip some of the code to get it to display. The quotes and < from the SUBHEAD field are removed. Hope this helps.
DEFINE FILE CAR
FLIST/A256V='Length: '|EDIT(CAR.SPECS.LENGTH)|'<br>'|'Width: '|EDIT(CAR.SPECS.WIDTH)|'<br>'|'Height '|EDIT( CAR.SPECS.HEIGHT)|'<br>';
END
TABLE FILE CAR
BY 'CAR.SPECS.LENGTH' NOPRINT

ON CAR.SPECS.LENGTH SUBHEAD
" <CAR.SPECS.FLIST "
HEADING
"Rows displayed as columns"
FOOTING
""
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     UNITS=IN,
     SQUEEZE=ON,
     ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='ARIAL',
     SIZE=9,
$
TYPE=TITLE,
     STYLE=BOLD,
$
ENDSTYLE
END

This message has been edited. Last edited by: Don Garland,
January 19, 2010, 04:15 AM
GamP
If you include code in the thread, please put it between then [ code ] and [ /code ] tags, otherwise pieces of your code might be interpreted as html....

Having said that, the question could also be answered with the following:
DEFINE FILE CAR
COUNTER WITH CAR = COUNTER + 1;
END
TABLE FILE CAR
PRINT CAR 
OVER MODEL
OVER SEATS
BY COUNTER NOPRINT PAGE-BREAK
END

Hope this helps ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
January 21, 2010, 12:30 PM
Prash1983
Thanks GamP and Don!!
Solution works!
Now, I have one more question here.
Say, I need to add one more field and make the O/P as follows:
col1 A1
col2 B1
col3 C1
col4 D1 (value of D1 being 1 of 3)


-----Page break-------

col1 A2
col2 B2
col3 C2
col4 D2 (value of D2 being 2 of 3)

-----Page break-------

col1 A3
col2 B3
col3 C3
col4 D3 (value of D3 being 3 of 3)

I checked the documentation and found that TABPAGENO & TABLASTPAGE are used for numbering, but they are used to add page numbers in HEADING OR FOOTING.
How can I achieve this O/P ?


webFOCUS 7.6.x,
z/OS(Mainframes),
Excel and HTML
January 21, 2010, 01:21 PM
Prash1983
Currently I can get the output as follows:
Col4 D4 (Value of D4 is "1 OF ????")
I want to fill this "????" with total number of pages which can change depending on file's data.
Number of pages should change w.r.t. the "col1" value.
Thanks!


webFOCUS 7.6.x,
z/OS(Mainframes),
Excel and HTML
January 21, 2010, 06:05 PM
Prash1983
Hi Guys!
I did it but the way is very trivial and dissatisfying.
1) I first did "SUM CNT.A1" on the table and put the result in HOLD table.
2) Defined a new variable in the HOLD file's definition to populate the value of "SUM CNT.A1"
3) Stored the result in new HOLD table.
4) Joined the HOLD table with original table. Now, I already had the "TOTAL COUNT" value.
5) Reported in XLS as required.

Please let me know of a better solution, if you come across any.
Thanks GamP & Don once again!


webFOCUS 7.6.x,
z/OS(Mainframes),
Excel and HTML
January 22, 2010, 05:39 AM
GamP
Something like this perhaps? It looks easier than what you described and it only goes through the data once.
DEFINE FILE CAR
COUNTER/I4 WITH CAR = COUNTER + 1;
TO/I4 = 1;
END
TABLE FILE CAR
SUM TO NOPRINT
PRINT CAR 
OVER MODEL
OVER SEATS
OVER COMPUTE TXT/A12 = LJUST(12,FTOA(COUNTER,'(F4)','A4') | ' of ' | FTOA(C1,'(F4)','A4'),'A12'); AS 'Page'
BY COUNTER NOPRINT PAGE-BREAK
ON TABLE SET PAGE OFF
END

Hope this helps ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988