A24 - Information Builders

advertisement
Introduction
1
Authors:
Francis Mariani – Francis Mariani.com (Canada)
Susannah Jones – Consultant (United States)
Anthony Alsford – EDATA Limited (United Kingdom)
Presentation Title:
Coding Standards for WebFOCUS Development
Abstract:
The Three Virtuosi from three countries, Francis, Susannah, and Anthony,
combine their near-century of experience to -
'Standards in Coding: Structure, Clarity, & Simplicity’.
2
Introduction
Designing the program
Presentation Layer
Maintainable Code
Questions
3
6. Passing the baton.
7. Modular / Reuseable code.
8. Consistent definitions.
9. Simplifies maintenance.
10. Speed of development.
TOP 10 REASONS FOR STANDARDS IN CODING
4
1. @@@@@@@@@@@@@@@@@@@@@@@
2. Big emergency?
Flip a switch, avoid a meltdown
3. Quick fix?
Might actually work
4. Major overhaul?
Instantly envision the whole thing
5. User confidence soars when your site is consistent.
TOP 10 REASONS FOR STANDARDS IN CODING
5
Fex construction
0. dictionary
1. environment variables
2. resource allocation
3. JOINs
4. DEFINEs
5. data extract(s)
6. presentation layer
7. maintainable code
6
#0.
dictionary
● list the dimensions that describe your business
● stabilize the nomenclature
concept
data codes
&varname
season
SEASON
/A1
&SEA
style
STYLE
/A8
&STY
color
COLOR
/A3
&CLR
division
DIV
/A2
&DIV
warehouse
WH
/A2
&WH
customer
CUST_ID
/A5
door
DOOR_ID
/A6
keys
code names
SEASON_NAME
/A25
KEYSS
STYLE_NAME
/A25
KEYSSC
COLOR_NAME
/A3
DIV_NAME
/A25
KEYSSCW
WH_NAME
/A25
&CUST
KEYSSCWK
CUST_NAME
/A25
&DOOR
KEYKD
DOOR_NAME
/A25
7
#0.
dictionary
● list the dimensions that describe your business
● stabilize the nomenclature
concept
data codes
&varname
season
SEASON
/A1
&SEA
style
STYLE
/A8
&STY
color
COLOR
/A3
&CLR
division
DIV
/A2
&DIV
warehouse
WH
/A2
&WH
customer
CUST_ID
/A5
door
DOOR_ID
/A6
keys
code names
SEASON_NAME
/A25
KEYSS
STYLE_NAME
/A25
KEYSSC
COLOR_NAME
/A3
DIV_NAME
/A25
KEYSSCW
WH_NAME
/A25
&CUST
KEYSSCWK
CUST_NAME
/A25
&DOOR
KEYKD
DOOR_NAME
/A25
as short as possible
8
#0.
dictionary
● list the dimensions that describe your business
● stabilize the nomenclature
concept
data codes
&varname
season
SEASON
/A1
&SEA
style
STYLE
/A8
&STY
color
COLOR
/A3
&CLR
division
DIV
/A2
&DIV
warehouse
WH
/A2
&WH
customer
CUST_ID
/A5
door
DOOR_ID
/A6
keys
code names
SEASON_NAME
/A25
KEYSS
STYLE_NAME
/A25
KEYSSC
COLOR_NAME
/A3
DIV_NAME
/A25
KEYSSCW
WH_NAME
/A25
&CUST
KEYSSCWK
CUST_NAME
/A25
&DOOR
KEYKD
DOOR_NAME
/A25
9
#0.
dictionary
● list the dimensions that describe your business
● stabilize the nomenclature
concept
data codes
&varname
season
SEASON
/A1
&SEA
style
STYLE
/A8
&STY
color
COLOR
/A3
&CLR
division
DIV
/A2
&DIV
warehouse
WH
/A2
&WH
customer
CUST_ID
/A5
door
DOOR_ID
/A6
keys
code names
SEASON_NAME
/A24
KEYSS
STYLE_NAME
/A24
KEYSSC
COLOR_NAME
/A3
DIV_NAME
/A24
KEYSSCW
WH_NAME
/A24
&CUST
KEYSSCWK
CUST_NAME
/A24
&DOOR
KEYKD
DOOR_NAME
/A24
10
#0.
dictionary
● list the dimensions that describe your business
● stabilize the nomenclature
concept
data codes
&varname
season
SEASON
/A1
&SEA
style
STYLE
/A8
&STY
color
COLOR
/A3
&CLR
division
DIV
/A2
&DIV
warehouse
WH
/A2
&WH
customer
CUST_ID
/A5
door
DOOR_ID
/A6
keys
code names
SEASON_NAME
/A24
KEYSS
STYLE_NAME
/A24
KEYSSC
COLOR_NAME
/A3
DIV_NAME
/A24
KEYSSCW
WH_NAME
/A24
&CUST
KEYSSCWK
CUST_NAME
/A24
&DOOR
KEYKD
DOOR_NAME
/A24
● list the measures
as they exist in database
different in reports
units
UNITS
/I8
UNITS/I8S
dollars
DOLLARS
/D8.2
DOLS/P11.2SM
11
Fex construction
0. dictionary
1. environment variables
2. resource allocation
3. JOINs
4. DEFINEs
5. data extract(s)
6. presentation layer
7. maintainable code
12
1. environment variables
● initialize parameters
-* makes Dept Status Report
-* second comment line
-SET &FEXNAME='myfex';
-SET &EDITDATE='5.19.07';
-DEFAULT &SEA='FOC_NONE';
-DEFAULT &STY='$*';
-DEFAULT &DIV='ALL';
for email at 1pm
-DEFAULT &CUST='B2900';
-SET &exrate= 1.20 ;
-SET &DD0 = 'myfex';
-SET &DD1 = 'myfex1';
-SET &server='\\servername\d$\';
One, 1, comment line at top,
documentation at the end !
use &FEXNAME in usage logs,
&FEXNAME and &EDITDATE in
report footings
for ‘ALL’ values of a variable,
use ‘FOC_NONE’, or ‘$*’
IF SEASON IS FOC_NONE
returns all values
nb: SEASON is /A1, so $* is too
wide; $* not for numbers
Lower case, more readable
drill-down fexes
13
● line up the equal signs
!!!
-SET &FEXNAME='myfex';
-SET &EDITDATE='5.19.07';
-DEFAULT &SEA='FOC_NONE';
-DEFAULT &STY='$*';
-DEFAULT &DIV='ALL';
-DEFAULT &CUST='B2900';
-SET &exrate=1.20 ;
-SET &DD0=‘myfex’;
-SET &DD1=‘myfex1’;
-DEFAULT &bydis=‘OFF’ ;
-DEFAULT &shwpic=0 ;
-SET &shwpicx=ABS( &shwpic
-1)
;
14
● line up the equal signs
!!!
-SET &FEXNAME
-SET &EDITDATE
-DEFAULT &SEA
-DEFAULT &STY
-DEFAULT &DIV
-DEFAULT &CUST
-SET &exrate
-SET &DD0
=
=
=
=
=
=
=
=
'myfex';
'5.19.07';
'FOC_NONE';
'$*';
'ALL';
'B2900';
1.20 ;
‘myfex’;
-SET &DD1
= ‘myfex1’;
-DEFAULT &bydis
= ‘OFF’ ;
-DEFAULT &shwpic
= 0 ;
-SET &shwpicx
= ABS( &shwpic - 1 );
but never use TAB key
Use 0 and 1 for booleans,
not ON and OFF,
or YES and NO
● next, complete your environmental variables
SET ASNAMES
= ON
SET LINES
= 998
SET PAGE
= NOPAGE
SET BYDISPLAY
= &bydis
15
Fex construction
0. dictionary
1. environment variables
2. resource allocation
3. JOINs
4. DEFINEs
5. data extract(s)
6. presentation layer
7. maintainable code
16
2. resource allocation
● use input parameters for data directories
USE
D:\IBI\APPS\&DIV|\INVENTORY.FOC
D:\IBI\APPS\&CUST|\ORDERS2007.FOC AS ORDERS
D:\IBI\APPS\&CUST|\ORDERS2006.FOC AS ORDERS
\\servername\d$\IBI\APPS\&CUST|\ORDERS2005.FOC AS ORDERS
END
FILEDEF DECODEDV DISK &servername|IBI\APPS\DECODEDV.FTM
17
2. resource allocation
● use input parameters for data directories
USE
D:\IBI\APPS\&DIV|\INVENTORY.FOC
D:\IBI\APPS\&CUST|\ORDERS2007.FOC AS ORDERS
D:\IBI\APPS\&CUST|\ORDERS2006.FOC AS ORDERS
\\servername\d$\IBI\APPS\&CUST|\ORDERS2005.FOC AS ORDERS
END
FILEDEF DECODEDV DISK &servername|IBI\APPS\DECODEDV.FTM
● make report headers from input parameters
use a decode file
-DEFAULT &DIV
= ‘DR’;
FILEDEF DECODEDV DISK D:\IBI\APPS\DECODEDV.FTM
-RUN
-SET &headerdiv
= IF &DIV IS ‘ALL’ THEN ‘all divisions’
ELSE DECODE &DIV(DECODEDV);
-TYPE &|headerdiv = &headerdiv
&headerdiv = Dresses Division
18
What’s a decode file?
Take a look at the EDUCFILE… see how COURSE_NAME is repeated?
Make a DECODECC file
with a code snippet…
TABLE FILE EDUCFILE
SUM
COMPUTE BLANK/A1 = ' ';
COMPUTE NAME/A32 = '''' | COURSE_NAME || '''' ;
BY COURSE_CODE
ON TABLE SAVE AS DECODECC
END
19
2. resource allocation
● use input parameters for data directories
USE
D:\IBI\APPS\&DIV|\INVENTORY.FOC
D:\IBI\APPS\&CUST|\ORDERS2007.FOC AS ORDERS
D:\IBI\APPS\&CUST|\ORDERS2006.FOC AS ORDERS
\\servername\d$\IBI\APPS\&CUST|\ORDERS2005.FOC AS ORDERS
END
FILEDEF DECODEDV DISK &servername|IBI\APPS\DECODEDV.FTM
● make report headers from input parameters
FILEDEF DECODEDV DISK D:\IBI\APPS\DECODEDV.FTM
-RUN
-SET &headerdiv = IF &DIV IS ‘ALL’ THEN ‘all divisions’
ELSE DECODE &DIV(DECODEDV);
● make filters from input parameters
-SET &FILTERDIV =
-
IF &DIV IS ‘ALL’ THEN ‘
‘IF DIV IS ‘ | &DIV ;
‘ ELSE
20
Fex construction
0. dictionary
1. environment variables
2. resource allocation
3. JOINs
4. DEFINEs
5. data extract(s)
6. presentation layer
7. maintainable code
21
3. JOINs
● Clear your joins before making new ones; its just a good habit
JOIN CLEAR *
● Label your joins
JOIN KEY IN host TO KEY IN guest AS JPROD
to refer to them specifically,
to clear when necessary
JOIN CLEAR JPROD
● Use TAG syntax when duplicated field names occur across files
it allows you to use syntax as in SQL T1.[fieldname]
JOIN KEY IN INVENTRY TO KEY IN PRODUCT TAG T1 AS JPROD
END
TABLE FILE
SUM ….BY INVENTRY.prod_no BY PRODNAME
…or
TABLE FILE INVENTORY
SUM ….BY T1.inv_no BY PRODNAME
22
3. JOINs
● Use TAG syntax when joining twice
FIELD=SHIP_CODE,.. $
FIELD=SHIP_FROM,.. $
FIELD=SHIP_TO, .. $
. . .
FIELD=SHIP_CODE,
.. $
FIELD=CUSTOMERNAME,.. $
FIELD=ADDRESS,
.. $
. . .
JOIN SHIP_FROM IN host TO SHIP_CODE IN guest TAG T1 AS JCUST1
JOIN SHIP_TO
IN host TO SHIP_CODE IN guest TAG T2 AS JCUST2
END
TABLE FILE host
PRINT SHIP_FROM T1.CUSTOMERNAME
SHIP_TO T2.CUSTOMERNAME
23
Fex construction
0. dictionary
1. environment variables
2. resource allocation
3. JOINs
4. DEFINEs
5. data extract(s)
6. presentation layer
7. maintainable code
24
4. DEFINEs
● Clear your DEFINES not quite as important
JOIN statements clear DEFINE statements
DEFINE FILE fn CLEAR
DEFINE FILE fn ADD
SET KEEPDEFINES ON
except…
DEFINE FILE HOLD
. . .
END
TABLE FILE HOLD . . .
ON TABLE HOLD
END
...
These DEFINEs
will still apply to
this HOLD file
25
4. DEFINEs
● lowercase
DEFINE FILE CAR
icost/D8
= IF COUNTRY EQ ‘FRANCE’ THEN
ELSE
COST ;
COGS/P11M
= icost * SALES ;
MN6/A6
= F_MN6('200705');
END
COST * &exrate
26
4. DEFINEs
● lowercase
DEFINE FILE CAR
icost/D8
= IF COUNTRY EQ ‘FRANCE’ THEN
ELSE
COST ;
COGS/P11M
= icost * SALES ;
MN6/A6
= F_MN6('200705');
END
● UPPERcase
COGS/P11M
COST * &exrate
= icost * SALES ;
27
4. DEFINEs
● lowercase
DEFINE FILE CAR
icost/D8
= IF COUNTRY EQ ‘FRANCE’ THEN
ELSE
COST ;
COGS/P11M
= icost * SALES ;
MN6/A6
= F_MN6('200705');
END
● UPPERcase
COGS/P11M
COST * &exrate
= icost * SALES ;
● define business rules in FUNCTIONs , put in edasprof
DEFINE FUNCTION F_MN6(YYM/A6)
yy1/A2
= EDIT(YYM,'$$99');
month/A2 = EDIT(YYM,'$$$$99');
mn3/A3
= DECODE month(01 Jan 02 Feb 03 Mar 04 Apr 05 May 06 Jun
07 Jul 08 Aug 09 Sep 10 Oct 11 Nov 12 Dec ELSE ' ');
F_MN6/A6 = mn3 | ' ' | yy1 ;
END
MN6/A6=F_MN6('200705');
- - -> May 07
28
#0.
dictionary
● list the dimensions that describe your business
● stabilize the nomenclature
concept
data codes
&varname
season
SEASON
/A1
&SEA
style
STYLE
/A8
&STY
color
COLOR
/A3
&CLR
division
DIV
/A2
&DIV
warehouse
WH
/A2
&WH
customer
CUST_ID
/A5
door
DOOR_ID
/A6
keys
code names
SEASON_NAME
/A24
KEYSS
STYLE_NAME
/A24
KEYSSC
COLOR_NAME
/A3
DIV_NAME
/A24
KEYSSCW
WH_NAME
/A24
&CUST
KEYSSCWK
CUST_NAME
/A24
&DOOR
KEYKD
DOOR_NAME
/A24
● list the measures
as they exist in database
different in reports
units
UNITS
/I8
UNITS/I8S
dollars
DOLLARS
/D8.2
DOLS/P11.2SM
cost of goods sold
COGS/P11M
● and functions
display
date
YYM
/A6
F_YYM/A6
e.g. 200705 -> May 07
29
Fex construction
0. dictionary
1. environment variables
2. resource allocation
3. JOINs
4. DEFINEs
5. data extract(s)
6. presentation layer
7. maintainable code
30
5. EXTRACT
● filters in the first phase
TABLE FILE CAR
&FILTERCAR
&FILTERCNTRY
&FILTERSEATS
SUM SALES BY COUNTRY BY CAR
ON TABLE HOLD
12-character name limit
went away!
● the interim HOLD file, name it something other than HOLD
TABLE FILE CAR
&FILTERCAR . . .
SUM SALES BY COUNTRY BY CAR
ON TABLE HOLD AS HCAR1
END
-RUN
TABLE FILE HCAR1
SUM SALES BY
ON TABLE HOLD AS HCAR2
END
31
5. EXTRACT
● lowercase for branching,
easier to separate from the true body of your logic.
TABLE FILE CAR
SUM
-GOTO by.&BYFIELD ;
-by.COUNTRY
BY COUNTRY AS ‘manufacturing country’
-GOTO by.end ;
-by.CAR
BY CAR
AS ‘car’
-GOTO by.end ;
-by.end
ON TABLE. . .
END
-RUN
-IF &FOCERRNUM NE 0 THEN GOTO . . .
● check for compile errors after every paragraph , and handle…
so that your fex doesn’t continue, and process incorrectly.
32
5. EXTRACT
Readability:
Its all about readability.
Next year when you go back to look at your fex,
the more readable you’ve made it,
the faster you’ll remember what you did .
● align your AS phrases:
SUM
FIELDONE AS ‘some nice label’
FLDTWO
AS ‘some other label’
33
5. EXTRACT
Readability:
Its all about readability.
Next year when you go back to look at your fex,
the more readable you’ve made it,
the faster you’ll remember what you did .
● align your AS phrases:
SUM
FIELDONE AS ‘some nice label’
FLDTWO
AS ‘some other label’
● separate lines for fieldnames,
easier to count columns for your compute statements.
SUM
FIELDONE
AS ‘some nice label’
FLDTWO
AS ‘some other label’
FLD3
AS ‘some nice title’
COMPUTE FLD4/I8=C1+C2+C3; AS ‘nice summary’
34
5. EXTRACT
● conditional display:
-SET &field1np = IF … THEN ‘ ‘ ELSE ‘ NOPRINT ‘;
-SET &fieldtwonp = IF … THEN ‘ ‘ ELSE ‘-*’;
SUM
FIELDONE AS ‘some nice label’ &field1np
&fieldtwonp.EVAL FLDTWO
AS ‘some other label’
35
5. EXTRACT
● conditional display:
-SET &field1np = IF … THEN ‘ ‘ ELSE ‘ NOPRINT ‘;
-SET &field2np = IF … THEN ‘ ‘ ELSE ‘-*’;
SUM
FIELDONE
&field2np.EVAL FLDTWO
AS ‘some nice label’ &field1np
AS ‘some other label’
36
5. EXTRACT
● conditional display:
-SET &field1np = IF … THEN ‘ ‘ ELSE ‘ NOPRINT ‘;
-SET &field2np = IF … THEN ‘ ‘ ELSE ‘-*’;
SUM
FIELDONE
&field2np.EVAL FLDTWO
AS ‘some nice label’ &field1np
AS ‘some other label’
● in-line documentation
-SET &field1np = IF … THEN ‘ ‘ ELSE ‘ NOPRINT ‘;
-SET &field2np = IF … THEN ‘ ‘ ELSE ‘-*’;
-*
lower case and right
SUM
FIELDONE
AS ‘some nice label’ &field2np
&field2np.EVAL FLDTWO AS ‘some other label’
-* . . . . . . . . . . . . . . . . . . added for Lucy 9/07
AND COMPUTE RATE/D3%=FIELDONE/FLDTWO;
37
5. EXTRACT
● drilldowns:
The payoff for short names
and
boolean switches
character length of a url in IE is limited to
~2k
focexec=&DD0(SEA = ‘&SEA’ DIV=‘&DIV’ CUST=‘&CUST’ \
STY = ‘&STY’ SHWPIC= &SHWPIC ) , $
TYPE=CUSTOMERNAME,
DRILLMENUITEM=‘click for picture’,
focexec=&DD0(SEA = ‘&SEA’ DIV=‘&DIV’ CUST=
STY = ‘&STY’ SHWPIC= &SHWPICX
DRILLMENUITEM=‘click for detail’,
focexec=&DD1(SEA = ‘&SEA’ DIV=‘&DIV’ CUST=
STY = ‘&STY’ SHWPIC= &SHWPIC
$
CUSTID \
) ,
CUSTID \
) ,
38
5. EXTRACT
● drilldowns:
The payoff for short names
and
booleans.
character length is limited to ~ 2k
focexec=&DD0(SEA = ‘&SEA’ DIV=‘&DIV’ CUST=‘&CUST’ \
STY = ‘&STY’ SHWPIC= &SHWPIC ) , $
TYPE=CUSTOMERNAME,
DRILLMENUITEM=‘click for picture’,
focexec=&DD0(SEA = ‘&SEA’ DIV=‘&DIV’ CUST=
STY = ‘&STY’ SHWPIC= &SHWPICX
DRILLMENUITEM=‘click for detail’,
focexec=&DD1(SEA = ‘&SEA’ DIV=‘&DIV’ CUST=
STY = ‘&STY’ SHWPIC= &SHWPIC
$
CUSTID \
) ,
CUSTID \
) ,
● Elegant code is beautiful, fun to write, but self-indulgent.
Clarity and self-documenting code beats elegance.
39
Fex construction
0. dictionary
1. environment variables
2. resource allocation
3. JOINs
4. DEFINEs
5. data extract(s)
6. presentation layer
7. maintainable code
40
• Importance of Presentation
6. Presentation Layer
– A well presented layout will have
• The heading identifying the content
• The user able to discern the facts from the report
• Enough information about the report
– program, date and time, user, pages etc.
• Readability without aides
• Due consideration to colour usage
– Using Company colour scheme to promote Corporate image
– Garish colours do not encourage end users to utilise reports
– Too many colours can detract from content
– Differing output formats do not support certain colours
– Use colour codes instead of names
– Printed / Viewed only report requirements
– Excessive colours can be expensive on toner!!
41
•
Report Sections
– Heading
• Corporate Image?
• Report title(s)
– Domain (Department?)
– Reporting Group
– Report description
– Report level – Summary, Detail
• Parameters
– Date range selections
– Verbose text not codes
Report Heading
Report Subheading 1
Report Subheading 2
Report Subheading 3
Report Dates
Report Parameter 1
Report Parameter 2
Report Parameter 3
Report Parameter 4
Report Parameter 5
Report Parameter 6
Report Parameter 7
Report Parameter 8
42
•
Report Sections
– Footing
• Date and time of creation
– Know to which time frame the report relates
• User identity
– Who created the report
» Batch
» Individual via portal
• Page numbering
– What page is this?
– How many pages?
• Data sensitivity
– Commercial in Confidence
• Program information?
– Consider support requirements as well
Produced by: UserId
Page x of y
Created on : Date at Time
43
•
Report Sections
– Report Body
• Well laid out
– Can the User discern the facts?
– Is the report easily readable
» Report audience with disabilities
• Consider disparate output pitfalls
– Image locations differ between HTML and PDF
» URL resource or embedded
– Is the report paneled in PDF?
» Have different report layouts with Sub Heads on sort fields
» SQUEEZE or WRAP wide columns
» Output via Report Caster (Report Broker)
– Single Excel output
» SET PAGE-NUM = OFF
– Multiple worksheet bursting
» ON TABLE PCHOLD FORMAT EXL2K BYTOC
• Data density - Verbose or sparse
– BYDISPLAY
44
•
Report Styling
– Content - colouring, imaging and report usage
• Corporate colour scheme
• Avoid garish colours
– Red and Green together – Ugh!
RED
GREEN
• Images and / or Corporate logo
– Avoid domination of report heading
• Data type styling
– Negative values
» Braced
» Coloured red
• Fonts and Sizing
– Three (generally available) main faces – arial, verdana, trebuchet
– Disparate output formats
– Special report usage
» OCR
• Printing a report
– Will the report print equally as well in colour as mono?
45
•
Report Styling
– Specific tips on using colours
• Use codes instead of names
– Use Web page advice
Colorsontheweb.com
» Using “websafe” colour ranges
» #00, #33, #66, #99, #CC, #FF
– Some colour printers are not able to discriminate
» Closely related colours print the same
• Do not use too many colours
– Can make a report unbearable to view
– Some people have Colour blindness
– Fonts and Sizing
• Are internal reports to be styled differently to external?
– Separate styling code modules (CSS, WebFOCUS Style etc.)
• Report special usage
– Disabled person(s) as target audience
– Particular layout requirement (e.g. OCR)
46
Fex construction
0. dictionary
1. environment variables
2. resource allocation
3. JOINs
4. DEFINEs
5. data extract(s)
6. presentation layer
7. maintainable code
47
7. Maintainable Code
• Design of components
– Flexibility of report static components
• Header, Footer, Imagery
• Image physical locations for differing output formats
– PDF and HTML require different locations
– Will the report be used via Report Caster
» Well formed or complete URLs (excl. PDF)
• Parameterise
• Well formed and laid out
– Program synopsis in header
– Indentation
– Code blocks
– Aligned
– Commented (Documented)
– Consistent
48
An example– A typical report layout
Report Heading
Report Subheading 1
Report Subheading 2
Report Subheading 3
Report Dates
Report Parameter 1
Report Parameter 2
Report Parameter 3
Report Parameter 4
Report Parameter 5
Report Parameter 6
Report Parameter 7
Report Parameter 8
Produced by: UserId
Page x of y
Created on : Date at Time
49
An example – Coding the “flexible” heading and footing
HEADING
" <+0 &Rep_Heading"
" <+0 &Rep_Heading1"
" <+0 &Rep_Heading2"
" <+0 &Rep_Heading3"
"&Rep_Dates <+0 "
-* Only show those parameter lines that contain data.
-IF &Rep_Parms1.LENGTH LE 1 AND &Rep_Parms2.LENGTH LE
"&Rep_Parms1 <+0>&Rep_Parms2"
-:SkipPrm1;
-IF &Rep_Parms3.LENGTH LE 1 AND &Rep_Parms4.LENGTH LE
"&Rep_Parms3 <+0>&Rep_Parms4"
-:SkipPrm2;
-IF &Rep_Parms5.LENGTH LE 1 AND &Rep_Parms6.LENGTH LE
"&Rep_Parms5 <+0>&Rep_Parms6"
-:SkipPrm3;
-IF &Rep_Parms7.LENGTH LE 1 AND &Rep_Parms8.LENGTH LE
"&Rep_Parms7 <+0>&Rep_Parms8"
-:SkipPrm4;
1 THEN :SkipPrm1;
1 THEN :SkipPrm2;
1 THEN :SkipPrm3;
1 THEN :SkipPrm4;
FOOTING BOTTOM
"Produced by: &Userid <+0>Page:<TABPAGENO of <TABLASTPAGE<+0>Created on: &RepDate at &RepTime"
50
An example – Default variables used in heading and footing
-* Default report variables to ensure focexec doesn't prompt or fail
-DEFAULT &WFFMT
= 'HTML'
-DEFAULT &Rep_Heading = 'Possible WebFOCUS Standard'
-DEFAULT &Rep_Heading1 = ''
-DEFAULT &Rep_Heading2 = ''
-DEFAULT &Rep_Heading3 = 'Reporting Criteria:'
-DEFAULT &Rep_Dates
= ''
-DEFAULT &Rep_Parms1
= '' , &Rep_Parms2 = '' , &Rep_Parms3 = '' , &Rep_Parms4 = ''
-DEFAULT &Rep_Parms5
= '' , &Rep_Parms6 = '' , &Rep_Parms7 = '' , &Rep_Parms8 = ''
-SET &Userid
= GETUSER(USERID);
-SET &RepDate
= &DATEtDMYY;
-SET &RepTime
= EDIT(&TOD,'99$:99$:99');
51
An example – WebFOCUS style sheet - cover main output formats
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
LINE=1,
LINE=1,
LINE=2,
LINE=2,
LINE=3,
LINE=3,
LINE=4,
LINE=4,
LINE=5,
LINE=5,
LINE=6,
LINE=6,
LINE=7,
LINE=7,
LINE=8,
LINE=8,
LINE=9,
LINE=9,
ITEM=1,
ITEM=2,
ITEM=1,
ITEM=2,
ITEM=1,
ITEM=2,
ITEM=1,
ITEM=2,
ITEM=1,
ITEM=2,
ITEM=1,
ITEM=2,
ITEM=1,
ITEM=2,
ITEM=1,
ITEM=2,
ITEM=1,
ITEM=2,
CLASS=Headline1a,
CLASS=Headline1b,
CLASS=HeadLine2a,
CLASS=HeadLine2b,
CLASS=HeadLine3a,
CLASS=HeadLine3b,
CLASS=HeadLine4,
CLASS=HeadLine4,
CLASS=HeadLine5,
CLASS=HeadLine5,
CLASS=HeadLine6,
CLASS=HeadLine6,
CLASS=HeadLine6,
CLASS=HeadLine6,
CLASS=HeadLine6,
CLASS=HeadLine6,
CLASS=HeadLine6,
CLASS=HeadLine6,
WIDTH=1.75,
WIDTH=5.75,
WIDTH=1.75,
WIDTH=5.75,
WIDTH=1.75,
WIDTH=5.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
JUSTIFY=LEFT,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
TYPE=FOOTING,
TYPE=FOOTING,
TYPE=FOOTING,
TYPE=FOOTING,
TYPE=FOOTING,
TYPE=FOOTING,
LINE=1,
LINE=1,
LINE=1,
LINE=1,
LINE=1,
LINE=1,
ITEM=1,
ITEM=2,
ITEM=3,
ITEM=4,
ITEM=5,
ITEM=6,
CLASS=FootPart1,
CLASS=FootPart2,
CLASS=FootPart3,
CLASS=FootPart3,
CLASS=FootPart3,
CLASS=FootPart4,
WIDTH=2.62,
WIDTH=0.90,
WIDTH=0.15,
WIDTH=0.15,
WIDTH=0.15,
WIDTH=3.37,
JUSTIFY=LEFT,
JUSTIFY=RIGHT,
JUSTIFY=CENTER,
JUSTIFY=CENTER,
JUSTIFY=CENTER,
JUSTIFY=RIGHT,
SIZE=14,$
SIZE=14,$
SIZE=12,$
SIZE=12,$
SIZE=10,$
SIZE=10,$
SIZE=10,$
SIZE=10,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
STYLE=BOLD,
SIZE=8,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
SIZE=8,$
52
An example – Using external Cascading Style Sheets – HTML control
.HeadLine1a {font-family:Tahoma; font-size:14pt; font-weight:bold; color:#000000;
background-color:#FFFFFF; width:29%; text-align:left; border-style: NONE;}
.HeadLine1b {font-family:Tahoma; font-size:14pt; font-weight:bold; color:#000000;
background-color:#FFFFFF; width:69%; text-align:left; border-style: NONE;}
.HeadLine2a {font-family:Tahoma; font-size:12pt; font-weight:bold; color:#000000;
background-color:#FFFFFF; width:29%; text-align:left; border-style: NONE;}
.HeadLine2b {font-family:Tahoma; font-size:12pt; font-weight:bold; color:#000000;
background-color:#FFFFFF; width:69%; text-align:left; border-style: NONE;}
.HeadLine3a {font-family:Tahoma; font-size:10pt; font-weight:bold; color:#000000;
background-color:#FFFFFF; width:29%; text-align:left; border-style: NONE;}
.HeadLine3b {font-family:Tahoma; font-size:10pt; font-weight:bold; color:#000000;
background-color:#FFFFFF; width:69%; text-align:left; border-style: NONE;}
.HeadLine4 {font-family:Tahoma; font-size:10pt; font-weight:bold; color:#000000;
background-color:#FFFFFF; width:49%; text-align:left; border-style: NONE;}
.HeadLine5 {font-family:Tahoma; font-size:8pt; font-weight:bold; color:#000000;
background-color:#FFFFFF; width:49%; text-align:left; border-style: NONE;}
.HeadLine6 {font-family:Tahoma; font-size:8pt; font-weight:bold; color:#000000;
background-color:#FFFFFF; width:49%; text-align:left; vertical-align:middle;
border-style: NONE;}
.FootPart1 {font-family:Tahoma; font-size:8pt; font-weight:normal; color:#000000;
background-color:#FFFFFF; width:35%; text-align:left; border-style: NONE;}
.FootPart2 {font-family:Tahoma; font-size:8pt; font-weight:normal; color:#000000;
background-color:#FFFFFF; width:12%; text-align:right; border-style: NONE;}
.FootPart3 {font-family:Tahoma; font-size:8pt; font-weight:normal; color:#000000;
background-color:#FFFFFF; width:2%; text-align:center; border-style: NONE;}
.FootPart4 {font-family:Tahoma; font-size:8pt; font-weight:normal; color:#000000;
background-color:#FFFFFF; width:45%; text-align:right; border-style: NONE;}
53
7. Reusable Code
• Reusability of components
– Coding modules
• Parameterise
• Reduction of maintenance
– One change fixes all
• Decreases development time
– Ease of Usage by Power Users in End User reporting
– Consistency across BI
• Easier learning curve
– of learning complexities of style sheets
55
Reducing code development and maintenance timings
-INCLUDE std_init
DEFINE FILE CAR
IMG/A36 WITH COUNTRY MISSING ON = IF '&WFFMT' EQ 'EXL2K'
THEN '<img src=&ImageFile border=0>' ELSE MISSING;
END
TABLE FILE CAR
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SUM RCOST
AS 'Retail Cost'
-* Focexec: std_init.fex
DCOST
AS 'Dealer Cost'
-*
-* Author: Anthony Alsford - EDATA Limited
BY COUNTRY AS 'Country'
-*
SUM RCOST
AS 'Retail Cost'
-* Date:
29 August 2006
-*
DCOST
AS 'Dealer Cost'
-* Project: IBI User Conference 2007
BY COUNTRY
-*
WebFOCUS Reporting Standards
-*
BY CAR
AS 'Car'
-* Purpose: Provide initialisation procedure for standard
SUM RCOST
AS 'Retail Cost'
-*
reporting within WebFOCUS.
-*
DCOST
AS 'Dealer Cost'
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BY COUNTRY
-DEFAULT &WFFMT = 'HTML'
-SET &ImageFile = IF '&WFFMT.EVAL' EQ 'PDF' THEN 'web.gif' ELSE '/ibi_html/web.gif';
BY CAR
-SET &ImagePos = IF '&WFFMT.EVAL' EQ 'PDF' THEN ' POSITION=(5.50 0.00), ' ELSE '';
BY MODEL
AS 'Model'
-DEFAULT &Rep_Heading = 'Focus on Developers'
-DEFAULT &Rep_Heading1 = 'Thought provoking Style'
-INCLUDE std_head
-DEFAULT &Rep_Heading2 = ''
-INCLUDE std_foot
-DEFAULT &Rep_Dates = ''
&Rep_Parms1 = '' , &Rep_Parms2 = '' , &Rep_Parms3 = '' , &Rep_Parms4 = ''
ON TABLE PCHOLD FORMAT &WFFMT -DEFAULT
-DEFAULT &Rep_Parms5 = '' , &Rep_Parms6 = '' , &Rep_Parms7 = '' , &Rep_Parms8 = ''
ON TABLE SET HTMLCSS ON
-SET &Userid = GETUSER(USERID);
-SET &RepDate = &DATEtDMYY;
ON TABLE SET STYLE *
-SET &RepTime = EDIT(&TOD,'99$:99$:99');
-INCLUDE std_style
-RUN
SET CSSURL = '/approot/standards/standard.css'
ENDSTYLE
SET HTMLCSS = ON
END
SET NODATA = ''
-RUN
56
Reducing code development and maintenance timings
-INCLUDE std_init
DEFINE FILE CAR
IMG/A36 WITH COUNTRY MISSING ON = IF '&WFFMT' EQ 'EXL2K'
THEN '<img src=&ImageFile border=0>' ELSE MISSING;
END
TABLE FILE CAR
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SUM RCOST
AS 'Retail Cost'
-* Focexec: std_head.fex
DCOST
AS 'Dealer Cost'
-*
-* Author: Anthony Alsford - EDATA Limited
BY COUNTRY AS 'Country'
-*
SUM RCOST
AS 'Retail Cost'
-* Date:
29 August 2006
-*
DCOST
AS 'Dealer Cost'
-* Project: IBI User Conference 2007
BY COUNTRY
-*
WebFOCUS Reporting Standards
-*
BY CAR
AS 'Car'
-* Purpose: Provide standard heading using variable
SUM RCOST
AS 'Retail Cost'
-*
reporting within WebFOCUS.
-*
DCOST
AS 'Dealer Cost'
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BY COUNTRY
HEADING
" <+0 &Rep_Heading"
BY CAR
" <+0 &Rep_Heading1"
BY MODEL
AS 'Model'
" <+0 &Rep_Heading2"
" <+0 &Rep_Heading3"
-INCLUDE std_head
"&Rep_Dates <+0 "
-INCLUDE std_foot
-* Only show those parameter lines that contain data.
&Rep_Parms1.LENGTH LE 1 AND &Rep_Parms2.LENGTH LE 1 THEN
ON TABLE PCHOLD FORMAT &WFFMT -IF"&Rep_Parms1
<+0>&Rep_Parms2"
ON TABLE SET HTMLCSS ON
-:SkipPrm1;
-IF &Rep_Parms3.LENGTH LE 1 AND &Rep_Parms4.LENGTH LE 1 THEN
ON TABLE SET STYLE *
"&Rep_Parms3 <+0>&Rep_Parms4"
-INCLUDE std_style
-:SkipPrm2;
-IF &Rep_Parms5.LENGTH LE 1 AND &Rep_Parms6.LENGTH LE 1 THEN
ENDSTYLE
"&Rep_Parms5 <+0>&Rep_Parms6"
END
-:SkipPrm3;
-IF &Rep_Parms7.LENGTH LE 1 AND &Rep_Parms8.LENGTH LE 1 THEN
-RUN
"&Rep_Parms7 <+0>&Rep_Parms8"
:SkipPrm1;
:SkipPrm2;
:SkipPrm3;
:SkipPrm4;
-:SkipPrm4;
57
Reducing code development and maintenance timings
-INCLUDE std_init
DEFINE FILE CAR
IMG/A36 WITH COUNTRY MISSING ON = IF '&WFFMT' EQ 'EXL2K'
THEN '<img src=&ImageFile border=0>' ELSE MISSING;
END
TABLE FILE CAR
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SUM RCOST
AS 'Retail Cost'
-* Focexec: std_foot.fex
DCOST
AS 'Dealer Cost'
-*
-* Author: Anthony Alsford - EDATA Limited
BY COUNTRY AS 'Country'
-*
SUM RCOST
AS 'Retail Cost'
-* Date:
29 August 2006
-*
DCOST
AS 'Dealer Cost'
-* Project: IBI User Conference 2007
BY COUNTRY
-*
WebFOCUS Reporting Standards
-*
BY CAR
AS 'Car'
-* Purpose: Provide standard footing using variable
SUM RCOST
AS 'Retail Cost'
-*
reporting within WebFOCUS.
-*
DCOST
AS 'Dealer Cost'
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BY COUNTRY
FOOTING BOTTOM
"Produced by: &Userid <+0>Page:<TABPAGENO of <TABLASTPAGE<+0>Created
BY CAR
BY MODEL
AS 'Model'
-INCLUDE std_head
-INCLUDE std_foot
ON TABLE PCHOLD FORMAT &WFFMT
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
-INCLUDE std_style
ENDSTYLE
END
-RUN
on: &RepDate at &RepTime"
58
Reducing code development and maintenance timings
-INCLUDE std_init
DEFINE FILE CAR
IMG/A36 WITH COUNTRY MISSING ON = IF '&WFFMT' EQ 'EXL2K'
THEN '<img src=&ImageFile border=0>' ELSE MISSING;
END
TABLE FILE CAR
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SUM RCOST
AS 'Retail Cost'
-* Focexec: std_style.fex
DCOST
AS 'Dealer Cost'
-*
-* Author: Anthony Alsford - EDATA Limited
BY COUNTRY AS 'Country'
-*
SUM RCOST
AS 'Retail Cost'
-* Date:
29 August 2006
-*
DCOST
AS 'Dealer Cost'
-* Project: IBI User Conference 2007
BY COUNTRY
-*
WebFOCUS Reporting Standards
-*
BY CAR
AS 'Car'
-* Purpose: Provide standard styling using variable
SUM RCOST
AS 'Retail Cost'
-*
reporting within WebFOCUS.
-*
DCOST
AS 'Dealer Cost'
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BY COUNTRY
UNITS=IN, PAGESIZE='A4', LEFTMARGIN=0.20, RIGHTMARGIN=0.20, TOPMARGIN=0.20,
BOTTOMMARGIN=0.20, SQUEEZE=ON, ORIENTATION=PORTRAIT, BACKCOLOR=RGB(240 245 255),$
BY CAR
TYPE=HEADING, IMAGE=&ImageFile, CLASS=HeadImg, SIZE=(2.25 0.45), &ImagePos$
BY MODEL
AS 'Model'
TYPE=HEADING, BORDER=LIGHT, BORDER-STYLE=SOLID, SIZE=8, BACKCOLOR='WHITE', STYLE=BOLD,$
TYPE=HEADING, LINE=1, ITEM=1, CLASS=Headline1a, WIDTH=1.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=14,$
-INCLUDE std_head
TYPE=HEADING, LINE=1, ITEM=2, CLASS=Headline1b, WIDTH=5.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=14,$
-INCLUDE std_foot
TYPE=HEADING, LINE=2, ITEM=1, CLASS=HeadLine2a, WIDTH=1.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=12,$
LINE=2, ITEM=2, CLASS=HeadLine2b, WIDTH=5.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=12,$
ON TABLE PCHOLD FORMAT &WFFMT TYPE=HEADING,
TYPE=HEADING, LINE=3, ITEM=1, CLASS=HeadLine3a, WIDTH=1.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$
ON TABLE SET HTMLCSS ON
TYPE=HEADING, LINE=3, ITEM=2, CLASS=HeadLine3b, WIDTH=5.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$
TYPE=HEADING, LINE=4, ITEM=1, CLASS=HeadLine4, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$
ON TABLE SET STYLE *
TYPE=HEADING, LINE=4, ITEM=2, CLASS=HeadLine4, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=10,$
-INCLUDE std_style
TYPE=HEADING, LINE=5, ITEM=1, CLASS=HeadLine5, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
TYPE=HEADING, LINE=5, ITEM=2, CLASS=HeadLine5, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
ENDSTYLE
TYPE=HEADING, LINE=6, ITEM=1, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
END
TYPE=HEADING, LINE=6, ITEM=2, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
TYPE=HEADING, LINE=7, ITEM=1, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
-RUN
TYPE=HEADING, LINE=7, ITEM=2, CLASS=HeadLine6, WIDTH=3.75, JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=HEADING,
TYPE=FOOTING,
TYPE=FOOTING,
LINE=8,
LINE=8,
LINE=9,
LINE=9,
LINE=1,
LINE=1,
ITEM=1,
ITEM=2,
ITEM=1,
ITEM=2,
ITEM=1,
ITEM=2,
CLASS=HeadLine6,
CLASS=HeadLine6,
CLASS=HeadLine6,
CLASS=HeadLine6,
CLASS=FootPart1,
CLASS=FootPart2,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=3.75,
WIDTH=2.62,
WIDTH=1.05,
JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
JUSTIFY=LEFT, STYLE=BOLD, SIZE=8,$
JUSTIFY=CENTER, STYLE=BOLD, SIZE=8,$
59
Resulting in consistent look and feel and highly maintainable code
60
1. SO
THAT YOU CAN READ YOUR OWN CODE!
@@@@@@@@@@@@@@@@@@@@@@@
2. Big emergency?
Flip a switch, avoid a meltdown
3. Quick fix?
Might actually work
4. Major overhaul?
Instantly envision the whole thing
5. User confidence soars when your site is consistent.
TOP 10 REASONS FOR STANDARDS IN CODING
61
Report Caster good idea
killcast.fex
-SET &&KILLRPC = ‘N’ ;
62
Report Caster good idea
Make a backup copy of your
empty Caster log file,
on the day you first install
To purge your caster log,
stop caster, and overwrite
your botlog files from your
backup; Faster than ‘Purge’
63
Report Caster good idea
Get the .gifs out of the .war file
Faster loading,
if you have to get in on a dial- up line
64
MRE good idea - names
Don’t do this!
Don’t name your domain, your report
group, your folder, or your fex with its
long, display name
65
MRE good idea - names
Do name your domain with a nice directory name,
...
66
MRE good idea - names
… then give the nice long display name in the Properties Box
67
MRE good idea - names
Display name sorts in alpha order,
True domain directory name is unchanged.
68
MRE good idea - names
Number your fexes in run order
Mre’s random fex names are for temp work, only
69
“Things should be made as simple as possible, but no simpler”
— Albert Einstein 1933
71
Download