|
|
Resource Governor provides functions that are designed to assist with application development using Custom rules. These include String Functions, Date Functions, File Functions, and Current Request Functions. These functions are described below, along with variables and syntax examples. The ACTIVATE command can be executed directly from any Business rules file.
The following table lists and describes internal functions executable as ACTIVATE routines in the rules.
Function |
Description |
---|---|
%CLOSE |
Closes a file defined with DYNAM or FILEDEF. |
%COLUMNS |
Returns column names. |
%CONCAT |
Concatenates two strings into a resultant string value. |
%COPY |
Makes a copy of a file. |
%DATE |
Creates a formatted date string value. |
%DELETE |
Deletes characters between starting and ending positions inclusively. |
%DISTINCT |
Returns if DISTINCT columns were requested. |
%DOW |
Creates a day string value from a numeric indicator. |
%DYNAM |
Uses the DYNAM command for file manipulation in MVS. |
%FILEDEF |
Uses the FILEDEF system command for reserving, deleting, or modifying files on systems other than MVS. |
%FTOA |
Converts a NUMERIC fact value to a STRING. |
%FUNCOLS |
Returns functions with column names. |
%FUNCTION |
Returns function names. |
%GET |
Reads a line from a file defined with DYNAM or FILEDEF. |
%GROUPBY |
Returns group names. |
&INSERT |
Inserts characters between starting and ending positions inclusively. |
%LEFTREL |
Returns relational columns (left side). |
%LENGTH |
Returns the length of a string value. |
%LOCATE |
Locates the existence of a string within a string value and returns the position. |
%LOWCASE |
Sets a string value to lower case. |
%MONTH |
Creates a month string value. |
%ORDERBY |
Returns ordered columns. |
%ORNOTERR |
Invalid combination of OR and NOT logic. |
%OVERLAY |
Overlays one string with another at a specified position. |
%PAD |
Pads a given string with a given character to a specified length. |
%PUT |
Writes a record to a file defined with DYNAM or FILEDEF. |
%RELATION |
Returns the relational statements. |
%RELCNT |
Returns the number of times a column name is used in a relational clause. |
%RELOPCOL |
Returns the relational column/operator combinations and determines whether they compare against a literal or a field. |
%RELOPS |
Returns relational operator AND/OR with LITERAL or FIELD. |
%RELTABS |
Returns relational conditions between tables. |
%REQUEST |
Writes the current command request being processed to a file. |
%RIGHTREL |
Returns relational columns (right side). |
%SUBSTR |
Picks out a section of a string value with starting and ending numeric positions and puts that section into a resultant string value. |
%TABLES |
Returns table names. |
%TIME |
Creates a formatted time string value. |
%TRIM |
Trims blanks from the beginning, end, or both from a string value. |
%TRUNC |
Truncates a string at the desired position. |
%UPCASE |
Sets a string value to upper case. |
Note: All function names begin with a percent (%) sign and must be entered in uppercase.
Syntax:
ACTIVATE function_name DATA parm 1 ACTIVATE function_name DATA parm 1 DATA parm 2 . . . DATA parm n
where:
Is any valid internal function name.
Parameters passed to and received from functions are identified through the DATA statement(s) as shown in the example below,
Represents the parameters being passed to function_name using the DATA statement.
Note: The ACTIVATE and DATA keywords must always be entered in uppercase.
Examples in the following function descriptions are based on this sample TABLE request:
JOIN INDEX1 IN TABLE1 TO ALL INDEX2 IN TABLE2 END TABLE FILE TABLE1 SUM AVE.COLUMN4 MAX.COLUMN5 BY COLUMN1 BY COLUMN2 WHERE COLUMN3 GT '20101231' END
Note: TABLE1 contains columns 1 and 3. TABLE2 contains columns 2,4 and 5.
|
|
The %CLOSE function closes a file defined with DYNAM or FILEDEF.
Syntax:
ACTIVATE %CLOSE DATA (input string variable)
Example:
RULE close the file IF read record OR write record THEN DBA Rules Concluded AND ACTIVATE %CLOSE AND DATA DDN 1
|
|
The %COLUMNS function returns all the column names specified in the request.
Syntax:
ACTIVATE %COLUMNS DATA Column name IS WHAT
Example:
RULE Get column names ACTIVATE %COLUMNS DATA Column name IS WHAT THEN Column names retrieved
Based on the sample request, the following attribute-value pairs are true:
Column name IS TABLE1.COLUMN1 Column name IS TABLE2.COLUMN2
|
|
The %CONCAT function concatenates two strings into a resultant string value.
Syntax:
ACTIVATE %CONCAT DATA (input/output string variable) DATA (input string variable)
Example:
RULE Concatenate strings ACTIVATE %CONCAT DATA Record DATA Extra String
|
|
The %COPY function makes a copy of a file.
Syntax:
ACTIVATE %COPY DATA (output numeric variable)
Example:
RULE Copy file ACTIVATE %COPY DATA ioresult
This function will copy a file allocated as SYSUT1 to a file allocates as SYSUT2 using %DYNAM or %FILEDEF. Using the example above, if ioresult numeric variable is not a zero then the copy failed.
|
|
The %DATE function converts month, day, and year (numeric values) to an nn/nn/nn formatted string.
Syntax:
ACTIVATE %DATE DATA (output string variable) DATA (input numeric variable) DATA (input numeric variable) DATA (input numeric variable)
Example:
RULE make a date ACTIVATE %DATE DATA Message1 DATA Message2 DATA Message3
Given the month, day, and year (numeric values), the syntax example updates Extra String with a formatted string mm/dd/yy, dd/mm/yy, or yy/mm/dd.
The order of the DATA statements can be changed if a different date format is required. For example, if the required format was dd/mm/yy, then day would be on the first DATA statement and month on the second.
|
|
The %DELETE function deletes characters between starting and ending positions inclusively.
Syntax:
ACTIVATE %DELETE DATA (input/output string variable) DATA (input string variable) DATA (input string variable)
Example:
RULE Delete characters ACTIVATE %DELETE DATA Extra String DATA Start Pos DATA End Pos
The syntax example deletes all characters in Extra String between the specified Start Pos and End Pos, inclusively.
|
|
The %DISTINCT function returns true if DISTINCT is specified in the SELECT clause; otherwise, it returns false.
Syntax:
ACTIVATE %DISTINCT DATA Distinct columns
Example:
RULE Get distinct ACTIVATE %DISTINCT DATA Distinct columns THEN Distinct determined
Based on the sample request, the SIMPLEFACT Distinct columns are false. Distinct columns would be true if the sample had been:
PRINT DST.COLUMN1 ...
|
|
The %DOW function creates a day string value from a numeric indicator. The Day of Week NUMERIC value passed into business rules is a number from 0 through 6, Sunday through Saturday.
Syntax:
ACTIVATE %DOW DATA (input numeric variable) DATA (output string variable)
Example:
RULE day name ACTIVATE %DOW DATA Day of Week DATA Extra String
|
|
The %DYNAM function is used to manipulate files in PDS deployment.
Syntax:
ACTIVATE %DYNAM DATA (input string variable) DATA (input string variable)
Example:
RULE Allocate The CNTLFILE THEN Allocate The CNTLFILE AND DDN 1 := "CNTLFILE" AND Dynam Data := "FILE CNTLFILE" AND Dynam Data 1 := "DA SYS1.MY.CNTLFILE SHR REU" AND ACTIVATE %DYNAM AND DATA Dynam Data AND DATA Dynam Data 1
|
|
The %FILEDEF function is equivalent to using the %DYNAM command and uses the FILEDEF system command for reserving, deleting, or modifying files on systems other than PDS deployment.
Syntax:
ACTIVATE %FILEDEF DATA (input string variable) DATA (input string variable)
Example:
RULE Allocate The CNTLFILE THEN Allocate The CNTLFILE AND DDN 1 := "CNTLFILE" AND Dynam Data 1 := "DISK C:\\CNTLFILE.TXT" AND ACTIVATE %FILEDEF AND DATA DDN 1 AND DATA Dynam Data 1
|
|
The %FTOA function converts a NUMERIC fact value to a STRING.
Syntax:
ACTIVATE %FTOA DATA (output string variable) DATA (input string variable) !Format String DATA (input numeric variable)
Example:
RULE convert to alpha Extra String 1 ;= "4.2" Extra Number := 3.1294 ACTIVATE %FTOA DATA Extra String DATA Extra String 1 DATA Extra Number
Format String is in the form n.d, where n represents the total number of characters (including decimal point and sign) of the output string, and d represents the number of decimal places. A value of n=0 indicates that the number of places to the left of the decimal point will be as large as necessary to hold the entire number, but no larger than needed.
|
|
The %FUNCOLS function returns all the functions with column names specified in the request.
Syntax:
ACTIVATE %FUNCOLS DATA Function column IS WHAT
Example:
RULE Get functions with columns ACTIVATE %FUNCOLS DATA Function column IS WHAT THEN Functions with columns retrieved
Based on the sample request, the following attribute-value pairs are true:
Function column IS AVG.TABLE2.COLUMN4 Function column IS MAX.TABLE2.COLUMN5
|
|
The %FUNCTION function returns all the function names specified in the request.
Syntax:
ACTIVATE %FUNCTION DATA Function name IS WHAT
Example:
RULE Get functions ACTIVATE %FUNCTION DATA Function name IS WHAT THEN Functions retrieved
Based on the sample request, the following attribute-value pairs are true:
Function name IS AVG Function name IS MAX
|
|
The %GET function reads a line from a file defined with DYNAM or FILEDEF.
Syntax:
ACTIVATE %GET DATA (input string variable) DATA (output string variable) DATA (output numeric variable)
Example:
RULE read a record ACTIVATE %GET DATA DDN 1 DATA Record DATA ioresult IF ioresult = 0 THEN read record
|
|
The %GROUPBY function returns all the column names specified in the GROUP BY clause.
Syntax:
ACTIVATE %GROUPBY DATA Group by column IS WHAT
Example:
RULE Get group bys ACTIVATE %GROUPBY DATA Group by column IS WHAT THEN Group bys retrieved
Based on the sample request, the following attribute-value pairs are true:
Group by column IS TABLE1.COLUMN1 Group by column IS TABLE2.COLUMN2
|
|
The %INSERT function inserts characters between starting and ending positions inclusively.
Syntax:
ACTIVATE %INSERT DATA (input/output string variable) DATA (input string variable) DATA (input numeric variable)
Example:
RULE Insert characters ACTIVATE %INSERT DATA Extra String DATA Extra String 1 DATA Start Pos
The syntax example inserts characters in Extra String1 into Extra String at the position specified in Start Pos.
|
|
The %LEFTREL function returns the left-hand side of the relational condition as specified in the WHERE clause.
Syntax:
ACTIVATE %LEFTREL DATA Left relational column IS WHAT
Example:
RULE Get left relational column ACTIVATE %LEFTREL DATA Left relational column IS WHAT THEN Left relational column retrieved
Based on the sample request, the following attribute-value pairs are true:
Left relational column IS TABLE1.INDEX1 Left relational column IS TABLE1.COLUMN3
|
|
The %LENGTH function returns the length of a string value.
Syntax:
ACTIVATE %LENGTH DATA (output numeric variable) DATA (input string variable)
Example:
RULE find string length ACTIVATE %LENGTH DATA Extra Number DATA Record
The output string variable contains the length of the input string variable.
|
|
The %LOCATE function locates the existence of a string within a string value and returns the position.
Syntax:
ACTIVATE %LOCATE DATA (input string variable) DATA (input string variable) DATA (output numeric variable)
Example:
RULE locate a string ACTIVATE %LOCATE Tablename 1 := "Mercedes Benz" Tablename 2 := "Benz" DATA Tablename 1 DATA Tablename 2 DATA Extra Number
The third DATA statements numeric value contains the index value of second DATA statement variable in the first DATA statement variable. If value of the second DATA statement is not found a zero will be returned in the third DATA statement.
|
|
The %LOWCASE function sets a string value to lower case.
Syntax:
ACTIVATE %LOWCASE DATA (input/output string variable)
Example:
RULE lower case Extra String := "case change" ACTIVATE %LOWCASE DATA Extra String
|
|
The %MONTH function creates a month string value from a numeric indicator 0 through 12, January through December.
Syntax:
ACTIVATE %MONTH DATA (input numeric value) DATA (output string value)
Example:
RULE month name ACTIVATE %MONTH DATA Extra Number DATA Extra String
|
|
The %ORDERBY function returns all the column names specified in the ORDER BY clause.
Syntax:
ACTIVATE %ORDERBY DATA Order by column IS WHAT
Example:
RULE Get group bys ACTIVATE %ORDERBY DATA Order by column IS WHAT THEN Order bys retrieved
Based on the sample request, the following attribute-value pairs are true:
Order by column IS TABLE1.COLUMN1 Order by column IS TABLE2.COLUMN2
|
|
The %ORNOTERR function returns true if a faulty OR/NOT condition is specified in a WHERE clause.
Syntax:
ACTIVATE %ORNOTERR DATA Bad or not condition
Example:
RULE Determine faulty relational condition ACTIVATE %ORNOTERR DATA Bad or not condition THEN Faulty relational determined
Based on the sample request, the SIMPLEFACT Bad or not condition are false. If the sample had been:
TABLE FILE TABLE PRINT COLUMN1 WHERE COLUMN9 NE 'RED' OR 'BLUE' END
Then, when COLUMN9 is RED, it is not BLUE, so the OR makes the condition true; and when COLUMN9 is BLUE, it is not RED, so the OR still makes the condition true; and when COLUMN9 is neither RED nor BLUE, the condition is still true. The effect is the same as coding PRINT COLUMN1 without a WHERE clause.
In this case, the Bad or not condition is true.
|
|
The %OVERLAY function overlays one string with another at a specified position.
Syntax:
ACTIVATE %OVERLAY DATA (input/output string variable) DATA (input string variable) DATA (input numeric variable)
Example:
RULE Overlay a string ACTIVATE %OVERLAY DATA Extra String DATA Extra String 1 DATA Start Pos
The syntax example overlays Extra String with Extra String 1 at position Start Pos for the length of Extra String 1.. The starting position is relative to 1, for example, the first position in the string that can be overlaid is position = 1.
|
|
The %PAD function Pads a given string with a given character to a specified length.
Syntax:
ACTIVATE %PAD DATA (input/output string variable) DATA (input string variable) DATA (input numeric variable) DATA (defined string variable)
Example:
RULE Pad string Extra String 1 := "x" Extra Number = 3 ACTIVATE %PAD DATA Extra String DATA Extra String 1 DATA Extra Number DATA right
The syntax example pads Extra String with the character in Extra String 1 for a total of Extra Number characters.
The forth DATA statement must be one of the system defined string variables:
left will trim characters from the left side of the string. right will trim characters from the right side of the string. both will trim characters from both the left and right sides of the string.
|
|
The %PUT function writes a record to a file defined with DYNAM or FILEDEF.
Syntax:
ACTIVATE %PUT DATA (input string variable) DATA (input string variable) DATA (output numeric variable)
Example:
RULE Write a record ACTIVATE %PUT DATA DDN 1 DATA Record DATA ioresult IF ioresult = 0 THEN write record
|
|
The %RELATION function returns all the relational statements specified in the WHERE clause.
Syntax:
ACTIVATE %RELATION DATA Relational statement IS WHAT
Example:
RULE Get relational statements ACTIVATE %RELATION DATA Relational statement IS WHAT THEN Relational statements retrieved
Based on the sample request, the following attribute-value pairs are true:
Relational statement IS TABLE1.INDEX1.EQ.TABLE2.INDEX2 Relational statement IS TABLE1.COLUMN3.GT.19951231
|
|
The %RELCNT function returns the number of times a column name is used in a relational clause.
Syntax:
ACTIVATE %RELCNT DATA (input string variable) DATA (output numeric variable)
Example:
RULE Count column use in relational tests Extra String 1 := "COLUMN3" ACTIVATE %RELCNT DATA Extra String 1 DATA Extra Number
Based on the sample request, Extra Number will equal 1.
|
|
The %RELOPCOL function returns all the relational column/operator combinations and determines whether they compare against a literal or a field as specified in the WHERE clause.
Syntax:
ACTIVATE %RELOPCOL DATA Relational IS WHAT
Example:
RULE Get relational column and operator ACTIVATE %RELOPCOL DATA Relational IS WHAT THEN Relational column and operator retrieved
Based on the sample request, the following attribute-value pairs are true:
Relational IS TABLE1.INDEX1.EQ.FIELD Relational IS TABLE1.COLUMN3.GT.LITERAL
|
|
The %RELOPS function returns all the relational operators and determines whether they compare against a literal or a field as specified in the WHERE clause.
Syntax:
ACTIVATE %RELOPS DATA Relational operator IS WHAT
Example:
RULE Get relational operator ACTIVATE %RELOPS DATA Relational operator IS WHAT THEN Relational operator retrieved
Based on the sample request, the following attribute-value pairs are true:
Relational operator IS EQ.FIELD Relational operator IS GT.LITERAL
|
|
The %RELTABS function returns all the relational conditions between tables as specified in the WHERE clause.
Syntax:
ACTIVATE %RELTABS DATA Table relations ARE WHAT
Example:
RULE Get relational table conditions ACTIVATE %RELTABS DATA Table relations ARE WHAT THEN Relational table conditions retrieved
Based on the sample request, the following attribute-value pair are true:
Relational statement IS TABLE1.EQ.TABLE2
|
|
The %REQUEST function writes the current command request being processed to a file.
Syntax:
ACTIVATE %REQUEST DATA (input string variable)
Example:
RULE Put request in a file ACTIVATE %REQUEST DATA DDN 1 !DDN 1 is a file that has been previously defined and allocated
|
|
The %RIGHTREL function returns the right-hand side of the relational condition when it references a field as specified in the WHERE clause.
Syntax:
ACTIVATE %RIGHTREL DATA Right relational column IS WHAT
Example:
RULE Where FieldName ACTIVATE %RIGHTREL DATA Right relational column IS WHAT IF NOT Right relational column IS CREATOR.TABLE2.INDEX2 THEN DBA Rules Concluded AND Rule Number := 444 AND Run := "F" AND Reason := "WhereCo" AND Message1 := "Must use WHERE with CREATOR.TABLE2.INDEX2 as right column name"
Based on the sample request, the following attribute-value pairs are true:
Right relational column IS TABLE2.INDEX2
|
|
The %SUBSTR function picks out a section of a string value with starting and ending numeric positions and puts that section into a resultant string value.
Syntax:
ACTIVATE %SUBSTR DATA (input string variable) DATA (Output string variable) DATA (Start position) DATA (End position)
|
|
The %TABLES function returns all the table names specified in the FROM clause.
Syntax:
ACTIVATE %TABLES DATA Table IS WHAT
Example:
RULE Get table names ACTIVATE %TABLES DATA Table IS WHAT IF Table IS CREATOR.TABLE1 OR Table IS CREATOR.TABLE2 THEN table name used
Based on the sample request, the following attribute-value pairs are true:
Table IS TABLE1 Table IS TABLE2
|
|
The %TIME function creates a formatted time string value of xx:yy, where xx or yy can be any character values chosen. For example, Message1 and 2 may have been initialized using %SUBSTR from Day of Week.
Syntax:
ACTIVATE %TIME DATA (output string variable) DATA (input string variable) DATA (input string variable)
Example:
RULE Make time ACTIVATE %TIME DATA Extra String DATA Message1 DATA Message2
|
|
The %TRIM function trims blanks from the beginning, end, or both from a string value.
Syntax:
ACTIVATE %TRIM DATA (input/output string variable) DATA (defined string variable)
Example:
RULE Trim blanks ACTIVATE %TRIM DATA Extra String DATA right
The syntax example trims blanks from Extra String based on the second DATA statement value.
The second DATA statement must be one of the system defined string variables:
left will trim characters from the left side of the string. right will trim characters from the right side of the string. both will trim characters from both the left and right sides of the string.
|
|
The %TRUNC function truncates a string at the desired position.
Syntax:
ACTIVATE %TRUNC DATA (input/output string variable) DATA (input numeric variable)
Example:
RULE truncate Extra String := Current Date ! Make Extra String the year Lineptr := 5 ! Ends the current date in the fifth position ACTIVATE %TRUNC DATA Extra String DATA Lineptr
|
|
The %UPCASE function sets a string value to upper case.
Syntax:
ACTIVATE %UPCASE DATA (input/output string variable)
Example:
RULE Upper case Extra String := "case change" ACTIVATE %UPCASE DATA Extra String
|
WebFOCUS |