Focal Point
Help with column headings when using "OVER".
July 11, 2006, 04:04 PM
amravHelp with column headings when using "OVER".
Gurus,
I am trying to find the efficient way of doing this.
Lets say, I have a file with data like this in 2 rows.
A1 A2 A3 A4 A5 A6
B1 B2 B3 B4 B5 B6
I want to print a report like this:
"CH1" "CH2" "CH3" <-- Column Headings.
A1 A2 A3
A4 A5 A6
B1 B2 B3
B4 B5 B6
B1 B2 B3
B4 B5 B6
I have tried the following:
TABLE FILE FILE1
COMPUTE CH1 = 'CH1' AS ''
COMPUTE CH2 = 'CH2' AS ''
COMPUTE CH3 = 'CH3' AS ''
OVER
FIELD1 AS ''
FIELD2 AS ''
FIELD3 AS ''
OVER
FIELD4 AS ''
FIELD5 AS ''
FIELD6 AS ''
END
Problem with this is, it will print column titles for every record.
Also, If I want to have subheads, they will appear above column titles.
1.Is there any better way of doing this other than using HEADING command and try to align the column headings with the printed column data ?
2.How to do styling of this kind of report ?
My requirement is to color the rows that start with A1 with a color, color the rows that start with A4 with a different color etc ?
Just to make myself more clear,
I have a file with 100 columns where I need to print each row into 5 lines(with 10 columns each) and styling each of them differently.
Thanks in advance.
USA
July 11, 2006, 06:28 PM
dwfamrav,
I don't know about an efficient way, but there does seem to be a convoluted answer to you first question.
This is a three step process. I'm assuming you want your report sorted by SORTFIELD, but if you don't care about sort order, then you should be able to combine the first two steps.
The first steps assigns a line number to every line on your report, after sorting.
TABLE FILE FILE1
PRINT
FIELD1
FIELD2
FIELD3
FIELD4
FIELD5
FIELD6
COMPUTE
LINENUM/I5 = LINENUM + 1;
BY SORTFIELD
ON TABLE HOLD AS HOLD1
END
The second step is going to create an artificial page counter. In the IMOD statement, substitute for 50 the number of lines you want on each page. We are not actually going to print the page number on the report, but we are going to use it to tell the report when to pagebreak.
DEFINE FILE HOLD1
REMAINDER/I3 = IMOD(LINENUM,50,'I3');
PAGECOUNT/I3 = IF REMAINDER EQ 0 THEN PAGECOUNT + 1 ELSE PAGECOUNT;
END
TABLE FILE HOLD
PRINT *
PAGECOUNT
REMAINDER
ON TABLE HOLD AS HOLD2
END
The third step creates 3 fields that hacontain blank except for the first line of each page, in which case they contain your column titles.
TABLE FILE HOLD2
PRINT
COMPUTE
CH1/A3 = IF LINENUM EQ 1 THEN 'CH1' ELSE
IF PAGECOUNT EQ LAST PAGECOUNT THEN ' ' ELSE 'CH1'; AS ''
COMPUTE
CH2/A3 = IF LINENUM EQ 1 THEN 'CH1' ELSE
IF PAGECOUNT EQ LAST PAGECOUNT THEN ' ' ELSE 'CH2'; AS ''
COMPUTE
CH3/A3 = IF LINENUM EQ 1 THEN 'CH1' ELSE
IF PAGECOUNT EQ LAST PAGECOUNT THEN ' ' ELSE 'CH3'; AS ''
OVER
FIELD1 AS ''
FIELD2 AS ''
FIELD3 AS ''
OVER
FIELD4 AS ''
FIELD5 AS ''
FIELD6 AS ''
BY PAGECOUNT NOPRINT PAGE-BREAK
END
You'll probably have to play with column alignments, but I think this will work, as long as you don't set the number of lines on your page (second IMOD parameter in step 2) too high or too low.
Not sure about your second question yet. I'll think on that, if someone else doesn't get you an answer soon.
dwf
July 12, 2006, 09:49 AM
amravthanks dwf for your input.
I see your point.
In my case, I want to keep the headings just once at the beginning of the report.
I guess my only way is using the HEADING command and aligning it with the data.
USA
July 12, 2006, 10:35 AM
Tony ATry using SET LINES=9999 to see if that does what you want.
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 | |
July 12, 2006, 01:57 PM
dwfSorry, amrav. I did not realize you wanted the column titles only on page 1. HEADING should work fine. You could also do this, though I don't particularly think it's any better than HEADING.
DEFINE FILE FILE1
CH1/A3 = 'CH1';
CH2/A3 = 'CH2';
CH3/A3 = 'CH3';
END
TABLE FILE FILE1
PRINT
CH1 AS ''
CH2 AS ''
CH3 AS ''
OVER
FIELD1 AS ''
FIELD2 AS ''
FIELD3 AS ''
OVER
FIELD4 AS ''
FIELD5 AS ''
FIELD6 AS ''
END
As for color, something like
TYPE=DATA, COLUMN=FIELD1, COLOR=BLUE, $
TYPE=DATA, COLUMN=FIELD2, COLOR=BLUE, $
TYPE=DATA, COLUMN=FIELD3, COLOR=BLUE, $
TYPE=DATA, COLUMN=FIELD4, COLOR=RED, $
TYPE=DATA, COLUMN=FIELD5, COLOR=RED, $
TYPE=DATA, COLUMN=FIELD6, COLOR=RED, $
etc
That's a lot of stylesheet statements, though. YOu might be able to devise some dialogue manager loops to handle that, but it would be ugly, I think.
dwf
July 12, 2006, 03:29 PM
Mikel amrav:
1. "headings just once at the beginning of the report". I think
ON TABLE SUBHEAD is a good option.
2. About the style, may be
DEFMACRO helps to organize your styling needs in this report.
Example:
TABLE FILE CAR
PRINT
COUNTRY AS ''
MODEL AS ''
RCOST AS ''
OVER
CAR AS ''
BODYTYPE AS ''
DCOST AS ''
ON TABLE SUBHEAD
"CH1<+0>CH2<+0>CH3"
ON TABLE SET STYLE *
TYPE=REPORT, GRID=OFF, $
TYPE=TABHEADING, HEADALIGN=BODY, BACKCOLOR=SILVER, STYLE=BOLD, $
DEFMACRO=A1, COLOR=RED, WHEN=COUNTRY EQ 'ENGLAND', $
DEFMACRO=A2, COLOR=BLUE, WHEN=COUNTRY EQ 'JAPAN', $
TYPE=DATA, COLUMN=P1, MACRO=A1, $
TYPE=DATA, COLUMN=P2, MACRO=A1, $
TYPE=DATA, COLUMN=P3, MACRO=A1, $
TYPE=DATA, COLUMN=P1, MACRO=A2, $
TYPE=DATA, COLUMN=P2, MACRO=A2, $
TYPE=DATA, COLUMN=P3, MACRO=A2, $
TYPE=DATA, COLUMN=P4, MACRO=A2, $
TYPE=DATA, COLUMN=P5, MACRO=A2, $
TYPE=DATA, COLUMN=P6, MACRO=A2, $
ENDSTYLE
END
Hope this helps.
Regards,
Mikel
WebFOCUS 8.1.05, 8.2.01
USA
July 13, 2006, 10:47 AM
amravI meant positioning the heading elements in HTML format.
Thanks.
USA
Kerry Zhan
Focal Point Moderator
Information Builders, Inc.