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
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
Hidden Gems 6 In synonyms… Master File Profile – a new application control point Internal synonyms – working with WebFOCUS internals your way
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
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
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
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
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
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
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
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
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
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
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
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?
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 - 1 + 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''',$ … ????
Hidden Gems 6 Catalog Master Files TABLE FILE SYSTABLE PRINT COLCOUNT REMARKS KEYCOLUMNS RECLENGTH TBTYPE BY NAME END ????
Hidden Gems 6 In connections -- MATCH to achieve the difficult
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
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
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
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
Hidden Gems 6 MATCH Advanced MATCH varying sortfields to place different aggregation levels in the same record
Hidden Gems 6 MATCH Advanced MATCH varying sortfields to place different aggregation levels in the same record
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
Hidden Gems 6 MATCH Advanced
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
Hidden Gems 6 In requests… New prefixes – ROLL., MDN. , MDE. Prefixes on the summary line WHERE TOTAL and WHERE_GROUPED and COMPUTE
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.
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 19971001 WHERE REGION EQ 'West' OR 'Northeast' ON TABLE SET PAGE NOPAGE END Region State Inventory ------ ----- ---------- Northeast CT 37234 MA 35720 NY 36248 Average Northeast 36400 West CA 75553 WA 40969 Average West 58261 TOTAL 45144 Average of Detail Lines
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 19971001 WHERE REGION EQ 'West' OR 'Northeast' ON TABLE SET PAGE NOPAGE ON TABLE SUBTOTAL ROLL.AVE. END Region State Inventory ------ ----- ---------- Northeast CT 37234 MA 35720 NY 36248 Average Northeast 36400 West CA 75553 WA 40969 Average West 58261 TOTAL 47330 Average of Summary Lines
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 19971001 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
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 1997/12/01 4648 1997/11/01 3144 1997/10/01 1597 *TOTAL PRODUCT Coffee Grinder 3129 Coffee Pot 1997/12/01 1769 1997/11/01 1462 1997/10/01 2346 *TOTAL PRODUCT Coffee Pot 1859 Croissant 1997/12/01 7436 1997/11/01 5528 1997/10/01 6060 *TOTAL PRODUCT Croissant 6341 *TOTAL REGION Midwest 3776 Aggregation at 3 levels plus total Average of date detail Average of product average
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 1997/12/01 1188 1997/11/01 2282 1997/10/01 3675 *TOTAL PRODUCT Capuccino 2381 Coffee Grinder 1997/12/01 1536 1997/11/01 1399 1997/10/01 1315 *TOTAL PRODUCT Coffee Grinder 1416 Coffee Pot 1997/12/01 1442 1997/11/01 2129 1997/10/01 2082 *TOTAL PRODUCT Coffee Pot 1884 Croissant 1997/12/01 4291 1997/11/01 6978 1997/10/01 4741 *TOTAL PRODUCT Croissant 5336 *TOTAL REGION Northeast 2754 TOTAL 3265 Average of date detail Average of product average Aggregation at 3 levels plus total
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
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
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.
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.
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
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
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
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
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
Hidden Gems 6 In expressions… Simplified functions – optimized for SQL VALIDATE with REGEX – putting regular expressions to work
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
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.
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
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
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 10 7 7 7 JAPAN JAPAN 10 5 5 5 ITALY ITALY 10 5 5 5 W GERMANY W GERMANY 10 9 9 9 FRANCE FRANCE 10 6 6 6
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 = -12345.56; COMPUTE ALPHAVAL1/A10 = DIGITS(VALUE1,10); COMPUTE ALPHAVAL2/A4 = DIGITS(VALUE1,4); COMPUTE EDITVAL2/A15 = EDIT(VALUE1); END COUNTRY VALUE1 ALPHAVAL1 ALPHAVAL2 EDITVAL2 ------- ------ --------- --------- -------- ENGLAND -12345 0000012345 2345 0000012345 JAPAN -12345 0000012345 2345 0000012345 ITALY -12345 0000012345 2345 0000012345 W GERMANY -12345 0000012345 2345 0000012345 FRANCE -12345 0000012345 2345 0000012345
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 2016/04/27 2016/04/27 00:00:00 2016/06/27 2016/05/02 2016/06/27 2016/05/02 00:00:00 JAPAN 2016/04/27 2016/04/27 00:00:00 2016/06/27 2016/05/02 2016/06/27 2016/05/02 00:00:00 ITALY 2016/04/27 2016/04/27 00:00:00 2016/06/27 2016/05/02 2016/06/27 2016/05/02 00:00:00 W GERMANY 2016/04/27 2016/04/27 00:00:00 2016/06/27 2016/05/02 2016/06/27 2016/05/02 00:00:00 FRANCE 2016/04/27 2016/04/27 00:00:00 2016/06/27 2016/05/02 2016/06/27 2016/05/02 00:00:00
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 2016/04/27 2016/04/27 00:00:00 4 27 4 27 APR JAPAN 2016/04/27 2016/04/27 00:00:00 4 27 4 27 APR ITALY 2016/04/27 2016/04/27 00:00:00 4 27 4 27 APR W GERMANY 2016/04/27 2016/04/27 00:00:00 4 27 4 27 APR FRANCE 2016/04/27 2016/04/27 00:00:00 4 27 4 27 APR
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:
Hidden Gems 6 VALIDATE with Regular Expressions - Positive testing -REPEAT NEXTFMT FOR &FMTCNT FROM 1 TO 2 -SET &EMPID1=DECODE &FMTCNT(1 '071382660' 2 '818-69-2173'); -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 = 071382660 EMP_ID CURR_SAL 071382660 $11,000.00 Testing EMPID = 818-69-2173 818692173 $27,062.00
Hidden Gems 6 VALIDATE with Regular Expressions – Incorrect value -REPEAT NEXTFMT FOR &FMTCNT FROM 1 TO 2 -SET &EMPID1=DECODE &FMTCNT(1 '071382660' 2 '818-69-2173'); -TYPE EMPID1 = &EMPID1 -SET &EMPID=&EMPID1.(|VALIDATE=REGEX,REGEX='^\d{3}\d{2}\d{4}$').Employee ID.; -TYPE EMPID = &EMPID -NEXTFMT EMPID1 = 071382660 EMPID = 071382660 EMPID1 = 818-69-2173 ERROR AT OR NEAR LINE 7 IN PROCEDURE __WCFEX FOCEXEC * (FOC2910) RESPONSE DOES NOT MATCH THE REGULAR EXPRESSION: 818-69-2173 (FOC295) A VALUE IS MISSING FOR: &EMPID1
Hidden Gems 6 In output … FOCUS and XFOCUS files – the ultimate hold file format
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
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 255 2-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 1022 32-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
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 ,$
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,$
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];,$
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
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?
Socialize to Win! Daily Prizes Awarded! Tweet at @infobldrs and tag #IBSummit during the event! Tag @informationbuilders in your #IBSummit pics! Check our Summit Facebook & LinkedIn pages for updates, photos, and announcements