Professional Documents
Culture Documents
V100R003
Rule Configuration Reference
Issue 01
Date 2017-07-28
All other trademarks and trade names mentioned in this document are the property of their respective
holders.
Notice
The purchased products, services and features are stipulated by the contract made between Huawei and
the customer. All or part of the products, services and features described in this document may not be
within the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements,
information, and recommendations in this document are provided "AS IS" without warranties, guarantees
or representations of any kind, either express or implied.
The information in this document is subject to change without notice. Every effort has been made in the
preparation of this document to ensure accuracy of the contents, but all statements, information, and
recommendations in this document do not constitute a warranty of any kind, express or implied.
Website: http://www.huawei.com
Email: support@huawei.com
Author
Prepared by Sheng Xing Date 2017-06-18
Reviewed by Wang Changhao, Ji Chengfei, Date 2017-06-20
Yang Lixiang, Zhong Yu,
Tang Ting
Tested by Wu Wenying Date 2017-06-20
Approved by Li Shaoshao Date 2017-07-28
Purpose
The rule configuration is involved in multiple areas on the portal, for example, dynamic
charging, accumulation, bank statement template, TC outbound, and dynamic taxing. Since
script language syntax and preset functions are involved, the rule configuration is
independently described in this document. If related tasks in the Mobile Money V100R003
Service Administrator Guide and Mobile Money V100R003 System Administrator Guide
documents involve rule configuration, see information in this document to configure rules for
the tasks.
Intended Audience
This document is intended for:
Customer
Technical support engineers
Symbol Conventions
The symbols that may be found in this document are defined as follows.
Symbol Description
Change History
Changes between document issues are cumulative. The latest document issue contains all the
changes made in earlier issues.
Issue 01 (2017-07-28)
This is the first issue of the document.
Contents
2 Syntax...............................................................................................................................................7
2.1 Operator..........................................................................................................................................................................7
2.2 Data Type......................................................................................................................................................................10
2.2.1 Keyword....................................................................................................................................................................10
2.2.2 String Special Syntax.................................................................................................................................................11
2.2.3 Datetime Special Syntax............................................................................................................................................12
2.2.4 List Special Syntax....................................................................................................................................................15
2.2.5 Map Special Syntax...................................................................................................................................................17
2.3 Expression....................................................................................................................................................................18
2.3.1 Expression Syntax.....................................................................................................................................................18
2.3.2 Scenario.....................................................................................................................................................................20
2.4 Function........................................................................................................................................................................20
3 Factor Reference...........................................................................................................................21
3.1 Action and Transaction.................................................................................................................................................21
3.2 Initiator, Credit, Debit, Requester, and Receiver..........................................................................................................22
3.3 Bank Statement.............................................................................................................................................................23
3.4 Tax Payer......................................................................................................................................................................24
4 Function Reference......................................................................................................................26
4.1 Overview......................................................................................................................................................................27
4.2 weekDay.......................................................................................................................................................................27
4.3 monthDiff.....................................................................................................................................................................27
4.4 dayDiff..........................................................................................................................................................................28
4.5 length............................................................................................................................................................................29
4.6 substr.............................................................................................................................................................................29
4.7 todate............................................................................................................................................................................30
4.8 GetAccuInContext........................................................................................................................................................30
4.9 GetAccu........................................................................................................................................................................31
4.10 hour.............................................................................................................................................................................32
5.3.1 ascii............................................................................................................................................................................51
5.3.2 chr..............................................................................................................................................................................52
5.3.3 indexof.......................................................................................................................................................................52
5.3.4 lastindexof.................................................................................................................................................................53
5.3.5 lefttrim/ltrim..............................................................................................................................................................54
5.3.6 righttrim/rtrim............................................................................................................................................................54
5.3.7 trim............................................................................................................................................................................55
5.3.8 length.........................................................................................................................................................................56
5.3.9 Like............................................................................................................................................................................56
5.3.10 lower........................................................................................................................................................................57
5.3.11 upper........................................................................................................................................................................57
5.3.12 lpad..........................................................................................................................................................................58
5.3.13 rpad..........................................................................................................................................................................59
5.3.14 split..........................................................................................................................................................................59
5.3.15 substr........................................................................................................................................................................60
5.3.16 tofloat.......................................................................................................................................................................61
5.3.17 toint..........................................................................................................................................................................61
5.3.18 tostring.....................................................................................................................................................................62
5.3.19 replace......................................................................................................................................................................63
5.3.20 translate....................................................................................................................................................................63
5.3.21 uuid..........................................................................................................................................................................64
1 Rule Description
Table 1.1 The rule application scenarios of the Charge Profile configuration item
Configuration My Functions > Operational Configuration > Detail Ops
Application Rules are used as the triggering conditions of the following scenarios
Scenario in the parameter:
Dynamic charging rule configuration
Dynamic charging rule notification configuration
Related Factors Transaction, Action, Initiator, Credit, Debit, Requester, and Receiver
Scenario The dynamic charging rule advance notification is triggered when the
Instance transaction time is earlier than October 1, 2015. The rule is configured
as follows:
if((Transaction.InitiatedTime < todate("01-10-2015
00:00:00","dd-MM-yyyy HH:mm:ss")))
return true;
else
return false;
Table 1.2 The rule application scenarios of the Tax Code configuration item
Configuration My Functions > Core Configuration > Advanced Configuration >
Item Path Tax Code
Application Rules are used as the triggering condition of the dynamic taxing rule.
Scenario
Scenario The Buy Goods tax is exempted in the region whose ID is 001. The
Instance rule is configured as follows:
if((TaxPayer.Region == "001")) return true; else return
false;
Table 1.3 The rule application scenarios of the Bank Statement Template configuration item
Configuration My Functions > Finance > Reconciliation Management >
Item Path Statement Template Management
Application Rules are used to parse the bank statement file name and fields in the
Scenario file.
Scenario The MT940 bank statement file name must be in the following format:
Instance Extras_de_cont_1111111_******.txt
The file name rule for parsing this type of file is configured as
follows:
if(BankStatement.Substring_1=="Extras" &&
BankStatement.Substring_2=="de" &&
BankStatement.Substring_3=="cont" &&
BankStatement.Substring_4=="1111111")return true; else
return false;
1.1.4 Accumulator
This topic describes the rule application scenario, related factor, available function, and
scenario instance of the Accumulator configuration item.
Table 1.4 The rule application scenarios of the Accumulator configuration item
Configuration My Functions > Operational Configuration > Accumulator
Item Path Configuration
Application Rules are used as the additional condition for the accumulator to start
Scenario accumulation.
Related Factors Transaction, Action, Initiator, Credit, Debit, Requester, and Receiver
1.1.5 TC Outbound
This topic describes the rule application scenario, related factor, available function, and
scenario instance of the TC Outbound configuration item.
Table 1.5 The rule application scenarios of the TC Outbound configuration item
Configuration My Functions > Operational Configuration > API > TC Outbound
Item Path
Application Rules are used to parse or map fields in the TC outbound message.
Scenario
Related Factors Transaction, Action, Initiator, Credit, Debit, Requester, and Receiver
Scenario Obtain the short code of the debit party. The rule is configured as
Instance follows:
return Debit.ShortCode;
Table 1.6 The rule application scenarios of the Loyalty Point Rule configuration item
Configuration My Functions > Operational Configuration > Loyalty Point
Item Path Configuration > Loyalty Point Rule
Application Rules are used as the triggering condition of the dynamic loyalty point
Scenario rule.
If this mode is used, you need only to select the suitable function, correct factor,
operator, and factor value and the system will automatically generate a script containing
the if-else statement. If there are multiple factors, the factor expressions are used as
conditions of the if statement and is calculated using &&.
Scenario: Configure a rule in simple mode so that the system returns true if the
transaction reason type is Deposit_VDF and returns false if the transaction reason type is
not Deposit_VDF, as shown in Figure 1.2.
Complex mode
If this mode is used, you can configure a rule using either of the following methods:
− Manually edit the script.
− Select a function or factor on the left. The system generates the corresponding script
in the text boxes on the right. You need to select related factors, operators, and
factor values.
Scenario: Configure a rule in complex mode so that the system returns true if the
transaction reason type is Deposit_VDF and returns false if the transaction reason
type is not Deposit_VDF. After you select a reason type on the left, the system
automatically generates an if-else statement in the text boxes on the right. You need
to manually set the reason type value, as shown in Figure 1.2.
Simple mode Configure a rule on the GUI Only simple if-else rules can be
without using the script language configured and the result must be
to edit the script. a Boolean value (true or false).
Complex mode Configure various rules. Since the script language needs to
be used to edit the script,
operators must be familiar with
the syntax of the script language.
1.3 Syntax
When configuring rules in complex mode, operators need to write scripts using the script
language.
For details, see 2Syntax.
2 Syntax
2.1 Operator
This topic describes the operators.
Table 3.2 describes the operators.
Relational operators support the comparison between dates, between numbers of different types (for
example, 100L == 100.0D), between number-type character strings (for example, "123" == "123"), and
between number-type character strings and numbers (for example, "123" == 123).
If the calculation result of the arithmetic expression is an empty value or an empty set, you can use the
keyword null or nil to check.
2.2.1 Keyword
This topic describes the data type keywords.
Table 3.3 describes the data type keywords.
String Attributes
Table 1.1 describes the string attributes.
Return value: 5
String Methods
Table 1.1 describes the string methods.
String Operator
Table 1.1 describes the string operators.
+ Combines two character strings. For Combine the characters "hello" and
example, the expression str1 + str2 " world" to return the character
indicates to return a character string string "hello world".
consisting of str1 and str2. string str = "hello";
str + " world";
Datetime Attributes
Table 1.1 describes the datetime attributes.
week Nth week in a year. Obtain the Nth week in a year in the
datetime.
datetime dateVar1;
dateVar1.week;
weekDay Day in a week. The options are as Obtain the day in a week.
follows: datetime dateVar1;
1: Monday dateVar1.weekDay;
2: Tuesday
3: Wednesday
Datetime Methods
Table 1.1 describes the datetime methods.
dayDiff(xxD Number of days between two dates. Calculate the number of days
ate) If xxDate is earlier than the other between dateVar1 and dateVar2.
date, the value is a positive number. datetime dateVar1;
datetime dateVar2;
dateVar1.dayDiff(dateVar2);
);
Definition Method
The list definition methods are as follows:
Defining a constant set: List list = [1, 2, 3]; or List list = List[1, 2, 3, 4];
Defining a variable set: List<type> list = new List<type>();
In the information, type indicates the type of the element stored in the list, for example, int, double, and
student (complex object).
List Methods
Table 1.1 describes the list methods.
remove Deletes elements from a list. Delete the first element from the
list.
List<int> list = new
List<int>();
list.add(1);
list.add(2);
list.remove(0);
get Accesses elements in a list. Access the first element in the list.
NOTE List<int> list = new
Similar to the get method, the List<int>();
list[index] method can also access list.add(1);
elements in a list. list.add(2);
list.get(0);
Or:
List<int> list = new
List<int>();
list.add(1);
list.add(2);
list[0];
filter Filters out elements meeting the Filter out elements whose age is 24
conditions from a list. The from the list.
parameter is a Boolean expression. List<student> list = new
List<student>();
list.filter(student.age ==
24);
projection Projects a parameter as a new list. Project the age of students in the list
The parameter can be any an as a new list.
expression. List<student> list = new
List<student>();
list.projection(student.age)
;
List Operators
Table 1.1 describes the list operators.
union Calculates the union of two lists. Calculate the union of the [1, 2] and
[2, 3] lists.
[1, 2] union [2, 3];
intersect Calculates the intersection of two Calculate the intersection of the [1,
lists. 2] and [2, 3] lists.
[1, 2] intersect [2, 3];
minus Calculates the difference set of two Calculate the difference set of the
lists. [1, 2] and [2, 3] lists.
[1, 2] minus [2, 3];
in/notin Checks whether the first list is Check whether 1 is included in [1,
included in the second list. If yes, 2, 3].
the method returns true. If no, the 1 in [1, 2, 3];
method returns false.
contain/notco Checks whether the first list Check whether [1, 2, 3] includes [1,
ntain includes the second list. If yes, the 2].
method returns true. If no, the [1, 2, 3] contain [1, 2]
method returns false.
exclude Checks whether the first list Check whether [1, 2] excludes [3,
excludes the second list. If yes, the 4].
method returns true. If no, the [1, 2] contain [3, 4]
method returns false.
Definition Method
The map definition methods are as follows:
Defining a constant set: Map map = [1:"hello", 2:"world"];
Defining a variable set: Map<type, type> = new Map<type, type>();
In the information, type indicates the type of the element stored in the map.
Map Methods
Table 1.1 describes the map methods.
remove Deletes elements from a map, for Delete elements whose key is 1
example, map.remove(xxx). from the map.
Map<int, string> map = new
Map<int, string>();
map.put(1, "hello world");
map.put(2, "welcome you");
map.remove(1);
2.3 Expression
This topic describes the syntax of some expressions used in rule configuration.
Each expression must have a return expression to indicate the return value of the expression.
2.3.2 Scenario
This topic describes the scenario for using an expression based on the expression syntax.
Check whether the length of the KYC field City of the transaction credit party is less than
225. If yes, the function returns true. If no, the function returns false.
if((Credit.City.length < 225))
return true;
else
return false;
2.4 Function
Functions are used to perform logic processing or calculation processing on parameters and
export the processing result.
For details about the preset functions, see 5Preset Function Reference.
3 Factor Reference
ActionType Type of an action. The system returns the action type code.
NOTE
In simple mode, the action type name is displayed on the GUI and the action
type code is displayed in the script automatically generated by the system.
In complex mode, the operator must enter the action type code in the script.
Factor Description
Factor Description
Factor Description
Factor Description
4 Function Reference
4.1 Overview
This topic describes precautions for using functions.
If a rule is configured in simple mode, the operator does not need to manually edit the
script. The operator only needs to select a suitable function and set the function
parameters. Then, the system automatically generates a script.
If the function parameter is a date constant, the operator needs to use the todate function
to convert the constant into the date format, for example, (todate("20150104","dd-MM-
yyyy HH:mm:ss").
4.2 weekDay
This topic describes the weekDay function.
Description
This function is used to calculate the week day of a date.
Parameter
oneDateTime: date for which the week day is to be calculated. This parameter can be a
constant or a factor.
Scenario
Check whether the transaction initiation date is Sunday. If yes, the function returns true. If no,
the function returns false.
if((Transaction.InitiatedTime.weekDay == 0))
return true;
else
return false;
4.3 monthDiff
This topic describes the monthDiff function.
Description
This function is used to calculate the number of months between two dates.
Parameter
sourceDateTime: compared date.
desDateTime: comparing date.
If the time specified by desDateTime is earlier than that specified by sourceDateTime, the
return result is a positive number. Otherwise, the return result is a negative number.
Scenario
Check whether the number of months between the registration date and activation date of the
transaction credit party is greater than 0. If yes, the function returns true. If no, the function
returns false.
if((Credit.ActiveDate.monthDiff(Credit.RegisteredDate) > 0))
return true;
else
return false;
4.4 dayDiff
This topic describes the dayDiff function.
Description
This function is used to calculate the number of days between two dates.
Parameter
sourceDateTime: compared date.
desDateTime: comparing date.
If the time specified by desDateTime is earlier than that specified by sourceDateTime, the
return result is a positive number. Otherwise, the return result is a negative number.
Scenario
Check whether the number of days between the registration date and activation date of the
transaction credit party is greater than 0. If yes, the function returns true. If no, the function
returns false.
if((Credit.ActiveDate.dayDiff(Credit.RegisteredDate) > 0))
return true;
else
return false;
4.5 length
This topic describes the length function.
Description
This function is used to calculate the length of a character string.
Parameter
oneString: character string whose length is to be calculated.
Scenario
Check whether the length of the KYC field City of the transaction credit party is less than
225. If yes, the function returns true. If no, the function returns false.
if((Credit.City.length < 225))
return true;
else
return false;
4.6 substr
This topic describes the substr function.
Description
This function is used to truncate a sub character string from a character string.
Parameter
oneString: character string from which the sub character string is to be truncated.
index: index of the first character of the sub character string in the character string.
length: length of the character string.
Scenario
Check whether the prefix of the transaction credit party is 0031. If yes, the function returns
true. If no, the function returns false.
if((Credit.MSISDN.substr(0, 4) == "0031"))
return true;
else
return false;
4.7 todate
This topic describes the todate function.
Description
This function is used to convert a character string into a date.
Parameter
dateString: character string to be converted into a date. The conversion format is matched
based on the character string length. If the character string length is 8, the yyyyMMdd format
is matched. If the character string length is 12, the yyyyMMddHHmm format is matched. If the
character string length is 14, the yyyyMMddHHmmss format is matched. If the character string
length is not 8, 12, or 14, null is returned.
Scenario
Convert the character string "20151112" into a date and check whether the date is earlier than
the current date.
if((todate("20151112") > todate("12-11-2015 15:36:36","dd-MM-yyyy
HH:mm:ss")))
return true;
else
return false;
4.8 GetAccuInContext
This topic describes the GetAccuInContext function.
Description
This function is used to obtain the accumulation value of the specified transaction or action
participant in the transaction or action context.
Parameter
TransCont: transaction or action context.
Role: role of the transaction or action participant whose accumulation value is to be
obtained. The options are as follows:
− 0: initiator
− 1: credit
− 2: debit
− 3: requester
− 4: recipient
AccumulatorName: name of the accumulator whose value is to be obtained.
PeriodSeq: accumulation period. The options are as follows:
− 0: current cycle
− -1: previous cycle
Scenario
Obtain the value of the cusAccu accumulator of the transaction initiator in the current bill
cycle from the transaction context and check whether the value is 1000L.
if((GetAccuInContext(Transaction.Context, 0, "cusAccu", 0) > 1000L))
return true;
else
return false;
4.9 GetAccu
This topic describes the GetAccu function.
Description
This function is used to obtain the accumulator value of the transaction or action participant.
If the accumulator does not exist or the accumulation period has been archived, the function
returns 0.
Parameter
TransCont: transaction or action context.
Role: role of the transaction or action participant whose accumulation value is to be
obtained. The options are as follows:
− 0: initiator
− 1: credit
− 2: debit
− 3: requester
− 4: recipient
AccumulatorId: ID of the accumulator whose value is to be obtained.
PeriodSeq: accumulation period. The options are as follows:
− 0: current cycle
− -1: previous cycle
Scenario
Obtain the value of the cusAccu accumulator of the transaction initiator in the current bill
cycle from the transaction context and check whether the value is 1000L.
if((GetAccu(Transaction.Context, 0, "cusAccu", 0) > 1000L))
return true;
else
return false;
4.10 hour
This topic describes the hour function.
Description
This function is used to calculate the number of hours of a date.
Parameter
oneDateTime: date for which the number of hours is to be calculated.
Scenario
Check whether the transaction initiation time is later than 8 o'clock. If yes, the function
returns true. If no, the function returns false.
if((Transaction.InitiatedTime.weekDay > 8))
return true;
else
return false;
Parameter names in the preset functions cannot contain Java keywords, for example, float, double, int,
integer, and long.
Double quotation marks in the parameter must be replaced with the English double quotation marks ("
").
5.1.1 adddays
This topic describes the adddays function.
Format
adddays(Date, Integer)
Description
This function is used to calculate the date obtained by adding several days to a date.
Parameter
Parameter 1: specified date, which is of the Date type.
Parameter 2: number of days to be added, which is of the Integer type.
Return Value
The function returns a value of the Date type.
Scenario
Obtain the date ten days later than November 12, 2015.
datetime dateVar = "20151112000000";
return adddays(dateVar, 10);
5.1.2 addhours
This topic describes the addhours function.
Format
addhours(Date, Integer)
Description
This function is used to calculate the date obtained by adding several hours to a date.
Parameter
Parameter 1: specified date, which is of the Date type.
Parameter 2: number of hours to be added, which is of the Integer type.
Return Value
The function returns a value of the Date type.
Scenario
Obtain the date ten hours later than 15 o'clock on November 12, 2015.
datetime dateVar = "20151112150000";
5.1.3 addminutes
This topic describes the addminutes function.
Format
addminutes(Date, Integer)
Description
This function is used to calculate the date obtained by adding several minutes to a date.
Parameter
Parameter 1: specified date, which is of the Date type.
Parameter 2: number of minutes to be added, which is of the Integer type.
Return Value
The function returns a value of the Date type.
Scenario
Obtain the date 50 minutes later than 23:11 on November 12, 2015.
datetime dateVar = "20151112231100";
return addminutes(dateVar, 50);
5.1.4 addmonths
This topic describes the addmonths function.
Format
addmonths(Date, Integer)
Description
This function is used to calculate the date obtained by adding several months to a date.
Parameter
Parameter 1: specified date, which is of the Date type.
Parameter 2: number of months to be added, which is of the Integer type.
Return Value
The function returns a value of the Date type.
Scenario
Obtain the date three months later than November 12, 2015.
datetime dateVar = "20151112000000";
return addmonths(dateVar, 3);
5.1.5 addyears
This topic describes the addyears function.
Format
addyears(Date, Integer)
Description
This function is used to calculate the date obtained by adding several years to a date.
Parameter
Parameter 1: specified date, which is of the Date type.
Parameter 2: number of years to be added, which is of the Integer type.
Return Value
The function returns a value of the Date type.
Scenario
Obtain the date three years later than November 12, 2015.
datetime dateVar = "20151112000000";
return addyears(dateVar, 3);
5.1.6 currentDay
This topic describes the currentDay function.
Format
currentDay(Long/Date)
Description
This function is used to obtain the integer combined by the month and date corresponding to
the specified time.
Parameter
The parameter indicates the specified time, which is of the Long or Date type.
Return Value
The function returns a value of the Long type.
Scenario
Return the integer (MMdd) combined by the month and date of November 12, 2015.
datetime dateVar = "20151112000000";
return currentDay(dateVar);
5.1.7 fmtTime
This topic describes the fmtTime function.
Format
fmtTime(Long/String/Date, String)
Description
This function is used to format the date specified by parameter 1 based on the format
specified by parameter 2.
Parameter
Parameter 1: specified time, which is of the Long, String, or Date type.
Parameter 2: specified format, which is of the String type.
Return Value
The function returns a value of the String type.
Scenario
Convert the character string "20151112000000" into a date in the yyyy-MM-dd HH:mm:ss
format.
datetime dateVar = "20151112000000";
return fmtTime(dateVar, "yyyy-MM-dd HH:mm:ss");
5.1.8 getDaysOfMonth
This topic describes the getDaysOfMonth function.
Format
getDaysOfMonth(String)
Description
This function is used to obtain the number of days in a specified month of a year.
Parameter
The parameter indicates the specified month in a year, which is of the String type and in the
yyyyMM format.
Return Value
The function returns the number of days in the specified month of a year.
Scenario
Calculate the number of days in November of 2015.
return getDaysOfMonth("201511");
Return value: 30
5.1.9 getWeekOfYear
This topic describes the getWeekOfYear function.
Format
getWeekOfYear(String/Date)
Description
This function is used to calculate the week of the current date in a year. The calculation starts
from the first complete week in the year and the date before the first complete week is
calculated as the last week plus 1.
Parameter
The parameter indicates the specified date, which is of the String or Date type.
Return Value
The function returns a value of the Integer type.
Scenario
Calculate the week of December 12, 2012 in the year 2012.
return getWeekofYear("20121212");
Return value: 50
5.1.10 lastday
This topic describes the lastday function.
Format
lastday(Date)
Description
This function is used to obtain the last day in a specified month of a year.
Parameter
The parameter indicates the specified date, which is of the Date type.
Return Value
The function returns a value of the Date type.
Scenario
Obtain the last day in November of 2015.
return lastday(201511);
5.1.11 monthsbetween
This topic describes the monthsbetween function.
Format
monthsbetween(Date, Date)
Description
This function is used to obtain the number of months between two dates. If the day is the
same in the two dates or both dates are the last day of a month, the return value is an integer.
Otherwise, the return value contains a fractional part. (Assume that a month has 31 days.)
Parameter
Parameter 1 and parameter 2 indicate two dates, which are of the Date type.
Return Value
The function returns a value of the Double type.
Scenario
Calculate the number of months between February 5, 2015 and October 5, 2015.
datetime date1 = "20150205000000";
datetime date2 = "20151005000000";
return monthsbetween(date1, date2);
5.1.12 sysdate
This topic describes the sysdate function.
Format
sysdate()
Description
This function is used to obtain the current system time.
Parameter
None
Return Value
The function returns a value of the Date type.
Scenario
Obtain the current system time.
return sysdate();
5.1.13 todate
This topic describes the todate function.
Format
todate(String)
todate(String, String)
Description
todate(String): converts a character string into a date. The conversion format is matched
based on the character string length. If the character string length is 8, the yyyyMMdd
format is matched. If the character string length is 12, the yyyyMMddHHmm format is
matched. If the character string length is 14, the yyyyMMddHHmmss format is matched.
If the character string length is not 8, 12, or 14, null is returned.
todate(String, String): converts the character string specified by parameter 1 into a date
based on the format specified by parameter 2.
Parameter
The parameter of the todate(String) function indicates the character string to be
converted into a date, which is of the String type.
Parameters of the todate(String, String) function are described as follows, both of which
are of the String type:
− Parameter 1: indicates the character string to be converted.
− Parameter 2: indicates the specified format.
Return Value
The todate(String) function returns a value of the Date type.
If the parameter is null or the parameter length is not 8, 12, or 14, the function returns null.
The todate(String, String) function returns a value of the Date type.
Scenario 1
Convert the character string "20130716" into a date.
return todate("20130716");
Scenario 2
Convert the character string "20130716" into a date in the yyyy-MM-dd format.
return todate("20130716", "yyyy-MM-dd");
5.2.1 abs
This topic describes the abs function.
Format
abs(Short/Integer/Long/Float/Double)
Description
This function is used to obtain the absolute value of the parameter value.
Parameter
The parameter indicates a number whose absolute value is to be obtained, which is of the
Short, Integer, Long, Float, or Double type.
Return Value
The function returns the absolute value of the parameter.
Scenario
Obtain the absolute value of -1.
return abs(-1);
Return value: 1
5.2.2 ceil
This topic describes the ceil function.
Format
ceil(Float/Double)
Description
This function is used to obtain the smallest integer that is not less than the specified parameter
value.
Parameter
The parameter indicates a number to be calculated, which is of the Float or Double type.
Return Value
The function returns a value of the Double type.
Scenario
Obtain the smallest integer that is not less than 2.4.
return ceil(2.4);
Return value: 3
5.2.3 doubleconvert
This topic describes the doubleconvert function.
Format
doubleconvert(Object)
Description
This function is used to convert the parameter value into a value of the Double type.
Parameter
The parameter indicates the value to be converted, which can be of any type.
Return Value
The function returns a value of the Double type.
Scenario
Convert the character string "1.11" into a value of the Double type.
return doubleconvert("1.11");
5.2.4 floatconvert
This topic describes the floatconvert function.
Format
floatconvert(Object)
Description
This function is used to convert the parameter value into a value of the Float type.
Parameter
The parameter indicates the value to be converted, which can be of any type.
Return Value
The function returns a value of the Float type.
Scenario
Convert the character string "1.11" into a value of the Float type.
return floatconvert("1.11");
5.2.5 intconvert
This topic describes the intconvert function.
Format
intconvert(Object)
Description
This function is used to convert the parameter value into a value of the Integer type.
Parameter
The parameter indicates the value to be converted, which can be of any type.
Return Value
The function returns a value of the Integer type.
Scenario
Convert the character string "1.11" into a value of the Integer type.
return intconvert("1.11");
Return value: 1
5.2.6 longconvert
This topic describes the longconvert function.
Format
longconvert(Object)
Description
This function is used to convert the parameter value into a value of the Long type.
Parameter
The parameter indicates the value to be converted, which can be of any type.
Return Value
The function returns a value of the Long type.
Scenario
Convert the character string "1.11" into a value of the Long type.
return longconvert("1.11");
Return value: 1
5.2.7 shortconvert
This topic describes the shortconvert function.
Format
shortconvert(Object)
Description
This function is used to convert the parameter value into a value of the Short type.
Parameter
The parameter indicates the value to be converted, which can be of any type.
Return Value
The function returns a value of the Short type.
Scenario
Convert the character string "1.11" into a value of the Short type.
return shortconvert("1.11");
Return value: 1
5.2.8 floor
This topic describes the floor function.
Format
floor(Float/Double)
Description
This function is used to obtain the largest integer that is of the double type and is not greater
than the specified parameter value.
Parameter
The parameter indicates a number to be calculated, which is of the Float or Double type.
Return Value
The function returns a value of the Double type.
Scenario
Obtain the largest integer that is of the Double type and is not greater than -2.4.
return floor(-2.4);
5.2.9 greatest
This topic describes the greatest function.
Format
greatest(Boolean/Short/Integer/Long/Float/Double/String/Date...)
Description
This function is used to obtain the largest parameter value in a group of parameter values.
Parameter
The parameters indicate a group of values to be calculated, which are of the Boolean, Short,
Integer, Long, Float, Double, String, or Date type.
Return Value
The function returns the largest parameter value in a group of parameter values.
Scenario
Obtain the largest parameter value in (1,2,3).
return greatest(1,2,3);
Return value: 3
5.2.10 least
This topic describes the least function.
Format
least(Boolean/Short/Integer/Long/Float/Double/String/Date...)
Description
This function is used to obtain the smallest parameter value in a group of parameter values.
Parameter
The parameters indicate a group of values to be calculated, which are of the Boolean, Short,
Integer, Long, Float, Double, String, or Date type.
Return Value
The function returns the smallest parameter value in a group of parameter values.
Scenario
Obtain the smallest parameter value in (1,2,3).
return least(1,2,3);
Return value: 1
5.2.11 isdigit
This topic describes the isdigit function.
Format
isdigit(String)
Description
This function is used to check whether a character string consists of only digits.
Parameter
The parameter is of the String type.
Return Value
The function returns a value of the Boolean type (true or false).
Scenario
Check whether "2004" consists of only digits.
return isdigit("2004");
5.2.12 isnull
This topic describes the isnull function.
Format
isnull(Object)
Description
This function is used to check whether a parameter is empty.
Parameter
The parameter is of any type.
Return Value
If the parameter is null, the function returns true. If the parameter is not null, the function
returns false.
Scenario
Check whether null is empty.
return isnull(null);
5.2.13 nvl
This topic describes the nvl function.
Format
nvl(Object, Object)
Description
This function is used to return parameter 1 if parameter 1 is not empty and return parameter 2
if parameter 1 is empty.
Parameter
The parameters are of the Boolean, Short, Integer, Long, Float, Double, String, or Date type.
Return Value
The function returns parameter 1 if parameter 1 is not empty and return parameter 2 if
parameter 1 is empty.
Scenario
Return the value of date1. If date1 is empty, the function returns the constant 0.
return nvl(date1, 0);
Return value: 0
5.2.14 round
This topic describes the round function.
Format
round(Double, Integer)
round(Short/Integer/Long/Float/Double)
Description
The round(Double, Integer) function is used to obtain the value of parameter 1 rounded
off based on the accuracy specified by parameter 2.
The round(Short/Integer/Long/Float/Double) function is used to obtain the integer after
the parameter is rounded off.
Parameter
round(Short/Integer/Long/Float/Double, Integer): Parameter 1 can be of the Short,
Integer, Long, Float, or Double type. Parameter 2 must be of the Integer type.
round(Short/Integer/Long/Float/Double): The parameter can be of the Short, Integer,
Long, Float, or Double type.
Return Value
The round(Short/Integer/Long/Float/Double, Integer) function returns the Double-type
value of parameter 1 at the specified accuracy.
The round(Short/Integer/Long/Float/Double) function is used to obtain the Long-type
integer after the parameter is rounded off.
Scenario 1
Round off 1.1111111 at the accuracy of 2.
return round(1.1111111, 2);
Scenario 2
Round off 1.1111111 to an integer.
return round(1.1111111);
Return value: 1
5.2.15 sign
This topic describes the sign function.
Format
sign(Short/Integer/Long/Float/Double)
Description
This function is used to check whether the parameter value is greater than 0, less than 0, or
equal to 0. If the parameter value is greater than 0, the function returns 1. If the parameter
value is less than 0, the function returns -1. If the parameter value is equal to 0, the function
returns 0.
Parameter
The parameter is of the Short, Integer, Long, Float, or Double type.
Return Value
If the parameter value is greater than 0, the function returns 1. If the parameter value is less
than 0, the function returns -1. If the parameter value is equal to 0, the function returns 0.
Scenario
Check whether value 2 is greater than 0.
return sign(2);
Return value: 1
5.2.16 zero
This topic describes the zero function.
Format
zero()
Description
This function is used to return 0.
Parameter
None
Return Value
The function returns 0.
Scenario
Return 0.
return zero();
Return value: 0
5.3.1 ascii
This topic describes the ascii function.
Format
ascii(String)
Description
This function is used to obtain the ASCII value of the character string initial letter.
Parameter
The parameter indicates the character string for which the initial letter ASCII value is to be
calculated, which is of the String type.
Return Value
If the parameter is null or empty, the function returns 0. Otherwise, the function returns the
corresponding ASCII value.
Scenario
Obtain the ASCII value of the initial letter of the character string "abc".
return ascii("abc");
Return value: 97
5.3.2 chr
This topic describes the chr function.
Format
chr(Short/Integer/Long)
Description
This function is used to obtain the ASCII characters equivalent to the parameter.
Parameter
The parameter indicates the ASCII value, which is of the Short, Integer, or Long type.
Return Value
The function returns a value of the Character type.
Scenario
Obtain the ASCII characters corresponding to 67.
return chr(67);
Return value: A
5.3.3 indexof
This topic describes the indexof function.
Format
indexof(String, String, Integer)
Description
This function is used to obtain the index where the specified sub character string first appears
in the character string searched from the specified index.
Parameter
Parameter 1: character string where the sub character string is searched, which is of the
String type.
Parameter 2: character string to be searched for, which is of the String type.
Parameter 3: search start position, which is of the Integer type.
Return Value
If parameter 1 is null, the function returns -1. If parameter 1 is not null, the function returns
the position where the value of parameter 2 first appears in the value of parameter 1 searched
from the position specified by parameter 3.
Scenario
Obtain the index where the character string "ar" first appears in the character string "eartar"
which is searched from the first letter.
return indexof("eartar", "ar", 0);
Return value: 1
5.3.4 lastindexof
This topic describes the lastindexof function.
Format
lastindexof(String, String, Integer)
Description
This function is used to obtain the index where the specified sub character string last appears
in the character string searched from the specified index in reverse order.
Parameter
Parameter 1: character string where the sub character string is searched, which is of the
String type.
Parameter 2: character string to be searched for, which is of the String type.
Parameter 3: search start position, which is of the Integer type.
Return Value
If parameter 1 is null, the function returns -1. If parameter 1 is not null, the function returns
the position where the value of parameter 2 last appears in the value of parameter 1 searched
from the position specified by parameter 3 in reverse order.
Scenario
Obtain the index where the character string "ar" last appears in the character string "eartar"
which is searched from the last letter in reverse order.
return lastindexof("eartar", "ar", 5);
Return value: 4
5.3.5 lefttrim/ltrim
This topic describes the lefttrim/ltrim function.
Format
lefttrim(String) or ltrim(String)
Description
This function is used to remove space characters from the left of a character string.
Parameter
The parameter specifies the character string from whose left space characters are to be
removed, which is of the String type.
Return Value
The function returns a value of the String type.
Scenario
Remove the space character from the left of the character string " hello".
return lefttrim(" hello");
Or
return ltrim(" hello");
5.3.6 righttrim/rtrim
This topic describes the righttrim/rtrim function.
Format
righttrim(String) or rtrim(String)
Description
This function is used to remove space characters from the right of a character string.
Parameter
The parameter specifies the character string from whose right space characters are to be
removed, which is of the String type.
Return Value
The function returns a value of the String type.
Scenario
Remove space characters from the right of the character string "math ".
return righttrim("math ");
Or
return rtrim("math ");
5.3.7 trim
This topic describes the trim function.
Format
trim(String)
Description
This function is used to remove space characters from both sides of a character string.
Parameter
The parameter specifies the character string from whose two sides space characters are to be
removed, which is of the String type.
Return Value
The function returns a value of the String type.
Scenario
Remove space characters from both sides of the character string " hello ".
return trim(" hello ");
5.3.8 length
This topic describes the length function.
Format
length(String)
Description
This function is used to calculate the length of a character string.
Parameter
The parameter specifies the character string whose length is to be calculated, which is of the
String type.
Return Value
The function returns the length of the character string specified by the parameter.
Scenario
Calculate the length of the character string "math".
return length("math");
Return value: 4
5.3.9 Like
This topic describes the Like function.
Format
Like(String, String)
Description
This function is used to check whether parameter 1 matches the expression of parameter 2.
Parameter
Parameter 1: primary character string to be matched.
Parameter 2: format to be matched. The wildcard asterisk (*) matches any number of
characters. The wildcard question mark (?) matches only one character.
Return Value
If parameter 1 or parameter 2 is empty, the function returns false. If both parameters are not
empty, the function returns true if parameter 1 matches the expression of parameter 2 and
returns false if parameter 1 does not match the expression of parameter 2.
Scenario
Check whether the character string "math" matches the expression "?a*".
return Like("math", "?a*");
5.3.10 lower
This topic describes the lower function.
Format
lower(String)
Description
This function is used to convert all uppercase letters in a character string into lowercase
letters.
Parameter
The parameter specifies the character string to be converted, which is of the String type.
Return Value
The function returns a value of the String type.
Scenario
Convert the uppercase letter in the character string "aBc" into a lowercase letter.
return lower("aBc");
5.3.11 upper
This topic describes the upper function.
Format
upper(String)
Description
This function is used to convert all lowercase letters in a character string into uppercase
letters.
Parameter
The parameter specifies the character string to be converted, which is of the String type.
Return Value
The function returns a value of the String type.
Scenario
Convert all lowercase letters in the character string "aBc" into uppercase letters.
return upper("aBc");
5.3.12 lpad
This topic describes the lpad function.
Format
lpad(String, Integer, String)
Description
This function is used to add the character string specified by parameter 3 to the left of the
character string specified by parameter 1 to make the character string length reach the length
specified by parameter 2.
Parameter
Parameter 1: character string to whose left another character string is to be added, which
is of the String type.
Parameter 2: length of the character string after adding, which is of the Integer type.
Parameter 3: character string used for adding, which is of the String type.
Return Value
The function returns a value of the String type.
Scenario
Add the character string "-" to the left of the character string "math" to make the character
string length reach 10.
return lpad("math", 10, "-");
5.3.13 rpad
This topic describes the rpad function.
Format
rpad(String, Integer, String)
Description
This function is used to add the character string specified by parameter 3 to the right of the
character string specified by parameter 1 to make the character string length reach the length
specified by parameter 2.
Parameter
Parameter 1: character string to whose right another character string is to be added,
which is of the String type.
Parameter 2: length of the character string after adding, which is of the Integer type.
Parameter 3: character string used for adding, which is of the String type.
Return Value
The function returns a value of the String type.
Scenario
Add the character string "-" to the right of the character string "math" to make the character
string length reach 10.
return rpad("math", 10, "-");
5.3.14 split
This topic describes the split function.
Format
split(String,String)
Description
This function is used to split a specified character string.
Parameter
Parameter 1: character string to be split, which is of the String type.
Parameter 2: separator used for splitting, which is of the String type.
Return Value
If parameter 1 is null, the function returns an empty list. If parameter is not null, the function
returns a list of parameter 1 split by parameter 2.
Scenario
Split the character string "hello,world" into two character strings "hello" and "world". The
separator is a comma (,).
return split("hello,world", ",");
5.3.15 substr
This topic describes the substr function.
Format
substr(String, Integer, Integer)
Description
This function is used to truncate a sub character string from the character string specified by
parameter 1 from the position (included) specified by parameter 2 to the position (excluded)
specified by parameter 3.
Parameter
Parameter 1: character string where the sub character string is truncated, which is of the
String type.
Parameter 2: truncation start position (included), which is of the Integer type.
Parameter 3: truncation end position (excluded), which is of the Integer type.
Return Value
The function returns a value of the String type.
Scenario
Truncate the sub character string "lc" from the character string "welcome".
return substr("welcome", 2, 4);
5.3.16 tofloat
This topic describes the tofloat function.
Format
tofloat(String)
Description
This function is used to convert a character string into a value of the Float type.
Parameter
The parameter specifies the character string to be converted, which is of the String type.
Return Value
The function returns a value of the Float type.
Scenario
Convert the character string "11.1" into a value of the Float type.
return tofloat("11.1");
5.3.17 toint
This topic describes the toint function.
Format
toint(String)
Description
This function is used to convert a character string into an integer.
Parameter
The parameter specifies the character string to be converted, which is of the String type.
Return Value
The function returns a value of the Integer type.
Scenario
Convert the character string "11" into an integer.
return toint("11");
Return value: 11
5.3.18 tostring
This topic describes the tostring function.
Format
tostring(Character/Boolean/Short/Integer/Long/Float/Double/String/Date)
tostring(Date/Long, String)
Description
The tostring(Character/Boolean/Short/Integer/Long/Float/Double/String/Date) function
is used to convert the parameter into a character string.
The tostring(Date/Long, String) function is used to convert the date specified by
parameter 1 into a character string based on the format specified by parameter 2.
Parameter
tostring(Character/Boolean/Short/Integer/Long/Float/Double/String/Date): The
parameter specifies the character string to be converted, which is of the Character,
Boolean, Short, Integer, Long, Float, Double, String, or Date type.
tostring(Date/Long, String): Parameter 1 is of the Date or Long type. Parameter 2 is of
the String type.
− Parameter 1: content to be converted into a character string, which is of the Date or
Long type.
− Parameter 2: specified format, which is of the String type.
Return Value
The tostring(Character/Boolean/Short/Integer/Long/Float/Double/String/Date) function
returns a value of the String type.
If the parameter is null, the function returns null.
The tostring(Date/Long, String) function returns a value of the String type.
If parameter 1 is null, the function returns null.
Scenario 1
Convert date 20151112000000 into a character string.
Scenario 2
Convert date 20151112000000 into a character string in the yyyy-MM-dd HH:mm:ss format.
datetime dateVar = "20151112000000";
return tostring(dateVar, "yyyy-MM-dd HH:mm:ss");
5.3.19 replace
This topic describes the replace function.
Format
replace(String, String, String)
Description
This function is used to replace the value of parameter 2 in parameter 1 with the value of
parameter 3.
Parameter
All the three parameters are of the String type and are described as follows:
Parameter 1: primary character string where the character string to be replaced is located.
Parameter 2: character string to be replaced.
Parameter 3: character string used for replacement.
Return Value
The function returns a value of the String type.
Scenario
Replace the character string "ab" in the character string "abdeabef" with the character string
"xx".
return replace("abdeabef", "ab", "xx");
5.3.20 translate
This topic describes the translate function.
Format
translate(String,String,String)
Description
This function is used to replace parameter 2 in parameter 1 with parameter 3 and return the
parameter 1 after replacement.
The translate function is a superset of the replace function. If the replaced character string is shorter than
the character string used for replacement, the translate function obtains only the first N (number of
characters in the replaced character string) characters of the character string used for replacement. For
example, the return value of Translate('abcdefghij','abc','12356') is '123defghij' while the return value of
replace('abcdefghij','abc','12356') is '12356defghij'.
Parameter
All the three parameters are of the String type and are described as follows:
Parameter 1: primary character string where the character string to be replaced is located.
Parameter 2: character string to be replaced.
Parameter 3: character string used for replacement.
Return Value
The function returns a value of the String type.
Scenario
Replace the character string "abc" in the character string "abcdefghij" with the character string
"123".
return translate("abcdefghij","abc","123");
5.3.21 uuid
This topic describes the uuid function.
Format
uuid()
Description
This function is used to generate a random 32-bit character string.
Parameter
None
Return Value
The function returns a random 32-bit character string.
Scenario
Generate a random 32-bit character string.
return uuid();