The following features were added as of FOCUS 7.7.07.
SET FLOATMAPPING enables you to take advantage of decimal-based precision numbers available in DB2 and Oracle, and extends that functionality to all numeric processing for floating point numbers. With this processing, you gain both precision, including improved rounding, and enhanced performance.
The syntax is
SET FLOATMAPPING = {D|M|X}
where:
Uses the standard double-precision processing. This is the default value.
Uses a new internal format that provides decimal precision for double-precision floating point numbers up to 16 digits.
Uses a new internal format that provides decimal precision for double-precision floating point numbers up to 34 digits.
Note: If the field is passed to a HOLD file, the internal data types X or M will be propagated to the USAGE and ACTUAL formats in the HOLD Master File.
How to: |
Reference: |
Using the PARTITION_AGGR function, you can generate rolling calculations based on a block of rows from the internal matrix of a TABLE request. In order to specify how to determine the limits of the rolling calculations, you specify a partition of the data based on either a sort field or the entire TABLE. Within either type of break, you can start calculating from the beginning of the break or a number of rows prior to the current row. You can stop the rolling calculation at the current row or the end of the partition.
By default, the field values used in the calculations are the summed values of a measure in the request. Certain prefix operators can be used to add a column to the internal matrix and use that column in the rolling calculations. The rolling calculation can be SUM, AVE, CNT, MIN, MAX, FST, or LST.
PARTITION_AGGR([prefix.]measure,{sortfield|TABLE},from,to,operation)
where:
Defines an aggregation operator to apply to the measure before using it in the rolling calculation. Valid operators are:
Note: The operators PCT., RPCT., TOT., MDN., and DST. are not supported. COMPUTEs that reference those unsupported operators are also not supported.
Is the measure field to be aggregated. It can be a real field in the request or a calculated value generated with the COMPUTE command, as long as the COMPUTE does not reference an unsupported prefix operator.
Is a BY or ACROSS field that defines the boundary of the partition. Operations will not cross a boundary. In the request the BY HIGHEST phrase to sort high-to-low is supported. ACROSS COLUMNS AND is also supported, but BY ROWS OVER and FOR are not supported.
Specifying TABLE as the boundary makes the partition boundary the entire internal matrix.
For example, if the sort is BY YEAR BY MONTH, with data from both 2014 and 2015, specifying the boundary as YEAR means that January 2015 - 2 will be valued as zero (0) or MISSING, as two months prior to January 2015 would cross the YEAR boundary. However, specifying TABLE as the boundary and requesting - 2 months would return the data for November 2014.
Identifies the starting point for the rolling calculation. Valid values are:
Identifies the ending point of the rolling calculation. Valid values are:
Specifies the rolling calculation used on the values in the internal matrix. Supported operations are:
The calculation is performed prior to any WHERE TOTAL tests, but after WHERE_GROUPED tests.
The following request calculates a rolling average of the current line and the previous line in the internal matrix within the quarter.
TABLE FILE WFLITE SUM COGS_US COMPUTE AVE1/D12.2M = PARTITION_AGGR(COGS_US, TIME_QTR, -1, C, AVE); BY BUSINESS_REGION BY TIME_QTR BY TIME_MTH WHERE BUSINESS_REGION EQ 'North America' OR 'South America' ON TABLE SET PAGE NOLEAD END
The output is shown in the following image. Within each quarter, the first average is just the value from Q1, as going back 1 would cross a boundary. The second average is calculated using the first two rows within that quarter, and the third average is calculated using rows 2 and 3 within the quarter.
The following changes the rolling average to start from the beginning of the sort break.
COMPUTE AVE1/D12.2M = PARTITION_AGGR(COGS_US, TIME_QTR ,B, C, AVE);
The output is shown in the following image. Within each quarter, the first average is just the value from Q1, as going back would cross a boundary. The second average is calculated using the first two rows within that quarter, and the third average is calculated using rows 1 through 3 within the quarter.
The following command uses the partition boundary TABLE.
COMPUTE AVE1/D12.2M = PARTITION_AGGR(COGS_US, TABLE, B, C, AVE);
The output is shown in the following image. The rolling average keeps adding the next row to the average until a break in the business region sort field.
TABLE FILE WFLITE SUM COGS_US WITHIN TIME_QTR AS 'WITHIN Qtr' COMPUTE PART_WITHIN_QTR/D12.2M = PARTITION_AGGR(COGS_US, TIME_QTR, B, E, SUM); BY BUSINESS_REGION AS Region BY TIME_QTR BY TIME_MTH WHERE BUSINESS_REGION EQ 'North America' OR 'South America' ON TABLE SET PAGE NOPAGE END
The output is shown in the following image.
With other types of calculations, the results are not the same. For example, the following request calculates the average within quarter using the WITHIN phrase and the average with quarter using PARTITION_AGGR.
TABLE FILE WFLITE SUM COGS_US AS Cost CNT.COGS_US AS Count AVE.COGS_US WITHIN TIME_QTR AS 'Ave Within' COMPUTE PART_WITHIN_QTR/D12.2M = PARTITION_AGGR(COGS_US, TIME_QTR, B, E, AVE); BY BUSINESS_REGION AS Region BY TIME_QTR ON TIME_QTR SUBTOTAL COGS_US CNT.COGS_US BY TIME_MTH WHERE BUSINESS_REGION EQ 'North America' ON TABLE SET PAGE NOPAGE END
The output is shown in the following image. The average using the WITHIN phrase divides the total cost for the quarter by the total count of instances for the quarter (for example, $435,992.00/1514 =$287.97), while PARTITION_AGGR divides the total cost for the quarter by the number of report rows in the quarter (for example, $435,992.00/3 = $145,330.67).
How to: |
Reference: |
Use of LAST in a calculation retrieves the LAST value of the specified field the last time this calculation was performed. The PARTITION_REF function enables you to specify both how many rows back to go in order to retrieve a prior value, and a sort break within which the prior value calculation will be contained.
PARTITION_REF([prefix.]field, {sortfield|TABLE}, -offset)
where:
Is optional. If used, it can be one of the following aggregation operators:
Is the field whose prior value is to be retrieved.
Is the sort break within which to go back to retrieve the value. TABLE means retrieve the value without regard to sort breaks. Operations will not cross a partition boundary.
The Sort field may use BY HIGHEST to indicate a HIGH-TO-LOW sort. ACROSS COLUMNS AND is supported. BY ROWS OVER and FOR are not supported.
Is the integer number of records back to go to retrieve the value.
If the offset is prior to the partition boundary sort value, the return will be the default value for the field. The calculation is performed prior to any WHERE TOTAL tests, but after WHERE_GROUPED tests.
The following request retrieves the previous record within the sort field PRODUCT_CATEGORY.
TABLE FILE WFLITE SUM DAYSDELAYED COMPUTE NEWDAYS/I5=PARTITION_REF(DAYSDELAYED, PRODUCT_CATEGORY, -1); BY PRODUCT_CATEGORY BY PRODUCT_SUBCATEG ON TABLE SET PAGE NOPAGE END
The output is shown in the following image. The first value within each sort break is zero because there is no prior record to retrieve.
The following request retrieves the average cost of goods from two records prior to the current record within the PRODUCT_CATEGORY sort field.
TABLE FILE WFLITE SUM COGS_US AVE.COGS_US AS Average COMPUTE PartitionAve/D12.2M=PARTITION_REF(AVE.COGS_US, PRODUCT_CATEGORY, -2); BY PRODUCT_CATEGORY BY PRODUCT_SUBCATEG ON TABLE SET PAGE NOPAGE END
The output is shown in the following image.
Replacing the function call with the following syntax changes the partition boundary to TABLE.
COMPUTE PartitionAve/D12.2M=PARTITION_REF(AVE.COGS_US, TABLE, -2);
The output is shown in the following image.
How to: |
As FOCUS commands are encountered in a procedure, they are placed on a stack in memory (called FOCSTACK). The procedure is executed and the stack counter reset to zero (0) as a result a -RUN command, certain system variables, or the end of the procedure.
The parameter DMH_STACKLIM sets the maximum number of lines allowed in the FOCSTACK. This parameter is designed to prevent runaway tasks that generate a FOCSTACK that uses an inordinate amount of memory.
If users are not careful in designing loops in Dialogue Manager, they can inadvertently cause an infinite looping condition.
The parameter DMH_LOOPLIM sets the maximum number of Dialogue Manager loop iterations allowed, using -REPEAT or -GOTO commands.
DMH_STACKLIM and DMH_LOOPLIM should be set high enough to run your existing reports and procedures without error for your entire session. It is recommended that if you set these parameters, you should set them in a profile.
SET DMH_STACKLIM = n
where:
Sets the maximum number of lines allowed in FOCSTACK. The default value is zero (0), which does not limit the number of stacked commands.
SET DMH_LOOPLIM = n
where:
Sets the maximum number of loop iterations allowed. The default value is zero (0), which does not limit the number of loop iterations.
The SET PCOMMA=DFIX command causes delimited files with SUFFIX=COM, COMT, TAB, and TABT to be processed through the Adapter for DFIX. This processing provides more complete and meaningful messages and some changes to the processing of missing values when two delimiters in a row are encountered. With DFIX processing, a missing value is assigned to the field.
In order to be eligible for DFIX processing, the delimited file must satisfy the following requirements.
(FOC229) ERROR READING EXTERNAL DATA FILE: file
(FOC416) MORE VALUES SUPPLIED THAN FIELDS IN THE MASTER FILE DESCRIPTION
Given a date or date-time value and a time period, the DTRUNC function returns the date that is the beginning of that period. The parameter WEEK has been added, which returns the date that represents the first date of the given week. By default, the first day will be Sunday, but this can be changed using the WEEKFIRST parameter.
The following request returns the date that is the start of the week for the start date of certain employees:
DEFINE FILE WFLITE DAY1/WT = DTRUNC(START_DATE, DAY); WKSTART/YYMD = DTRUNC(START_DATE, WEEK); DAY2/WT = DTRUNC(WKSTART, DAY); END TABLE FILE WFLITE PRINT START_DATE DAY1 AS 'DOW 1' WKSTART AS 'Start,of Week' DAY2 AS 'DOW 2' BY EMPLOYEE_NUMBER WHERE START_DATE GT '20130101' WHERE EMPLOYEE_NUMBER CONTAINS 'AH' ON TABLE SET PAGE NOPAGE END
The output is:
Employee Start Start Number Date DOW 1 of Week DOW 2 -------- ----- ----- ------- ----- AH118 2013/01/15 TUE 2013/01/13 SUN AH2272 2013/01/17 THU 2013/01/13 SUN AH288 2013/11/11 MON 2013/11/10 SUN AH3520 2013/09/23 MON 2013/09/22 SUN AH3591 2013/09/22 SUN 2013/09/22 SUN AH5177 2013/07/21 SUN 2013/07/21 SUN
Given a date or timestamp and a component, DTRUNC returned the first date within the period specified by that component.
The following components have been added that return the last date within the period specified by the component.
This function is available in both FOCUS and SQL.
Note: You can change which day is considered the first day of the week using the WEEKFIRST parameter. By default, it is Sunday.
The following request returns the dates that corresponds to the first day of the week and the last day of the week for the given date.
DEFINE FILE WFLITE WEEKSTART/YYMD = DTRUNC(START_DATE, WEEK); WEEKEND/YYMD = DTRUNC(START_DATE, WEEK_END); END TABLE FILE WFLITE PRINT START_DATE WEEKSTART AS 'Start,of Week' WEEKEND AS 'End,of Week' BY EMPLOYEE_NUMBER WHERE EMPLOYEE_NUMBER CONTAINS 'AH1' ON TABLE SET PAGE NOPAGE END
The output is shown in the following image.
In this section: |
New numeric functions have been developed that make it easier to understand and enter the required arguments. These functions have streamlined parameter lists, similar to those used by SQL functions. In some cases, these simplified functions provide slightly different functionality than previous versions of similar functions.
The simplified functions do not have an output argument. Each function returns a value that has a specific data type.
When used in a request against a relational data source, these functions are optimized (passed to the RDBMS for processing).
Note:
How to: |
CEILING returns the smallest integer value that is greater than or equal to a number.
CEILING(number)
where:
Numeric
Is the number whose ceiling will be returned. The output data type is the same as the input data type.
In the following request, CEILING returns the smallest integer greater than or equal to the GROSS_PROFIT_US value.
DEFINE FILE WFLITE CEIL1/D7.2= CEILING(GROSS_PROFIT_US); END TABLE FILE WFLITE PRINT GROSS_PROFIT_US/D9.2 CEIL1 ON TABLE SET PAGE NOPAGE END
The partial output follows. Note that even though the value returned is an integer, it is returned with the same format as the CEIL1 field (D7.2):
Gross Profit CEIL1 ------------ ----- 165.00 165.00 13.99 14.00 60.99 61.00 225.98 226.00 79.99 80.00 44.59 45.00 94.30 95.00 238.50 239.00 199.99 200.00 68.99 69.00 63.58 64.00 129.99 130.00 37.49 38.00 75.99 76.00 13.99 14.00 119.00 119.00 -30.01 -30.00 54.99 55.00 189.98 190.00 44.59 45.00 91.98 92.00 89.00 89.00 59.50 60.00 129.99 130.00 54.00 54.00 109.98 110.00 98.99 99.00 98.99 99.00 99.99 100.00 44.59 45.00
How to: |
EXPONENT raises the constant e to a power.
EXPONENT(power)
where:
Numeric
Is the power to which to raise e. The output data type is numeric.
The following request prints the value of e and the value of e raised to the fifth power.
DEFINE FILE WFLITE EXP1/D12.5 = EXPONENT(1); EXP2/D12.5 = EXPONENT(5); END TABLE FILE WFLITE PRINT EXP1 EXP2 BY BUSINESS_REGION AS Region WHERE BUSINESS_REGION EQ 'EMEA' WHERE RECORDLIMIT EQ 1 ON TABLE SET PAGE NOPAGE END
The output is shown in the following image.
How to: |
FLOOR returns the largest integer value that is less than or equal to a number.
FLOOR(number)
where:
Numeric
Is the number whose floor will be returned. The output data type is the same as the input data type.
In the following request, FLOOR returns the largest integer less than or equal to the GROSS_PROFIT_US value.
DEFINE FILE WFLITE FLOOR1/D7.2= FLOOR(GROSS_PROFIT_US); END TABLE FILE WFLITE PRINT GROSS_PROFIT_US/D9.2 FLOOR1 ON TABLE SET PAGE NOPAGE END
Partial output follows. Note that even though the value returned is an integer, it is returned with the same format as the FLOOR1 field (D7.2):
Gross Profit FLOOR1 ------------ ------ 165.00 165.00 13.99 13.00 60.99 60.00 225.98 225.00 79.99 79.00 44.59 44.00 94.30 94.00 238.50 238.00 199.99 199.00 68.99 68.00 63.58 63.00 129.99 129.00 37.49 37.00 75.99 75.00 13.99 13.00 119.00 119.00 -30.01 -31.00 54.99 54.00 189.98 189.00 44.59 44.00 91.98 91.00 89.00 89.00 59.50 59.00 129.99 129.00 54.00 54.00 109.98 109.00 98.99 98.00 98.99 98.00 99.99 99.00 44.59 44.00
How to: |
MOD calculates the remainder from a division. The output data type is the same as the input data type.
MOD(dividend, divisor)
where:
Numeric
Is the value to divide.
Numeric
Is the value to divide by.
If the divisor is zero (0), the dividend is returned.
In the following request, MOD returns the remainder of PRICE_DOLLARS divided by DAYSDELAYED:
DEFINE FILE WFLITE MOD1/D7.2= MOD(PRICE_DOLLARS, DAYSDELAYED); END TABLE FILE WFLITE PRINT PRICE_DOLLARS/D7.2 DAYSDELAYED/I5 MOD1 WHERE DAYSDELAYED GT 1 ON TABLE SET PAGE NOPAGE ON TABLE PCHOLD FORMAT WP END
Partial output follows:
Price Days Dollars Delayed MOD1 ------- ------- ---- 399.00 3 .00 489.99 3 .99 786.50 2 .50 599.99 4 3.99 29.99 4 1.99 169.00 2 1.00 219.99 2 1.99 280.00 3 1.00 79.99 4 3.99 145.99 2 1.99 399.99 3 .99 349.99 3 1.99 169.00 3 1.00
How to: |
POWER raises a base value to a power.
POWER(base, power)
where:
Numeric
Is the value to raise to a power. The output value has the same data type as the base value. If the base value is integer, negative power values will result in truncation.
Numeric
Is the power to which to raise the base value.
In the following request, POWER returns the value COGS_US/20.00 raised to the power stored in DAYSDELAYED:
DEFINE FILE WFLITE BASE=COGS_US/20.00; POWER1= POWER(COGS_US/20.00,DAYSDELAYED); END TABLE FILE WFLITE PRINT BASE IN 15 DAYSDELAYED POWER1 BY PRODUCT_CATEGORY WHERE PRODUCT_CATEGORY EQ 'Computers' WHERE DAYSDELAYED NE 0 ON TABLE SET PAGE NOPAGE END
Partial output follows:
Product Days Category BASE Delayed POWER1 -------- ---- ------- ------ Computers 12.15 3 1,793.61 16.70 2 278.89 8.35 1 8.35 8.10 2 65.61 4.05 1 4.05 4.05 2 16.40 4.05 4 269.04 8.35 1 8.35 16.70 1 16.70 8.35 3 582.18 8.35 1 8.35 4.05 1 4.05 4.05 1 4.05 8.35 4 4,861.23 8.35 -1 .12 8.35 1 8.35 8.35 3 582.18
In this section: |
New simplified character functions CONCAT, REGEX, REPLACE, and SPLIT functions have been added.
How to: |
LAST_NONBLANK retrieves the last field value that is neither blank nor missing. If all previous values are either blank or missing, LAST_NONBLANK returns a missing value.
LAST_NONBLANK(field)
where:
Is the field name whose last non-blank value is to be retrieved. If the current value is not blank or missing, the current value is returned.
Note: LAST_NONBLANK cannot be used in a compound expression, for example, as part of an IF condition.
The following request shows the SALARY field, the LAST_NONBLANK value from a DEFINE, and the LAST_NONBLANK value from a COMPUTE.
DEFINE FILE EMPLOYEE MYSAL/I5 MISSING ON=IF DEPARTMENT EQ 'MIS' THEN SALARY ELSE MISSING; LAST_NONBLANK1/I5 MISSING ON= LAST_NONBLANK(MYSAL); END TABLE FILE EMPLOYEE PRINT LAST_NAME MYSAL LAST_NONBLANK1 COMPUTE LAST_NONBLANK2/I5 MISSING ON=LAST_NONBLANK(MYSAL); ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * GRID=OFF,$ END
The output is shown in the following image.
How to: |
The REGEX function matches a string to a regular expression and returns true (1) if it matches and false (0) if it does not match.
A regular expression is a sequence of special characters and literal characters that you can combine to form a search pattern.
Many references for regular expressions exist on the web.
REGEX(string, regular_expression)
where:
Alphanumeric
Is the character string to match.
Alphanumeric
Is a regular expression enclosed in single quotation marks (') constructed using literals and metacharacters. The following metacharacters are supported
For example, the regular expression '^Ste(v|ph)en$' matches values starting with Ste followed by either ph or v, and ending with en.
Note: The output value is numeric.
The following request matches the FIRSTNAME field against the regular expression '^Sara(h?)$', which matches Sara or Sarah:
TABLE FILE WFLITE PRINT FIRSTNAME AND COMPUTE REG1/I1=REGEX(FIRSTNAME,'^Sara(h?)$') ; BY LASTNAME/A10 WHERE LASTNAME EQ 'Allen' END
The output is
First LASTNAME Name REG1 -------- ----- ---- Allen Penny 0 Rosemary 0 Amber 0 Julie 0 Sarah 1 Leo 0 Margret 0 Donna 0 Damian 0 Alexander 0 Diego 0 Amber 0 Susan 0 Amber 0 Sara 1 Sara 1
How to: |
CONCAT removes trailing blanks from a string and then concatenates another string to it. The output is returned as variable length alphanumeric.
CONCAT(string1, string2)
where:
Alphanumeric
Is a string whose trailing blanks will be removed.
Alphanumeric
Is a string whose leading and trailing blanks will be preserved.
The following request concatenates city names with state names. Note that the city and state names are converted to fixed length alphanumeric fields before concatenation.
DEFINE FILE WFLITE CITY/A50 = CITY_NAME; STATE/A50 = STATE_PROV_NAME; CONCAT_CS/A100 = CONCAT(CITY,STATE); END TABLE FILE WFLITE SUM CITY AS City STATE AS State CONCAT_CS AS Concatenation BY STATE_PROV_NAME NOPRINT WHERE COUNTRY_NAME EQ 'United States' WHERE STATE LE 'Louisiana' ON TABLE SET PAGE NOLEAD END
The output is shown in the following image.
How to: |
REPLACE replaces all instances of a search string in an input string with the given replacement string. The output is always variable length alphanumeric with a length determined by the input parameters.
REPLACE(input_string , search_string , replacement)
where:
Alphanumeric or text (An, AnV, TX)
Is the input string.
Alphanumeric or text (An, AnV, TX)
Is the string to search for within the input string.
Alphanumeric or text (An, AnV, TX)
Is the replacement string to be substituted for the search string. It can be a null string ('').
REPLACE replaces the string 'South' in the Country Name with the string 'S.'
SET TRACEUSER = ON SET TRACEON = STMTRACE//CLIENT SET TRACESTAMP=OFF DEFINE FILE WFLITE NEWNAME/A20 = REPLACE(COUNTRY_NAME, 'SOUTH', 'S.'); END TABLE FILE WFLITE SUM COUNTRY_NAME BY NEWNAME AS 'New,Name' WHERE COUNTRY_NAME LIKE 'S%' ON TABLE SET PAGE NOLEAD END
The generated SQL passes the REPLACE function to the DBMS REPLACE function.
SELECT REPLACE(T3."COUNTRY_NAME",'SOUTH','S.'), MAX(T3."COUNTRY_NAME") FROM wrd_wf_retail_geography T3 WHERE (T3."COUNTRY_NAME" LIKE 'S%') GROUP BY REPLACE(T3."COUNTRY_NAME",'SOUTH','S.') ORDER BY REPLACE(T3."COUNTRY_NAME",'SOUTH','S.');
The output is shown in the following image.
In the following request, the virtual field DAYNAME1 is the string DAY1 with all instances of the string 'DAY' replaced with the string 'day'. The virtual field DAYNAME2 has all instances of the string 'DAY' removed.
DEFINE FILE WFLITE DAY1/A30 = 'SUNDAY MONDAY TUESDAY'; DAYNAME1/A30 = REPLACE(DAY1, 'DAY', 'day' ); DAYNAME2/A30 = REPLACE(DAY1, 'DAY', '' ); END TABLE FILE WFLITE PRINT DAY1 OVER DAYNAME1 OVER DAYNAME2 WHERE EMPLOYEE_NUMBER EQ 'AH118' ON TABLE SET PAGE NOPAGE END
The output is:
DAY1 SUNDAY MONDAY TUESDAY DAYNAME1 SUNday MONday TUESday DAYNAME2 SUN MON TUES
How to: |
The SPLIT function returns a specific type of element from a string. The output is returned as variable length alphanumeric.
SPLIT(element, string)
where:
Can be one of the following keywords:
Alphanumeric
Is the string from which the element will be extracted.
The following request defines strings and extracts elements from them.
DEFINE FILE WFLITE STRING1/A50 WITH COUNTRY_NAME= 'http://www.informationbuilders.com'; STRING2/A20 = 'user1@ibi.com'; STRING3/A20 = 'Louisa May Alcott'; Protocol/A20 = SPLIT(URL_PROTOCOL, STRING1); Path/A50 = SPLIT(URL_PATH, STRING1); Domain/A20 = SPLIT(EMAIL_DOMAIN, STRING2); User/A20 = SPLIT(EMAIL_USERID, STRING2); First/A10 = SPLIT(NAME_FIRST, STRING3); Last/A10 = SPLIT(NAME_LAST, STRING3); END TABLE FILE WFLITE SUM Protocol Path User Domain First Last ON TABLE SET PAGE NOLEAD END
The output is shown in the following image.
How to: |
CHECKMD5 takes an alphanumeric input value and returns a 128-bit value in a fixed length alphanumeric string, using the MD5 hash function. A hash function is any function that can be used to map data of arbitrary size to data of fixed size. The values returned by a hash function are called hash values. They can be used for assuring the integrity of transmitted data.
CHECKMD5(buffer)
where:
Is a data buffer whose hash value is to be calculated. It can be a set of data of different types presented as a single field, or a group field in one of the following data type formats: An, AnV, or TXn.
The following request calculates an MD5 hash check value and converts it to an alphanumeric hexadecimal value for display.
DEFINE FILE WFLITE MD5/A32 = HEXTYPE(CHECKMD5(PRODUCT_CATEGORY)); END TABLE FILE WFLITE SUM MD5 BY PRODUCT_CATEGORY ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * TYPE=REPORT,FONT=COURIER,$ ENDSTYLE END
The output is shown in the following image. The monospaced font shows that although the input values have varying length, the output has a fixed length.
How to: |
CHECKSUM computes a hash sum, called the checksum, of its input parameter, as a whole number in format I11. This can be used for equality search of the fields. A checksum is a hash sum used to ensure the integrity of a file after it has been transmitted from one storage device to another.
CHECKSUM(buffer)
where:
Is a data buffer whose hash index is to be calculated. It can be a set of data of different types presented as a single field, in one of the following data type formats: An, AnV, or TXn.
The following request computes a checksum hash value.
DEFINE FILE WFLITE CHKSUM/I11 = (CHECKSUM(PRODUCT_CATEGORY)); END TABLE FILE WFLITE PRINT CHKSUM BY PRODUCT_CATEGORY WHERE PRODUCT_CATEGORY NE LAST PRODUCT_CATEGORY ON TABLE SET PAGE NOLEAD END
The output is shown in the following image.
New simplified conversion functions CHAR, CTRL_CHAR, EDIT2, HEXTYPE, TO_INTEGER, and TO_NUMBER have been added.
How to: |
The CHAR function accepts a decimal integer and returns the character identified by that number converted to ASCII or EBCDIC, depending on the operating environment. The output is returned as variable length alphanumeric. If the number is above the range of valid characters, a null is returned.
CHAR(number_code)
where:
Integer
Is a field, number, or numeric expression whose whole absolute value will be used as a number code to retrieve an output character.
For example, a TAB character is returned by CHAR(9) in ASCII environments, or by CHAR(5) in EBCDIC environments.
The following request defines a field with carriage return (CHAR(13)) and line feed (CHAR(10)) characters inserted between the words HELLO and GOODBYE (in an ASCII environment). To show that these characters were inserted, the output is generated in PDF format and the StyleSheet attribute LINEBREAK='CRLF' is used to have these characters respected and print the field value on two lines.
DEFINE FILE WFLITE MYFIELD/A20 WITH COUNTRY_NAME='HELLO' | CHAR(13) | CHAR(10) | 'GOODBYE'; END TABLE FILE WFLITE SUM MYFIELD ON TABLE PCHOLD FORMAT PDF ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * TYPE=REPORT,LINEBREAK='CRLF',$ ENDSTYLE END
The output is shown in the following image.
How to: |
The CTRLCHAR function returns a nonprintable control character specific to the running operating environment, based on a supported list of keywords. The output is returned as variable length alphanumeric.
CTRLCHAR(ctrl_char)
where:
Is one of the following keywords.
The following request defines a field with carriage return (CTRLCHAR(CR)) and line feed (CTRLCHAR(LF)) characters inserted between the words HELLO and GOODBYE. To show that these characters were inserted, the output is generated in PDF format and the StyleSheet attribute LINEBREAK='CRLF' is used to have these characters respected and print the field value on two lines.
DEFINE FILE WFLITE MYFIELD/A20 WITH COUNTRY_NAME='HELLO' | CTRLCHAR(CR) | CTRLCHAR(LF) | 'GOODBYE'; END TABLE FILE WFLITE SUM MYFIELD ON TABLE PCHOLD FORMAT PDF ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * TYPE=REPORT,LINEBREAK='CRLF',$ ENDSTYLE END
The output is shown in the following image.
How to: |
The EDIT2 function converts a numeric, date, or date-time value to a character string based on a specified format. The format must be valid for the data supplied. The output is returned as variable length alphanumeric.
EDIT2(in_value, 'format')
where:
Numeric, date, or date-time
Is any numeric value or a date in either standard date or date-time format. If the date is given in standard date format, all of its time components are assumed to be zero.
Is a numeric, date, or date-time format enclosed in single quotation marks (').
The following request defines a date field as YYMD format and converts it to a character string (CharDate) in YYMtrD format.
DEFINE FILE WFLITE DATE1/YYMD = TIME_DATE_DAY_COMPONENT; CharDate/A20 = EDIT2(DATE1,'YYMtrD'); END TABLE FILE WFLITE SUM COGS_US BY CharDate WHERE TIME_MTHNAME EQ 'FEB' ON TABLE SET PAGE NOLEAD END
The output is shown in the following image.
How to: |
The HEXTYPE function returns the hexadecimal view of an input value of any data type. The result is returned as variable length alphanumeric. The alphanumeric field to which the hexidecimal value is returned must be large enough to hold two characters for each input character. The value returned depends on the running operating environment.
HEXTYPE(in_value)
where:
Is an alphanumeric or integer field, constant, or expression.
The following request returns a hexadecimal view of the country names and the sum of the days delayed.
DEFINE FILE WFLITE Days/I8 = DAYSDELAYED; Country/A20 = COUNTRY_NAME; HexCountry/A30 = HEXTYPE(Country); END TABLE FILE WFLITE SUM COUNTRY_NAME NOPRINT Country HexCountry Days COMPUTE HexDays/A40 = HEXTYPE(Days); BY COUNTRY_NAME NOPRINT WHERE COUNTRY_NAME LT 'P' ON TABLE SET PAGE NOPAGE END
The output is shown in the following image.
PHONETIC calculates a phonetic key for a string, or a null value on failure. Phonetic keys are useful for grouping alphanumeric values, such as names, that may have spelling variations. This is done by generating an index number that will be the same for the variations of the same name based on pronunciation. One of two phonetic algorithms can be used for indexing, Metaphone and Soundex. Metaphone is the default algorithm, except on z/OS where the default is Soundex.
You can set the algorithm to use with the following command.
SET PHONETIC_ALGORITHM = {METAPHONE|SOUNDEX}
Most phonetic algorithms were developed for use with the English language. Therefore, applying the rules to words in other languages may not give a meaningful result.
Metaphone is suitable for use with most English words, not just names. Metaphone algorithms are the basis for many popular spell checkers.
Note: Metaphone is not optimized in generated SQL. Therefore, if you need to optimize the request for an SQL DBMS, the SOUNDEX setting should be used.
Soundex is a legacy phonetic algorithm for indexing names by sound, as pronounced in English.
PHONETIC(string)
where:
Alphanumeric
Is a string for which to create the key. A null value will be returned on failure.
The following request changes the spelling of the last name for MARY SMITH to SMYTHE and generates a phonetic key for each last name.
DEFINE FILE EMPLOYEE LAST_NAME2/A16 = IF LAST_NAME EQ 'SMITH' AND FIRST_NAME EQ 'MARY' THEN 'SMYTHE' ELSE LAST_NAME; PKEY/A10 = PHONETIC(LAST_NAME2); END TABLE FILE EMPLOYEE PRINT FIRST_NAME LAST_NAME2 BY PKEY ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * GRID=OFF,$ ENDSTYLE END
The output is shown in the following image. Note that the two spellings for SMITH are assigned the same index number.
TO_INTEGER converts a character string that contains a valid number consisting of digits and an optional decimal point to an integer value. If the value contains a decimal point, the value after the decimal point is truncated. If the value does not represent a valid number, zero (0) is returned.
TO_INTEGER(string)
where:
The following request converts character strings to integers. Digits following the decimal point are truncated.
DEFINE FILE WFLITE INT1/I8 = TO_INTEGER('56.78'); INT2/I8 = TO_INTEGER('.5678'); INT3/I8 = TO_INTEGER('5678'); END TABLE FILE WFLITE PRINT INT1 INT2 INT3 BY BUSINESS_REGION AS Region WHERE READLIMIT EQ 1 ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * GRID=OFF,$ ENDSTYLE END
The output is shown in the following image.
TO_NUMBER converts a character string that contains a valid number consisting of digits and an optional decimal point to the numeric format most appropriate to the context. If the value does not represent a valid number, zero (0) is returned.
TO_NUMBER(string)
where:
The following request converts character strings to double-precision floating point numbers.
DEFINE FILE WFLITE NUM1/D12.1 = TO_NUMBER('56.78'); NUM2/D12.2 = TO_NUMBER('0.5678'); END TABLE FILE WFLITE PRINT NUM1 NUM2 BY BUSINESS_REGION AS Region WHERE READLIMIT EQ 1 ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * GRID=OFF,$ ENDSTYLE END
The output is shown in the following image.
In this section: |
The new simplified date functions DT_CURRENT_DATE, DT_CURRENT_DATETIME, and DT_CURRENT_TIME have been added.
How to: |
The DT_CURRENT_DATE function returns the current date-time provided by the running operating environment in date-time format. The time portion of the datetime is set to zero.
DT_CURRENT_DATE()
The following request returns the current date.
DEFINE FILE WFLITE CURRDATE/YYMD WITH COUNTRY_NAME = DT_CURRENT_DATE(); END TABLE FILE WFLITE SUM CURRDATE ON TABLE SET PAGE NOPAGE END
The output is shown in the following image.
How to: |
DT_CURRENT_DATETIME returns the current date and time provided by the running operating environment in date-time format, with a specified time precision.
DT_CURRENT_DATETIME(component)
where:
Is one of the following time precisions.
Note: The field to which the value is returned must have a format that supports the time precision requested.
The following request returns the current date and time, with the time specified in microseconds.
DEFINE FILE WFLITE CURRDATE/HYYMDm WITH COUNTRY_NAME = DT_CURRENT_DATETIME(MICROSECOND); END TABLE FILE WFLITE SUM CURRDATE ON TABLE SET PAGE NOPAGE END
The output is shown in the following image.
How to: |
The DT_CURRENT_TIME function returns the current time provided by the running operating environment in date-time format, with a specified time precision. The date portion of the returned date-time value is set to zero.
DT_CURRENT_TIME(component)
where:
Is one of the following time precisions.
Note: The field to which the value is returned must have a format that supports the time precision requested.
The following request returns the current time, with the time precision set to milliseconds.
DEFINE FILE WFLITE CURRTIME/HHISs WITH COUNTRY_NAME = DT_CURRENT_TIME(MILLISECOND); END TABLE FILE WFLITE SUM CURRTIME ON TABLE SET PAGE NOPAGE END
The output is shown in the following image.
In this section: |
Simplified system functions ENCRYPT, GETENV, and PUTENV have been added.
How to: |
The ENCRYPT function encrypts an alphanumeric input value using the encryption algorithm configured in FOCUS. The result is returned as variable length alphanumeric.
ENCRYPT(password)
where:
Fixed length alphanumeric
Is the value to be encrypted.
The following request encrypts the value guestpassword using the encryption algorithm configured in FOCUS.
-SET &P1 = ENCRYPT('guestpassword'); -TYPE &P1
The returned encrypted value is {AES}963AFA754E1763ABE697E8C5E764115E.
How to: |
The GETENV function takes the name of an environment variable and returns its value as a variable length alphanumeric value.
GETENV(var_name)
where:
fixed length alphanumeric
Is the name of the environment variable whose value is being retrieved.
The following request retrieves the value of the variable EDAEXTSEC.
-SET &E1 = GETENV('EDAEXTSEC'); -TYPE &E1
The value returned is ON if FOCUS was started with security on or OFF if FOCUS was started with security off.
How to: |
The PUTENV function assigns a value to an environment variable. The function returns an integer return code whose value is 1 (one) if the assignment is not successful or 0 (zero) if it is successful.
PUTENV(var_name, var_value)
where:
Fixed length alphanumeric
Is the name of the environment variable to be set.
Alphanumeric
Is the value you want to assign to the variable.
The following request assigns the value FOCUS/Shell: to the UNIX PS1 variable.
-SET &P1 = PUTENV('PS1','FOCUS/Shell:');
This causes UNIX to display the following prompt when the user issues the UNIX shell command SH:
FOCUS/Shell:
The following request creates a variable named xxxx and sets it to the value this is a test. It then retrieves the value using GETENV.
-SET &XXXX=PUTENV(xxxx,'this is a test'); -SET &YYYY=GETENV(xxxx); -TYPE Return Code: &XXXX, Variable value: &YYYY
The output is:
Return Code: 0, Variable value: this is a test
The following automatic direct operations are supported between date and date-time formats:
Assignment of a date field or a date constant to a date-time field. The time component is set to zero (midnight). The date can be a full component date such as YYMD or a partial component date such as YYM. It cannot be a single component date such as Q, as this type of date, although displayed as a date in reports, is stored as an integer value and is used as an integer value in expressions.
Assignment of a date-time field or date-time constant to a date field. The time components are removed.
When a date-time value is compared with or subtracted from a date value, or a date value is compared with or subtracted from a date-time value, the date is converted to date-time with the time component set to midnight. They are then compared or subtracted as date-time values.
Simplified date functions can use either date or date-time values as their date parameters. Legacy user functions do not support this new functionality. The date-time functions (H functions) use date-time parameters and the new date functions use new dates, which are stored as offsets from a base date.
Recognition and use of date or date-time constants.
In this case, the size in terms of number of digits is strictly limited to at least six for a full component date or date-time value, (eight for a four-digit year), three for a partial component date, and one for a single component date.
For information about creating and using date and date-time constants, see the Describing Data manual.
The following request generates a date-time value using the DT_CURRENT_DATETIME function. It then assigns this value to a date field and assigns that date field to a date-time field.
TABLE FILE WFLITE PRINT QUANTITY_SOLD NOPRINT AND COMPUTE DATETIME1/HYYMDm = DT_CURRENT_DATETIME(MILLISECOND); AS 'Date-Time 1' COMPUTE DATE1/YYMD = DATETIME1; AS 'Date' COMPUTE DATETIME2/HYYMDm = DATE1; AS 'Date-Time 2' WHERE RECORDLIMIT EQ 20 ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * GRID=OFF,$ ENDSTYLE END
The output is shown in the following image. The original date-time field has a non-zero time component. When assigned to the date field, the time component is removed. When that date is assigned to the second date-time field, a zero time component is added.
The following request creates one date-time field and one date field. When quantity sold is 1, they have the same date value and the date-time field has a zero time component. When quantity sold is 2, they have different date values, and the date-time field has a zero time component. In all other cases, the date-time field has the current date with a non-zero time component, and the date field has the current date. The EQUAL1 field compares them to see if they compare as equal.
TABLE FILE WFLITE PRINT QUANTITY_SOLD AS Quantity AND COMPUTE DATETIME1/HYYMDm = IF QUANTITY_SOLD EQ 1 THEN '2017/06/05' ELSE IF QUANTITY_SOLD EQ 2 THEN '2016/02/29' ELSE DT_CURRENT_DATETIME(MILLISECOND); AS 'Date-Time' COMPUTE DATE1/YYMD = IF QUANTITY_SOLD EQ 1 THEN '2017/06/05' ELSE IF QUANTITY_SOLD EQ 2 THEN '2015/12/30' ELSE DT_CURRENT_DATE(); AS 'Date' COMPUTE EQUAL1/A1 = IF DATETIME1 EQ DATE1 THEN 'Y' ELSE 'N'; AS 'Equal?' WHERE RECORDLIMIT EQ 12 ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * GRID=OFF,$ ENDSTYLE END
The output is shown in the following image. When a date value is compared to a date-time value, the date is converted to a date-time value with the time component set to zero, and then the values are compared. Therefore, when QUANTITY_SOLD is 1, both the date components are equal and the time component of the date-time field is set to zero, so when the date is converted to a date-time value, they are equal. When QUANTITY_SOLD is 2, the date components are different, so they are not equal. When QUANTITY_SOLD is 3, the date components are the same, but the date-time field has a non-zero time component. Therefore, when the date field is converted to a date-time value with a zero time component and they are compared, they are not equal.
In this section: |
Reference: |
The LNGPREP utility extracts TITLE, DESCRIPTION, CAPTION, and PROMPT attribute values from application Master Files into specially formatted language translation files for each language you need. Once you have the contents of these language files translated, your users can run these applications in the language they choose.
LNGPREP does two things. It extracts attribute values from a Master File into language files, and it inserts or updates the TRANS_FILE attribute in the Master File with a value identifying the application folder where the language files reside and a prefix used for naming the set of language files. If the Master File is part of a cluster, LNGPREP will extract translatable strings from every Master File referenced in the cluster, and will update each with the same TRANS_FILE value.
LNGPREP requires an input file listing the three-character codes of the languages you need.
The name of each language file starts with the prefix specified in the TRANS_FILE value, followed by a three-character language code, and the extension .lng.
For example, assume the language input file contains the French and Spanish language codes:
fre spa
If the Master File specifies:
trans_file = xlate/xl_
The language translation files would be in the xlate application folder, named:
xl_fre.lng for French
xl_spa.lng for Spanish
Each Master File must have a single base language in which the DESCRIPTION, TITLE, CAPTION, and PROMPT attributes are specified. This language need not be English.
LNGPREP extracts these attribute values into the base language file, whose language code, for historical reasons, is eng. In this case, eng does not mean English. It means whatever language the Master File is written in.
The base language file (prefixeng.lng) should never be hand edited. All other .lng files must be hand edited by translators, to translate the string values from the base language to the appropriate language.
Translating Applications into English
Since language code eng is reserved to mean base language, you cannot use it to contain English translations of an application whose base language is not English. In those cases, use any of the other English dialect language codes, such as AME, UKE, CAE, or AUE. For example, if the base language is German, specify AME in the languages file, run LNGPREP, and it will produce prefixeng.lng and prefixame.lng files, both in German. Translate the contents of prefixame.lng into English. Leave prefixeng.lng untouched.
Each language file contains a line for each attribute value from a related set of Master Files. Each attribute value has a unique index number assigned to it. For example, if the Master File contains FIELDNAME=PRODUCT_CATEGORY, TITLE='Product,Category', and that TITLE happens to be the 39th translatable attribute value, LNGPREP will produce lng files all containing the line:
39 = Product,Category
Your French translator will edit prefixfre.lng, leaving the index values unchanged while translating the string values, producing, in this case,
39 = Produit,Catégorie
At run time, when the TITLE for field PRODUCT_CATEGORY needs to be displayed, if FOCUS is configured for LANG=FRE, FOCUS looks up "Product,Category" in prefixeng.lng, finds index value 39, looks up 39 in prefixfre.lng, and displays the TITLE as "Produit,Catégorie."
The recommended best practice is to create an app directory solely for the purpose of containing .lng files, and use this appname and a common prefix value for all LNGPREP commands. In addition, put the languages fn.cfg file in this app folder. This will create one set of .lng files for all apps, minimizing the time and effort spent on translation.
How to: |
You must first create a configuration file containing the three-character language codes for each translation file you need, one language code on each line. The first invocation of LNGPREP for a given Master File adds the TRANS_FILE attribute in that and all related Master Files, creates the base language file by scanning the Master Files for supported attribute values, and creates a copy of the base language file with the correct name for each additional language. Then, a translator has to translate the values in each additional language file from the base language to the correct language for that file.
On each subsequent run, LNGPREP will check for updates to the list of related Master Files and attribute values and update the files as needed. Translators will then have to translate any attribute values added to the language files.
LNGPREP FILE n_part_name LNGAPP appname LNGPREFIX prefix LNGFILE appname/fn
where:
Specifies the n-part (app1/app2...) name of a Master File.
Specifies the literal characters that will precede the three-character language code in the names of the .lng files.
Specifies the appname and filename of a user-created .cfg file containing the list of three-character language codes, one per line. For example, the following file named langretail.cfg contains language codes for American English, French, and Japanese:
ame fre jpn
Assume the lnglist.cfg file contains the language codes fre (French) and spa (Spanish):
fre spa
Issue the following LNGPREP command:
LNGPREP FILE weather/forecast LNGAPP xlate LNGPREFIX tq_ LNGFILE xlate/lnglist
The following language files will be created:
The Master File weather/ forecast.mas will be updated with the following attribute
TRANS_FILE= xlate/tq_
Translators then have to translate the values in xlate/tq_fre.lng and xlate/tq_spa.lng.
Starting with this release, the top of the EDAPRINT log file contains all environment variables. In addition, if JDK_HOME and JAVA_HOME are both not set, the following warning message displays in EDAPRINT:
W JDK_HOME= or JAVA_HOME= required for Java Listener start
The following example shows a sample of the top portion of the EDAPRINT log file:
02/24/2016 09:57:11.753 I Workspace initialization started 02/24/2016 09:57:11.753 I EDACONF=C:\ibi\srv99\wfs 02/24/2016 09:57:11.753 I EDAHOME=C:\ibi\srv99\home 02/24/2016 09:57:11.753 I Environment Variables... 02/24/2016 09:57:11.753 I ALLUSERSPROFILE=C:\Documents and Settings\All Users 02/24/2016 09:57:11.753 I APPDATA=C:\Documents and Settings\se02703\Application Data 02/24/2016 09:57:11.753 I CLASSPATH=. 02/24/2016 09:57:11.769 I C:\Program Files\Java\jre6\lib\ext\QTJava.zip 02/24/2016 09:57:11.769 I CommonProgramFiles=C:\Program Files\Common Files 02/24/2016 09:57:11.769 I COMPUTERNAME=INFORMAT-31B4D7 02/24/2016 09:57:11.769 I ComSpec=C:\WINDOWS\system32\cmd.exe 02/24/2016 09:57:11.769 I DEFLOGDIR=C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection 02/24/2016 09:57:11.769 I EDACONF=C:\ibi\srv99\wfs 02/24/2016 09:57:11.769 I EDAEXTSEC=OFF 02/24/2016 09:57:11.769 I EDAHOME=C:\ibi\srv99\home 02/24/2016 09:57:11.769 I EDAPRINT=C:\ibi\srv99\wfs 02/24/2016 09:57:11.769 I EDASHARE=C:\ibi\srv99\wfs 02/24/2016 09:57:11.769 I EDATEMP0=C:\ibi\srv99\wfs\edatemp 02/24/2016 09:57:11.769 I FP_NO_HOST_CHECK=NO 02/24/2016 09:57:11.769 I HOMEDRIVE=H: 02/24/2016 09:57:11.769 I HOMEPATH=\
|
Information Builders |