Download presentation
Presentation is loading. Please wait.
1
In the World of WebFocus Reporting
Hidden Gems 6 In the World of WebFocus Reporting Walter F. Blood Director of Product Management and Support Information Builders
2
Hidden Gems 6 Where We Will Look-- In synonyms… In connections…
Master File Profile – a new application control point Internal synonyms – working with WebFOCUS internals your way In connections… MATCH to achieve the difficult In requests… New prefixes ROLL. MDN. MDE. Summary prefixes – functionality on the summary line WHERE TOTAL and WHERE_GROUPED – surrounding COMPUTE In expressions… Simplified functions – optimized for SQL VALIDATE with REGEX – putting regular expressions to work In output… FOCUS and XFOCUS files – the ultimate hold file format
3
Hidden Gems 6 In synonyms…
Master File Profile – a new application control point Internal synonyms – working with WebFOCUS internals your way
4
FX Hidden Gems 6 In synonyms – Master File Profile
Profiles – all functionality of focexec Supports all of the language – no limitations Typical tasks include- Path modification based on user File allocation based on criteria Environment settings adjustment Database attachment and settings Last profile run takes precedence – overwrite existing settings TABLE SET Dialogue Manager MATCH Dialogue Manager LET DEFINE TABLEF MODIFY MODIFY JOIN FX
5
Hidden Gems 6 In synonyms – Master File Profile
Profiles – run automatically at critical control points Edasprof – when agent starts up Group/user profile –when user is identified Master file profile – when synonym is parsed
6
Hidden Gems 6 In synonyms – Master File Profile
Master File Profiles run with each invocation of TABLE TABLEF GRAPH MATCH FILE CHECK, ?f, ?ff MODIFY Multiple MFD_PROFILES may be executed JOIN or Cross-References MORE
7
Using Global Variables
Hidden Gems 6 In synonyms – MFD Profile Using Global Variables VARIABLE NAME=[&&]var, USAGE=An, [DEFAULT=defvalue,][QUOTED={OFF|ON},] $ Master Attributes which may be parameterized include: POSITION OCCURS REMARKS DESCRIPTION TITLE HELPMESSAGE DBA USERID and VALUE Access Attributes which may be parameterized include: CONNECTION TABLENAME DIRECTORY EXTENSION
8
Hidden Gems 6 In synonyms – MFD Profile : Global Variables MASTER FILE
FILE=GRPPOL ,SUFFIX=SQLORA ,MFD_PROFILE=GRPPOL VARIABLE NAME=LTD, USAGE=A30, DEFAULT=‘ LTD or ETD‘ ,$ SEGNAME=GRPPOL,SEGTYPE=S0 FIELD=GROUP_CODE,GCODE,A8,TITLE=‘ Group Code‘ ,$ FIELD=GROUP_NAME,,A30,TITLE=‘ Group Policy Holder‘ ,$ FIELD=CONTRACT_NO,CONTRACT,A8,TITLE=‘ Contract Number‘ ,$ FIELD=LONG_TERM,LTD,A1,TITLE=&<D , $ FIELD=EFFECT_DATE,,YYMD,TITLE=‘ Effective,Date‘ ,$ MASTER FILE -IF &1 NE ‘ GRPPOL‘ GOTO NOVAR1; -SET &<D = IF &&TEAM_NAME EQ ‘ GM‘ THEN ‘ Extended Term‘ ELSE ‘ Long Term‘ ; - NOVAR1 MASTER FILE PROFILE 8
9
Hidden Gems 6 In synonyms – MFD Profile : Creating or Pointing to Files FILE=GRPPOL ,SUFFIX=SQLORA ,MFD_PROFILE=GRPPOL VARIABLE NAME=LTD, USAGE=A30, DEFAULT=‘ LTD or ETD‘ ,$ SEGNAME=GRPPOL,SEGTYPE=S0 FIELD=GROUP_CODE,GCODE,A8,TITLE=‘ Group Code‘ ,$ FIELD=GROUP_NAME,,A30,TITLE=‘ Group Policy Holder‘ ,$ FIELD=CONTRACT_NO,CONTRACT,A8,TITLE=‘ Contract Number‘ ,$ FIELD=LONG_TERM,LTD,A1,TITLE=&<D , $ FIELD=EFFECT_DATE,,YYMD,TITLE=‘ Effective,Date‘ ,$ FILTER SELECTGRPS = IF DECODE GROUP_CODE(TEAMRESP ELSE 2) EQ 0 THEN 1 ELSE 0 ; MASTER FILE -IF &1 NE ‘ GRPPOL‘ GOTO NOVAR1; -SET &<D = IF &&TEAM_NAME EQ ‘ GM‘ THEN ‘ Extended Term‘ ELSE ‘ Long Term‘ ; NOVAR1 FILEDEF TEAMRESP DISK c:\userapp\teamresp.dat MASTER FILE PROFILE 9
10
Hidden Gems 6 In synonyms – Master File Profile : Security MASTER FILE
FILE=GRPPOL ,SUFFIX=SQLORA ,MFD_PROFILE=GRPPOL SEGNAME=GRPPOL,SEGTYPE=S0 VARIABLE NAME=&<D, USAGE=A30, DEFAULT=‘ LTD or ETD‘ ,$ VARIABLE NAME=&&UID, USAGE=A8, DEFAULT=‘ ‘ ,$ VARIABLE NAME=&&DBAVAL,USAGE=A50, DEFAULT=GROUP_CODE EQ ‘ X‘ AND GROUP_CODE EQ ‘ Y‘ ;,$ FIELD=GROUP_CODE,GCODE,A8,TITLE=‘ Group Code‘ ,$ FIELD=GROUP_NAME,,A30,TITLE=‘ Group Policy Holder‘ ,$ FIELD=CONTRACT_NO,CONTRACT,A8,TITLE=‘ Contract Number‘ ,$ FIELD=LONG_TERM,LTD,A1,TITLE=&<D , $ FIELD=EFFECT_DATE,,YYMD,TITLE=‘ Effective,Date‘ ,$ FILTER SELECTGRPS = IF DECODE GROUP_CODE(TEAMRESP ELSE 2) EQ 0 THEN 1 ELSE 0 ; END DBA=DBA,$ USER=&&UID,ACCESS=R,RESTRICT=VALUE_WHERE, NAME=GRPPOL,VALUE=&&DBAVAL,$ MASTER FILE 10
11
Hidden Gems 6 In synonyms – Master File Profile : Security
-IF &1 NE ‘ GRPPOL‘ GOTO NOVAR1; -SET &<D = IF &&TEAM_NAME EQ ‘ GM‘ THEN ‘ Extended Term‘ ELSE ‘ Long Term‘ ; NOVAR1 TABLE FILE TEAMS PRINT GRP_RESP WHERE TEAM EQ ‘&&TEAM_NAME‘ ON TABLE SAVE AS TEAMRESP END -ALL -SET &&DBAVAL= SELECTGRPS; MASTER FILE PROFILE 11
12
Hidden Gems 6 In synonyms – Master File Profile : Security MASTER FILE
FILE=GRPPOL ,SUFFIX=SQLORA ,MFD_PROFILE=GRPPOL VARIABLE NAME=&<D, USAGE=A30, DEFAULT=‘ LTD or ETD‘ ,$ SEGNAME=GRPPOL,SEGTYPE=S0 FIELD=GROUP_CODE,GCODE,A8,TITLE=‘ Group Code‘ ,$ FIELD=GROUP_NAME,,A30,TITLE=‘ Group Policy Holder‘ ,$ FIELD=CONTRACT_NO,CONTRACT,A8,TITLE=‘ Contract Number‘ ,$ FIELD=LONG_TERM,LTD,A1,TITLE=&<D , $ FIELD=EFFECT_DATE,,YYMD,TITLE=‘ Effective,Date‘ ,$ FILTER SELECTGRPS = IF DECODE GROUP_CODE(TEAMRESP ELSE 2) EQ 0 THEN 1 ELSE 0 ; END DBA=DBA,DBAFILE=MYFILE,$ MASTER FILE 12
13
Hidden Gems 6 In synonyms – Master File Profile : Security
DEFINE FILE SYSCOLUM LINENO WITH TBNAME = LINENO + 1; LINED/A80 = IF LINENO EQ 1 THEN ‘ FILE=MYFILE,SUFFIX=FIX‘ ELSE IF LINENO EQ 2 THEN ‘ SEGNAME=ONE,SEGTYPE=S0‘ ELSE IF LINENO EQ 3 THEN ‘ FIELDNAME=ONE,,A1,A1,$‘ ELSE IF LINENO EQ 4 THEN ‘ END‘ ELSE IF LINENO EQ 5 THEN ‘ DBA=DBA,$‘ ELSE IF LINENO EQ 6 THEN ‘ USER=‘ ‘ ‘ ‘ ,ACCESS=R, RESTRICT=VALUE,NAME=SYSTEM, ‘ | ‘ VALUE= RECORDLIMIT EQ 5,$‘ ELSE IF LINENO EQ 7 THEN ‘ RESTRICT=VALUE,VALUE=‘ | ‘ SELECTGRPS,$‘ ELSE IF LINENO EQ 8 THEN ‘ USER=NORM,ACCESS=R,‘ | ‘ RESTRICT=VALUE,NAME=SYSTEM,‘ | ‘ VALUE=SELECTGRPS,$‘ ELSE ‘ ‘ ; END TABLE FILE SYSCOLUM PRINT LINED ON TABLE SAVE AS MYFILE WHERE LINENO LE 8 MASTER FILE PROFILE 13
14
Hidden Gems 6 In synonyms – Master File Profile : Avoiding Loops!!!
-TYPE STARTING MFD3 (MFD_PROFILE) -DEFAULT &&MFD3_REP = 0; -SET &&MFD3_REP = &&MFD3_REP + 1; -IF &&MFD3_REP GT 1 GOTO NOMORE; CHECK FILE MYFILE HOLD TABLE FILE HOLD PRINT FIELDNAME END … -NORMAL -SET &&MFD3_REP = 0; -NOMORE -EXIT MASTER FILE PROFILE Not 1st Time – Skip to end 14 14
15
Hidden Gems 6 Catalog Master Files Application Metadata Tables
New /catalog master files to access system and app data using TABLE FILE Based on SUFFIX=FMI Located in srv/home/catalog – always available sysfiles - list of accessible app name objects on path for a given type (default MASTER). sysdirs - recursive list of physical files under a physical directory. sysapps - metadata for applications and files systables - app name of tables (and related metadata) on path. syscolum – column info for master files – like CHECK FILE HOLD syscube (hierarchical) and syscube2 (parent/child) – information about cube structures sysdeffn – information on functions created with DEFINE FUNCTION sysfkeys – foreign and primary key information sysimp – impact analysis sysindex – index information syskeys – information on synonym described keys syssets – information on the current SETs in place sysusers – user information Applications can access this data using TABLE, TABLE/HOLD, READFILE Catalog/? Example? – I will add examples of these – new query mechanisms to get info from system My problem with any of these is that the world in one directory all 6200 masters (focus.prod.master) – did someone mention application independence?
16
Hidden Gems 6 Catalog Master Files …
$ FILE=SYSTABLE, SUFFIX=FMI, REMARKS='Metadata: Table Information', $ SEGNAME=SYSTABLE,SEGTYPE=S2 $ FIELD=NAME ,,A18,A64,INDEX=I,DESC='NAME OF THE MASTER FILE',$Comment f FIELD=NAME ,,A64,A64,INDEX=I,DESC='NAME OF THE MASTER FILE',$Uncomment $Indexed for join in TABLIST FIELD=CREATOR ,,A512,A512,DESC='EDADBA OR APPNAME IF 2PARTNAME IS ON',$ $AFD TABLENAME qualifer if AFD exists, else constant EDADBA FIELD=TYPE ,,A1,A1,DESC='CONSTANT - T',$ FIELD=DBNAME ,,A8,A8,DESC='CONSTANT - EDADB',$ FIELD=TSNAME ,,A8,A8,DESC='NOT INITIALIZED - DEFAULT '' ''',$ FIELD=DBID ,,I4,I4,DESC='CONSTANT - ''1''',$ FIELD=OBID ,,I4,I4,DESC='SYSTEM GENERATED LAST ASSIGNED',$ FIELD=COLCOUNT ,,I4,I4,DESC='MFD - CNT.FLDNO',$ FIELD=EDPROC ,,A8,A8,DESC='NOT INITIALIZED - DEFAULT '' ''',$ FIELD=VALPROC ,,A8,A8,DESC='NOT INITIALIZED - DEFAULT '' ''',$ FIELD=CLUSTERTYPE,,A1,A1,DESC='CONSTANT - ''N''',$ … ????
17
Hidden Gems 6 Catalog Master Files
TABLE FILE SYSTABLE PRINT COLCOUNT REMARKS KEYCOLUMNS RECLENGTH TBTYPE BY NAME END ????
18
Hidden Gems 6 In connections -- MATCH to achieve the difficult
19
Sort Merge Hidden Gems 6 MATCH Basics
BYs and Verb control structure of output record WHEREs control selection OLD NEW AFTER MATCH HOLD selection of matched data being placed in the output record HOLD
20
Hidden Gems 6 MATCH Sorts - BYs Using BY fields
Control both column order in record as well as connection To “MATCH” - must have same name in request – use AS MATCH up to 16 levels in a single MATCH request MATCH keys do not have to be the same! Matching keys - output in 1 column Non-matching keys – distinct columns Output record created based upon common keys Keys plus associated verb objects OLD to NEW for non-MATCHING key objects SET MATCHCOLUMNORDER=GROUPED/UNGROUPED – fields promoted to common keys
21
Hidden Gems 6 MATCH Verbs Using PRINT or SUM SUM: PRINT:
Aggregates verb objects included in level Aggregation level based upon BYs at that level Output sequence controlled by order of request and BYs, and MATCH levels PRINT: Includes detail records for verb objects selected in level Grouped and sorted based upon BY fields Output sequence controlled by order of request and BYs , and MATCH levels
22
Hidden Gems 6 CONTROL THE MISSING! Holding Patterns MATCH
OLD-OR-NEW – All RECORDS, both files (DEFAULT) OLD-AND-NEW—Common RECORDS only OLD-NOT-NEW – RECORDS in OLD missing in NEW NEW-NOT-OLD - RECORDS in NEW missing in OLD OLD-NOR-NEW - Combo of OLD-NOT-NEW NEW-NOT-OLD OLD – RECORDS in OLD with RECORDS in NEW NEW – RECORDS in NEW with RECORDS in OLD OLD NEW OLD OLD NEW NEW OLD NEW NEW OLD NEW OLD OLD NEW NEW OLD NEW NEW OLD OLD NEW OLD OLD OLD OLD NEW NEW NEW NEW OLD NEW OLD NEW
23
Hidden Gems 6 MATCH Advanced
MATCH varying sortfields to place different aggregation levels in the same record
24
Hidden Gems 6 MATCH Advanced
MATCH varying sortfields to place different aggregation levels in the same record
25
Hidden Gems 6 MATCH Advanced TABLE FILE HOLDOUT PRINT
HOLDOUT.HOLDOUT.PRODUCT AS 'Product' HOLDOUT.HOLDOUT.UNITS AS 'Total,Product,Units' HOLDOUT.HOLDOUT.BUDUNITS AS 'Total,Product,Budget,Units' HOLDOUT.HOLDOUT.REGION AS 'Region' HOLDOUT.HOLDOUT.DOLLARS AS 'Total,Region,Dollars' HOLDOUT.HOLDOUT.BUDDOLLARS AS 'Total,Region,Budget,Dollars' HOLDOUT.HOLDOUT.CATEGORY AS 'Category' E08 AS 'Total,Category,Units' E09 AS 'Total,Category,Budget,Units' HOLDOUT.HOLDOUT.DATE AS 'Date' E11 AS 'Total,Date,Dollars' E12 AS 'Total,Date,Budget,Dollars' ON TABLE SET PAGE-NUM NOLEAD ON TABLE SET ASNAMES ON
26
Hidden Gems 6 MATCH Advanced
27
Hidden Gems 6 MATCH Advanced MATCH output variations
Use Sort Groups – multiple verbs – within each match section SET MATCHCOLUMNORDER GROUPED – new behavior fields with common sorts are grouped UNGROUPED – old behavior fields displayed in match specified order New behavior allows HOLD FORMAT FOCUS/XFOCUS
28
Hidden Gems 6 In requests… New prefixes – ROLL., MDN. , MDE.
Prefixes on the summary line WHERE TOTAL and WHERE_GROUPED and COMPUTE
29
Hidden Gems 6 Rolling up calculations on summary rows – ROLL.
ROLL. Prefix Operator Rolling up calculations on summary rows – ROLL. BY/ON field {SUMMARIZE|SUBTOTAL|SUB-TOTAL|RECOMPUTE} [ROLL.][prefix1.] [field1 field2 ...|*] [ROLL.][prefix2.] [fieldn ...] SUMMARIZE and RECOMPUTE normally use detail record data ROLL.prefix uses lower level summary data rather than detail data Supported prefixes include SUM., AVE., MIN., MAX., FST., LST., CNT., and ASQ. ROLL. without prefix – implied SUM.
30
Average of Detail Lines
Hidden Gems 6 Prefix Operator ROLL. Rolling up calculations on summary rows – ROLL. TABLE FILE GGSALES SUM UNITS AS 'Inventory ' BY REGION BY ST ON REGION SUBTOTAL AVE. AS 'Average' WHERE DATE GE WHERE REGION EQ 'West' OR 'Northeast' ON TABLE SET PAGE NOPAGE END Region State Inventory Northeast CT MA NY Average Northeast 36400 West CA WA Average West 58261 TOTAL Average of Detail Lines
31
FOCUS 7706 New Features - Expressions
Prefix Operator ROLL. Rolling up calculations on summary rows – ROLL. TABLE FILE GGSALES SUM UNITS AS 'Inventory ' BY REGION BY ST ON REGION SUBTOTAL AVE. AS 'Average' WHERE DATE GE WHERE REGION EQ 'West' OR 'Northeast' ON TABLE SET PAGE NOPAGE ON TABLE SUBTOTAL ROLL.AVE. END Region State Inventory Northeast CT MA NY Average Northeast 36400 West CA WA Average West 58261 TOTAL Average of Summary Lines
32
Hidden Gems 6 Rolling up calculations on summary rows – ROLL.
Prefix Operator ROLL. Rolling up calculations on summary rows – ROLL. TABLE FILE GGSALES SUM UNITS BY REGION BY PRODUCT BY HIGHEST DATE WHERE DATE GE WHERE REGION EQ 'Midwest' OR 'Northeast' WHERE PRODUCT LIKE 'C%' ON PRODUCT SUBTOTAL AVE. ON REGION SUMMARIZE ROLL.AVE. ON TABLE SET PAGE NOPAGE END Aggregation at 3 levels plus total Average of date detail Average of product average
33
Hidden Gems 6 Rolling up calculations on summary rows – ROLL.
Prefix Operator ROLL. Rolling up calculations on summary rows – ROLL. Region Product Date Unit Sales Midwest Coffee Grinder /12/ 1997/11/ 1997/10/ *TOTAL PRODUCT Coffee Grinder Coffee Pot /12/ 1997/11/ 1997/10/ *TOTAL PRODUCT Coffee Pot Croissant /12/ 1997/11/ 1997/10/ *TOTAL PRODUCT Croissant *TOTAL REGION Midwest Aggregation at 3 levels plus total Average of date detail Average of product average
34
Hidden Gems 6 Rolling up calculations on summary rows – ROLL.
Prefix Operator ROLL. Rolling up calculations on summary rows – ROLL. Region Product Date Unit Sales Northeast Capuccino /12/ 1997/11/ 1997/10/ *TOTAL PRODUCT Capuccino Coffee Grinder /12/ 1997/11/ 1997/10/ *TOTAL PRODUCT Coffee Grinder Coffee Pot /12/ 1997/11/ 1997/10/ *TOTAL PRODUCT Coffee Pot Croissant /12/ 1997/11/ 1997/10/ *TOTAL PRODUCT Croissant *TOTAL REGION Northeast TOTAL Average of date detail Average of product average Aggregation at 3 levels plus total
35
Hidden Gems 6 Rolling up calculations on summary rows – ROLL.
Prefix Operator ROLL. Rolling up calculations on summary rows – ROLL. ROLL.prefix prefix operation will be performed using next lower level summary data No prefix operator at the level below ? With SUM/COUNT/WRITE SUM. will be used. With PRINT/LIST the prefix operator will be used. MULTILINES makes a difference with ROLL. because it suppresses the summary line that would be used. Average of date detail Average of product average Aggregation at 3 levels plus total
36
Hidden Gems 6 Using the Median and Mode prefix operators – MDN. / MDE.
Prefix Operators MDE and MDN Using the Median and Mode prefix operators – MDN. / MDE. Median - value at the 50th percentile of the data – MDN. Mode – value that appears the most often in the data – MDE. Must be used at lowest aggregation level on a numeric field or smartdate. In case of tie with MDE – Mode – lowest values is displayed. Not available in DEFINE, WHERE or on summary line. Average of date detail Average of product average Aggregation at 3 levels plus total
37
Hidden Gems 6 Using the Median and Mode prefix operators – MDN. / MDE.
Prefix Operators MDN. and MDE. Using the Median and Mode prefix operators – MDN. / MDE.
38
Hidden Gems 6 Using the Median and Mode prefix operators – MDN. / MDE.
Prefix Operators MDN. And MDE. Using the Median and Mode prefix operators – MDN. / MDE.
39
Hidden Gems 6 Using prefix operators on the summary line
On summary line with RECOMPUTE or SUMMARIZE – recalculate Prefix operator followed by space - MAX. Fieldname Reference fieldnames with Prefix operator to use the correct field Prefix operator NOT followed by space - MAX.Fieldname Multiple different prefix operators can be used on same summary line Average of date detail Average of product average Aggregation at 3 levels plus total
40
Hidden Gems 6 Prefix Operators on the Summary Line Using the prefix operators on the summary line - incorrect TABLE FILE EMPLOYEE SUM EMPLOYEE.EMPINFO.CURR_SAL AS 'Total,Salary' AVE.EMPLOYEE.EMPINFO.CURR_SAL WITHIN EMPLOYEE.EMPINFO.DEPARTMENT AS 'Average,Salary' BY LOWEST EMPLOYEE.EMPINFO.DEPARTMENT BY LOWEST EMPLOYEE.EMPINFO.LAST_NAME ON EMPLOYEE.EMPINFO.DEPARTMENT RECOMPUTE SUM. EMPLOYEE.EMPINFO.CURR_SAL AVE.EMPLOYEE.EMPINFO.CURR_SAL AS '*TOTAL' Average of date detail Average of product average Aggregation at 3 levels plus total
41
Hidden Gems 6 Using the prefix operators on the summary line - correct
TABLE FILE EMPLOYEE SUM EMPLOYEE.EMPINFO.CURR_SAL AS 'Total,Salary' AVE.EMPLOYEE.EMPINFO.CURR_SAL WITHIN EMPLOYEE.EMPINFO.DEPARTMENT AS 'Average,Salary' BY LOWEST EMPLOYEE.EMPINFO.DEPARTMENT BY LOWEST EMPLOYEE.EMPINFO.LAST_NAME ON EMPLOYEE.EMPINFO.DEPARTMENT RECOMPUTE SUM. EMPLOYEE.EMPINFO.CURR_SAL AVE. AVE.EMPLOYEE.EMPINFO.CURR_SAL AS '*TOTAL' Average of date detail Average of product average Aggregation at 3 levels plus total
42
Hidden Gems 6 Prefix Operators on the Summary Line Using the prefix operators on the summary line - multiple TABLE FILE EMPLOYEE SUM EMPLOYEE.EMPINFO.CURR_SAL AS 'Total,Salary' AVE.EMPLOYEE.EMPINFO.CURR_SAL WITHIN EMPLOYEE.EMPINFO.DEPARTMENT AS 'Average,Salary' BY LOWEST EMPLOYEE.EMPINFO.DEPARTMENT BY LOWEST EMPLOYEE.EMPINFO.LAST_NAME ON EMPLOYEE.EMPINFO.DEPARTMENT RECOMPUTE MAX. EMPLOYEE.EMPINFO.CURR_SAL AVE. AVE.EMPLOYEE.EMPINFO.CURR_SAL AS '*TOTAL' Average of date detail Average of product average Aggregation at 3 levels plus total
43
COMING in 82 MATRIX Hidden Gems 6
WHERE TOTAL, WHERE_GROUPED and COMPUTE Selecting the Totals to use in a COMPUTE– WHERE_GROUPED DETAILS IN MATRIX WHERE_GROUPED TOTALS OUT COMPUTE COMING in 82 WHERE TOTAL TOTALS SORT
44
Hidden Gems 6 In expressions… Simplified functions – optimized for SQL
VALIDATE with REGEX – putting regular expressions to work
45
Hidden Gems 6 What Is A Simplified Function? Simplified Functions
Simpler to use -fewer parameters Parameter lengths are mostly gone Output parameter is gone Naming and syntax similar to other languages Designed to be optimizable to SQL
46
Hidden Gems 6 Better, right? Simplified Functions LOCASE vs LOWER
LOCASE could be replaced by LOWER which will lower case all characters in a string. LCWORD keeps the first character of each word uppercase. LCWORD2 keeps the first character of each word uppercase plus uppercases characters after apostrophes. LCWORD3 similar to LCWORD2 but keeps also uppercases characters after apostrophes that are not followed by spaces.
47
Hidden Gems 6 Character Functions: Simplified Functions
CHAR_LENGTH: Returning the Length in Characters of a String DIGITS: Converting a Number to a Character String LOWER: Returning a String With All Letters Lowercase LPAD: Left-Padding a Character String LTRIM: Removing Blanks From the Left End of a String POSITION: Returning the First Position of a Substring in a Source String RPAD: Right-Padding a Character String RTRIM: Removing Blanks From the Right End of a String SUBSTRING: Extracting a Substring From a Source String TOKEN: Extracting a Token From a String TRIM_: Removing Leading Characters, Trailing Characters, or Both From a String UPPER: Returning a String With All Letters Uppercase
48
Hidden Gems 6 DateTime Functions: Simplified Functions
DTADD: Incrementing a Date or Date-Time Component DTDIFF: Returning the Number of Component Boundaries Between Date or Date-Time Values DTPART: Returning a Date or Date-Time Component in Integer Format DTRUNC: Returning the Start of a Date Period for a Given Date
49
Hidden Gems 6 Simplified functions - CHAR_LENGTH
The CHAR_LENGTH function returns the length, in characters, of a string. CHAR_LENGTH(source_string) TABLE FILE CAR PRINT COUNTRY COMPUTE COUNTRYV/A10V = TRIMV('B',COUNTRY,10,' ',1,'A10V'); COMPUTE COUNTRYLEN/I3 = CHAR_LENGTH(COUNTRY); COMPUTE COUNTRYARGLEN/I3 = ARGLEN(10,COUNTRY,'I3'); COMPUTE COUNTRYLENV/I3 = CHAR_LENGTH(COUNTRYV); COMPUTE COUNTRYARGLENV/I3 = ARGLEN(10,COUNTRYV,'I3'); END COUNTRY COUNTRYV COUNTRYLEN COUNTRYARGLEN COUNTRYLENV COUNTRYARGLENV ENGLAND ENGLAND JAPAN JAPAN ITALY ITALY W GERMANY W GERMANY FRANCE FRANCE
50
Hidden Gems 6 Simplified functions - DIGITS
The DIGITS function converts an Integer value to Alpha. DIGITS(number,length) TABLE FILE CAR PRINT COUNTRY COMPUTE VALUE1/I10 = ; COMPUTE ALPHAVAL1/A10 = DIGITS(VALUE1,10); COMPUTE ALPHAVAL2/A4 = DIGITS(VALUE1,4); COMPUTE EDITVAL2/A15 = EDIT(VALUE1); END COUNTRY VALUE1 ALPHAVAL1 ALPHAVAL2 EDITVAL2 ENGLAND JAPAN ITALY W GERMANY FRANCE
51
Hidden Gems 6 Simplified functions - DTADD
The DTADD function increments a DATE or DATETIME component. DTADD(date, component, increment) TABLE FILE CAR PRINT COUNTRY COMPUTE TDAY/YYMD = '&DATEYYMD'; COMPUTE TDATETIME/HYYMDS = DT('&DATEYYMD'); COMPUTE TDAYP2M/YYMD = DTADD(TDAY, MONTH, 2); COMPUTE TDAYP5D/YYMD = DTADD(TDAY,DAY,5); COMPUTE TDAYP2MDATEADD/YYMD = DATEADD(TDAY,'M',2); COMPUTE TDAYP5DHADD/HYYMDS = HADD(TDATETIME, 'DAY', 5, 8, 'HYYMDS'); END COUNTRY TDAY TDATETIME TDAYP2M TDAYP5D TDAYP2MDATEADD TDAYP5DHADD ENGLAND /04/ /04/27 00:00: /06/ /05/ /06/ /05/02 00:00:00 JAPAN /04/ /04/27 00:00: /06/ /05/ /06/ /05/02 00:00:00 ITALY /04/ /04/27 00:00: /06/ /05/ /06/ /05/02 00:00:00 W GERMANY /04/ /04/27 00:00: /06/ /05/ /06/ /05/02 00:00:00 FRANCE /04/ /04/27 00:00: /06/ /05/ /06/ /05/02 00:00:00
52
Hidden Gems 6 Simplified functions - DTPART
The DTPART function return a specific Integer component of a date or datetime field. DTPART(date, component) TABLE FILE CAR PRINT COUNTRY COMPUTE TDAY/YYMD = '&DATEYYMD'; COMPUTE TDATETIME/HYYMS =DT('&DATEYYMD'); COMPUTE TDTPARTM/I3 = DTPART(TDAY,MONTH); COMPUTE TDTPARTD/I3 = DTPART(TDATETIME,DAY); COMPUTE TDPARTM/I8 = DTPART(TDAY,'MM','I8'); COMPUTE THPARTD/I8 = HPART(TDATETIME,'DAY','I8'); COMPUTE THNAMEM/A3 = HNAME(TDATETIME,'MONTH','A3'); END COUNTRY TDAY TDATETIME TDTPARTM TDTPARTD TDPARTM THPARTD THNAMEM ENGLAND /04/ /04/27 00:00: APR JAPAN /04/ /04/27 00:00: APR ITALY /04/ /04/27 00:00: APR W GERMANY /04/ /04/27 00:00: APR FRANCE /04/ /04/27 00:00: APR
53
Hidden Gems 6 VALIDATE with Regular Expressions
VALIDATE command used with &variables – allows validation without requiring data access &variable.(|VALIDATE=REGEX,REGEX='regexpression'). -TYPE &YN.(|VALIDATE=REGEX,REGEX=‘^YN$’).ENTER Y/N. -TYPE &MODEL.(|VALIDATE=REGEX,REGEX=‘^[a-zA-Z0-9]+$’).Model?. (FOC2909) INVALID REGULAR EXPRESSION: (FOC2910) RESPONSE DOES NOT MATCH THE REGULAR EXPRESSION:
54
Hidden Gems 6 VALIDATE with Regular Expressions - Positive testing
-REPEAT NEXTFMT FOR &FMTCNT FROM 1 TO 2 -SET &EMPID1=DECODE &FMTCNT(1 ' ' 2 ' '); -SET &EMPID=IF &EMPID1.(|VALIDATE=REGEX,REGEX='^\d{3}\-?\d{2}\-?\d{4}$').Employee ID. CONTAINS '-' - THEN EDIT(&EMPID1,'999$99$9999') ELSE &EMPID1; TABLE FILE EMPLOYEE HEADING " “ "Testing EMPID = &EMPID1</1“ PRINT EID CSAL WHERE EID EQ '&EMPID.EVAL‘ ON TABLE SET PAGE NOPAGE ON TABLE SET STYLE * GRID=OFF,$ END -RUN -NEXTFMT Testing EMPID = EMP_ID CURR_SAL $11,000.00 Testing EMPID = $27,062.00
55
Hidden Gems 6 VALIDATE with Regular Expressions – Incorrect value
-REPEAT NEXTFMT FOR &FMTCNT FROM 1 TO 2 -SET &EMPID1=DECODE &FMTCNT(1 ' ' 2 ' '); -TYPE EMPID1 = &EMPID1 -SET &EMPID=&EMPID1.(|VALIDATE=REGEX,REGEX='^\d{3}\d{2}\d{4}$').Employee ID.; -TYPE EMPID = &EMPID -NEXTFMT EMPID1 = EMPID = EMPID1 = ERROR AT OR NEAR LINE 7 IN PROCEDURE __WCFEX FOCEXEC * (FOC2910) RESPONSE DOES NOT MATCH THE REGULAR EXPRESSION: (FOC295) A VALUE IS MISSING FOR: &EMPID1
56
Hidden Gems 6 In output … FOCUS and XFOCUS files – the ultimate hold file format
57
Hidden Gems 6 FOCUS/XFOCUS Hold Files Why FOCUS/XFOCUS hold files?
Size - hierarchical structure Max 32 GB in single partition Scalability Index capabilities Multiple types Expandability and Intelligence Partitioning offers growth to 32TB Security Dynamic and static possibilities
58
Hidden Gems 6 FOCUS DATABASE 4K page size 512K pages per partition
FOCUS/XFOCUS Hold Files - Size FOCUS DATABASE 4K page size 512K pages per partition Up to 2-GB per physical file Up to GB partitions Up to ½ terabyte total size Segment names up to 8 chars Index field names up to 12 chars Page 1 contains FDT and data XFOCUS DATABASE 16K page size 2048K pages per partition Up to 32-GB per physical file Up to GB partitions Up to 32 terabytes total size Segment names up to 64 chars Index field names up to 66 chars Page 1 dedicated to FDT
59
Hidden Gems 6 FOCUS XFOCUS
FOCUS/XFOCUS Hold Files – Index capabilities FOCUS XFOCUS Internal indices – In Master file Created on hold statement or in subsequent REBUILD FIELD=EMPID, ALIAS=EID, FORMAT=A10, INDEX=I,$ External index – In USE declaration Created in REBUILD – one field per INDEX USE indexname WITH mastername MDI – Multi-dimensional Index – In Access File Created in REBUILD – multiple fields MASTER=EMPLOYEE MDI = mdiname, TARGET_OF = segname ,$ DIM = field1 [MAXVALUES = n1] [WITHIN = dimname1],$ MDIDATA = mdifile1 ,$
60
Hidden Gems 6 FOCUS XFOCUS FOCUS/XFOCUS Hold Files – Expandability
Partitioned File – controlled in ACCESS file Create partition via HOLD and add to access file FILE=EMPLOYEE, SUFFIX=XFOC, ACCESS=EMPLOYEE Multiple partitions allowed in ACCESS file Searched in specified sequence Adjust sequence to reporting needs MASTER=EMPLOYEE,$ DATA = database_filename1 , . DATA= database_filenamen,$
61
Hidden Gems 6 FOCUS XFOCUS FOCUS/XFOCUS Hold Files – Intelligence
Intelligent Partitioned File – controlled in ACCESS file Create partition via HOLD based upon intelligence FILE=EMPLOYEE, SUFFIX=XFOC, ACCESS=EMPLOYEE Contents of each partition indicated in WHERE MASTER=EMPLOYEE,$ DATA = database_filename1 , [WHERE=expression1,]$ WHERE expressions limited to -- WHERE = field operator value1 [ OR value2...]; ,$ WHERE = field FROM value1 TO value2 [AND FROM value3 TO value4];,$
62
Hidden Gems 6 FOCUS XFOCUS FOCUS/XFOCUS Hold Files – Security
DBA security can be added to HOLD FORMAT FOCUS/XFOCUS using SET HOLDSTAT =OFF/ON/filename HOLDSTAT file is appended to HOLD file upon creation HOLDSTAT file can be static or created dynamically using MFD_PROFILE $ mystat.err $ Included comments $ Can be dynamically created in MFD Profile $BOTTOM DEFINE COUNTRY/A5=EDIT(COUNTRY,’9$9$9$9$9$’);,$ END DBAFILE = filename $ More comments
63
Hidden Gems 6 Master File Profile – a new application control point Internal synonyms MATCH to achieve the difficult New prefixes – ROLL., MDN. , MDE Prefixes on the summary line WHERE TOTAL, WHERE_GROUPED and COMPUTE New Simplified functions VALIDATE with REGEX FOCUS and XFOCUS files – the ultimate hold file format Questions?
64
Socialize to Win! Daily Prizes Awarded!
Tweet and tag #IBSummit during the event! in your #IBSummit pics! Check our Summit Facebook & LinkedIn pages for updates, photos, and announcements
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.