Focal Point
Changing Column Title Dynamically

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

August 22, 2006, 10:58 AM
KellyT
Changing Column Title Dynamically
Hello,

I am trying to change a column title dynamically. If the title (fleetnumber) comes across from the database as 9999 I want it to say MISC. if the column title comes across as 88 I want it to say DED. Besides those headings I also have numbers 1 - 87 that I want to leave as is.

I tried doing it through the stylesheet and through the -SET but can't seem to get it to work either way.

Thanks for the help in advance,
Kelly


Prod: WebFOCUS 8.2.0.4
OS: Windows
Outputs: HTML, PDF, Excel, PPT
In Focus since 2005
August 22, 2006, 11:26 AM
KellyT
Hi Tom,

Thanks for the quick response. Here is the code that I'm using. I got the define field to check out ok but now I can't get it to work in the reports code.

DEFINE FILE YTD$
NEWFLEETID/I4=FLEETID;
NEWTRNOV/I6=TURNOVER;
TODAY/YYMD='&YYMD';
CURRMON/YYM=TODAY;
PREVMON/YYM=CURRMON-1;
NEWDATE/YYMD=HDATE(DATE, 'YYMD');
NEWMNTH/YYM=NEWDATE;
FLDNAM2/A20='YTD';
FLDNAM3/A20='YTD Cost';
TODAYSDATE/MDYY=TODAY;
MISC/A5=
IF NEWFLEETID EQ '9999' THEN 'MISC' ELSE
IF NEWFLEETID EQ '88' THEN 'DED ' ELSE EDIT( NEWFLEETID ,'9999');
END

TABLE FILE YTD$
SUM
'YTD$.YTD$.NEWTRNOV/I8' AS ' '
BY HIGHEST 'YTD$.YTD$.NEWMNTH' AS 'Turnover'
ACROSS 'YTD$.YTD$.NEWFLEETID' AS ' '
HEADING
"EXECUTIVE SUMMARY OF OPERATIONS ACTIVITIES"
" "
"FLEET ISSUES:"
"WHERE ( NEWMNTH EQ CURRMON ) OR ( NEWMNTH EQ PREVMON );
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE SET STYLE *
UNITS=IN,
PAGESIZE='Letter',
LEFTMARGIN=0.250000,
RIGHTMARGIN=0.250000,
TOPMARGIN=0.250000,
BOTTOMMARGIN=0.250000,
SQUEEZE=ON,
ORIENTATION=PORTRAIT,
$
TYPE=REPORT,
GRID=OFF,
FONT='TIMES NEW ROMAN',
SIZE=10,
COLOR='BLACK',
BACKCOLOR='NONE',
STYLE=NORMAL,
$
TYPE=DATA,
COLUMN=N1,
FONT='ARIAL',
SIZE=9,
STYLE=BOLD,
$
TYPE=DATA,
ACROSSCOLUMN=N1,
FONT='ARIAL',
SIZE=9,
$
TYPE=TITLE,
COLUMN=N1,
FONT='ARIAL',
SIZE=9,
STYLE=BOLD,
$
TYPE=TITLE,
ACROSSCOLUMN=N1,
FONT='ARIAL',
SIZE=9,
$
TYPE=HEADING,
LINE=1,
OBJECT=TEXT,
ITEM=1,
SIZE=12,
STYLE=BOLD+UNDERLINE,
$
TYPE=HEADING,
LINE=3,
OBJECT=TEXT,
ITEM=1,
STYLE=BOLD,
$
TYPE=HEADING,
LINE=3,
OBJECT=TEXT,
ITEM=2,
STYLE=UNDERLINE,
$
TYPE=HEADING,
LINE=4,
OBJECT=TEXT,
ITEM=1,
SIZE=9,
$
TYPE=HEADING,
LINE=4,
OBJECT=FIELD,
ITEM=1,
SIZE=9,
$
TYPE=ACROSSVALUE,
ACROSS=1,
FONT='ARIAL',
SIZE=9,
STYLE=BOLD,
$
TYPE=ACROSSVALUE,
ACROSS=1,
COLOR='RED',
WHEN=N1 EQ 9999,
$
TYPE=ACROSSTITLE,
ACROSS=1,
FONT='ARIAL',
SIZE=9,
STYLE=BOLD,
$
ENDSTYLE
END


Prod: WebFOCUS 8.2.0.4
OS: Windows
Outputs: HTML, PDF, Excel, PPT
In Focus since 2005
August 22, 2006, 11:34 AM
Tony A
Kelly,

You are DEFINing the MISC field but are not using it anywhere in your code (I trapped the output to get it all).

Looking at your code though, would I be correct in thinking you want the MISC as the column title on NEWFLEETID? If so then just -
......
MISC/A5=DECODE NEWFLEETID (9999 'MISC' 88 'DED ' ELSE EDIT( NEWFLEETID ,'9999'));
END

TABLE FILE YTD$
SUM NEWTRNOV/I8 AS ' '
BY HIGHEST NEWMNTH AS 'Turnover'
ACROSS MISC AS ' '
etc.


T

p.s. enclose your code snippets in [ code] and [/code] tags (without the spaces).

This message has been edited. Last edited by: Tony A,



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 
August 22, 2006, 11:58 AM
KellyT
Hi Tom,

I am getting an error with the define field saying) SYNTAX ERROR IN DECODE ELSE CLAUSE.

MISC/A5=DECODE NEWFLEETID ('9999' 'MISC' '88' 'DED' ELSE EDIT(NEWFLEETID, '9999'));

I took from the else to the end out and I didn't get an error when I checked it.

When I put the code in the report like you said I'm only getting the DED and MISC columns now. I need all the columns 1 - 87 plus DED and MISC.

1 2 3 4 5 6 ..... DED MISC

I hope that makes sense.

Thanks for your help.


Prod: WebFOCUS 8.2.0.4
OS: Windows
Outputs: HTML, PDF, Excel, PPT
In Focus since 2005
August 22, 2006, 03:06 PM
KellyT
Hi Tom,

Thanks, that worked. Now the only other problem I have with it is that the numbers 1 - 87 are coming back as 0001, 0002, 0003, ....0087. It is putting zeros in front of it so it is A4. I can't have that either. I don't know if I need to do another define or what.

Thanks again for the help.
Kelly


Prod: WebFOCUS 8.2.0.4
OS: Windows
Outputs: HTML, PDF, Excel, PPT
In Focus since 2005
August 22, 2006, 04:13 PM
Tony A
Kelly,

The reason that you are getting 0001 etc is because of the edit. Look up the FTOA function but remember that you need to get the host numeric into a decimal or floating point value first.

Also note that the NEWFLEETID was defined as an integer so the equality test should not have the single quotes around the value.

i.e. NEWFLEETID EQ 88 and not NEWFLEETID EQ '88'

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 
August 28, 2006, 01:58 PM
KellyT
I didn't get the above code to work but here is the version I did get to work:

FLEET/A5 = FTOA(NEWFLEETID, '(D4)', FLEET);
MISC/A5 = IF (TRIM('L', FLEET, 5, ' ', 1, 'A5')) EQ '9,999' THEN 'MISC'
ELSE IF FLEET EQ ' 88' THEN 'DED'
ELSE FLEET;
END
TABLE FILE YTD$
SUM
'YTD$.YTD$.NEWTRNOV/I8' AS ' '
BY HIGHEST 'YTD$.YTD$.NEWMNTH' AS 'Turnover'
ACROSS MISC AS ' '


Thanks for everyones help


Prod: WebFOCUS 8.2.0.4
OS: Windows
Outputs: HTML, PDF, Excel, PPT
In Focus since 2005