Focal Point
[CLOSED] How to reference reformatted columns

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

October 25, 2012, 03:44 PM
JC Zhu
[CLOSED] How to reference reformatted columns
I need to be able to dynamically reference an ACROSS column in my procedure. I have been able to do it using the technique in the following sample code ("COLUMN=SALES(&column_num)").

-SET &column_num = 2;

TABLE FILE CAR
SUM
SALES
BY CAR
ACROSS SEATS
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
TYPE=DATA,
COLUMN=SALES(&column_num),
BACKCOLOR=GREEN,
$
ENDSTYLE
END


However, I also need to apply dynamic format based on field values in the same procedure. After I apply dynamic format, the column referencing no longer works. See following sample code.

-SET &column_num = 2;
DEFINE FILE CAR
FMT/A10 = IF CAR EQ 'BMW' THEN 'D10.2' ELSE 'D10';
END

TABLE FILE CAR
SUM
SALES/FMT
BY CAR
ACROSS SEATS
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
TYPE=DATA,
COLUMN=SALES(&column_num),
BACKCOLOR=GREEN,
$
ENDSTYLE
END


I am guessing it does not work any more because reformatting stores duplicate columns in the internal matrix, and now the referencing is just confused. Does anybody know how to tackle this?

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


WebFOCUS 7.7.3
Windows, All Outputs
October 25, 2012, 04:15 PM
susannah
do a HELP search on the terms TYPE=ACROSSVALUE and TYPE=ACROSSTITLE




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
October 25, 2012, 05:07 PM
Dan Satchell
Unfortuntaely, I think you will need to use column notation instead of column names in order to address the correct column:

-SET &column_num = 4;

DEFINE FILE CAR
FMT/A10 = IF CAR EQ 'BMW' THEN 'D10.2' ELSE 'D10';
END

TABLE FILE CAR
SUM 
SALES/FMT
BY CAR
ACROSS SEATS
ON TABLE SET PAGE-NUM NOLEAD 
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
TYPE=DATA,
COLUMN=C&column_num,
BACKCOLOR=GREEN,
$
ENDSTYLE
END



WebFOCUS 7.7.05
October 29, 2012, 04:32 PM
JC Zhu
Thanks. I actually didn't know I could use C-notation like "C&column_num". This is going to very helpful. Question: can you explain why &column_num needs to be set to 4 to reference the second across column? I tested setting it to 1 and it references the first across column. So I am confused how it actually works.


WebFOCUS 7.7.3
Windows, All Outputs
October 29, 2012, 05:14 PM
Dan Satchell
If you review the COLUMN= attribute under style sheet attributes, there are several options involving column numbers. Honestly, I am also confused as to how WebFOCUS assigns column numbers in the internal matrix. There is also a general setting that affects how the columns are numbered:

SET CNOTATION = ALL/EXPLICIT/PRINTONLY

I always try to reference columns by their column names because this makes the code much easier to understand. But sometimes (as in this case) column notation is unavoidable and I have found that experimentation is the only way to determine the correct column number to use.


WebFOCUS 7.7.05