You are on page 1of 72

Mobile Money

V100R003
Rule Configuration Reference

Issue 01

Date 2017-07-28

HUAWEI TECHNOLOGIES CO., LTD.


Copyright © Huawei Technologies Co., Ltd. 2017. All rights reserved.
No part of this document may be reproduced or transmitted in any form or by any means without prior
written consent of Huawei Technologies Co., Ltd.

Trademarks and Permissions


and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.

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.

Huawei Technologies Co., Ltd.


Address: Huawei Industrial Base
Bantian, Longgang
Shenzhen 518129
People's Republic of China

Website: http://www.huawei.com

Email: support@huawei.com

Issue 01 (2017-07-28) Huawei Proprietary and Confidential i


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference About This Document

About This Document

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential ii


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference About This Document

Symbol Description

Indicates an imminently hazardous situation


which, if not avoided, will result in death or
serious injury.
Indicates a potentially hazardous situation
which, if not avoided, could result in death
or serious injury.
Indicates a potentially hazardous situation
which, if not avoided, may result in minor or
moderate injury.
Indicates a potentially hazardous situation
which, if not avoided, could result in
equipment damage, data loss, performance
deterioration, or unanticipated results.
NOTICE is used to address practices not
related to personal injury.
Calls attention to important information,
best practices and tips.
NOTE is used to address information not
related to personal injury, equipment
damage, and environment deterioration.

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential iii


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference Contents

Contents

About This Document....................................................................................................................ii


1 Rule Description............................................................................................................................1
1.1 Application Scenario......................................................................................................................................................1
1.1.1 Charge Profile..............................................................................................................................................................1
1.1.2 Tax Code......................................................................................................................................................................2
1.1.3 Bank Statement Template............................................................................................................................................2
1.1.4 Accumulator................................................................................................................................................................3
1.1.5 TC Outbound...............................................................................................................................................................3
1.1.6 Loyalty Point Rule.......................................................................................................................................................4
1.2 Editing Modes................................................................................................................................................................4
1.3 Syntax.............................................................................................................................................................................6

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

Issue 01 (2017-07-28) Huawei Proprietary and Confidential iv


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference Contents

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 Preset Function Reference.........................................................................................................33


5.1 Daily Processing Functions..........................................................................................................................................33
5.1.1 adddays......................................................................................................................................................................33
5.1.2 addhours....................................................................................................................................................................34
5.1.3 addminutes.................................................................................................................................................................35
5.1.4 addmonths..................................................................................................................................................................35
5.1.5 addyears.....................................................................................................................................................................36
5.1.6 currentDay.................................................................................................................................................................36
5.1.7 fmtTime.....................................................................................................................................................................37
5.1.8 getDaysOfMonth.......................................................................................................................................................38
5.1.9 getWeekOfYear..........................................................................................................................................................38
5.1.10 lastday......................................................................................................................................................................39
5.1.11 monthsbetween........................................................................................................................................................39
5.1.12 sysdate.....................................................................................................................................................................40
5.1.13 todate.......................................................................................................................................................................41
5.2 Value Processing Functions..........................................................................................................................................42
5.2.1 abs..............................................................................................................................................................................42
5.2.2 ceil.............................................................................................................................................................................42
5.2.3 doubleconvert............................................................................................................................................................43
5.2.4 floatconvert................................................................................................................................................................43
5.2.5 intconvert...................................................................................................................................................................44
5.2.6 longconvert................................................................................................................................................................45
5.2.7 shortconvert...............................................................................................................................................................45
5.2.8 floor...........................................................................................................................................................................46
5.2.9 greatest.......................................................................................................................................................................46
5.2.10 least..........................................................................................................................................................................47
5.2.11 isdigit.......................................................................................................................................................................48
5.2.12 isnull........................................................................................................................................................................48
5.2.13 nvl............................................................................................................................................................................49
5.2.14 round........................................................................................................................................................................49
5.2.15 sign..........................................................................................................................................................................50
5.2.16 zero..........................................................................................................................................................................51
5.3 Character String Processing Functions.........................................................................................................................51

Issue 01 (2017-07-28) Huawei Proprietary and Confidential v


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference Contents

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

Issue 01 (2017-07-28) Huawei Proprietary and Confidential vi


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 1 Rule Description

1 Rule Description

About This Chapter


Rules can be used in many scenarios (for example, the dynamic charging) for parsing fields,
calculating field values, or triggering the scenarios. Before configuring rules, you need to
understand basic concepts related to rules, which helps you configure rules correctly.
1.1 Application Scenario
This topic describes application scenarios of rules.
1.2 Editing Modes
The Mobile Money system provides the simple mode and complex mode for modifying rules
on the GUI. This topic describes the application scopes and use examples of the two modes.
1.3 Syntax
When configuring rules in complex mode, operators need to write scripts using the script
language.

1.1 Application Scenario


This topic describes application scenarios of rules.
1.1.1Charge Profile through 1.1.6Loyalty Point Rule describe the application scenarios of
rules in the current version, scenario factors, and functions used in the scenarios. For details
about the factors, see 3Factor Reference. For details about the functions, see 4Function
Reference.

1.1.1 Charge Profile


This topic describes the rule application scenario, related factor, available function, and
scenario instance of the Charge Profile configuration item.

Table 1.1 The rule application scenarios of the Charge Profile configuration item
Configuration My Functions > Operational Configuration > Detail Ops

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 1


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 1 Rule Description

Item Path Configuration > Charge Profile

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

Available weekDay, monthDiff, dayDiff, length, substr, todate,


Functions GetAccuInContext, and hour

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;

1.1.2 Tax Code


This topic describes the rule application scenario, related factor, available function, and
scenario instance of the Tax Code configuration item.

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

Related Factors Transaction, Action, and TaxPayer

Available weekDay, monthDiff, dayDiff, length, substr, todate, and hour


Functions

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;

1.1.3 Bank Statement Template


This topic describes the rule application scenario, related factor, available function, and
scenario instance of the Bank Statement Template configuration item.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 2


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 1 Rule Description

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.

Related Factors BankStatement

Available weekDay, monthDiff, dayDiff, length, substr, todate, and hour


Functions

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

Available weekDay, monthDiff, dayDiff, length, substr, todate, and hour


Functions

Scenario For the accumulator Amount_CustInitiator_Oneoff, the trust level of


Instance the transaction initiator must be 11.
The rule is configured as follows:
if((Initiator.TrustLevel == 11)) return true; else
return false;

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 3


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 1 Rule Description

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

Available weekDay, monthDiff, dayDiff, length, substr, todate, GetAccu, and


Functions hour

Scenario Obtain the short code of the debit party. The rule is configured as
Instance follows:
return Debit.ShortCode;

1.1.6 Loyalty Point Rule


This topic describes the rule application scenario, related factor, available function, and
scenario instance of the Loyalty Point Rule configuration item.

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.

Related Factors Transaction, Action, Initiator, Credit, Debit, and Requester.

Available weekDay, monthDiff, dayDiff, length, substr, todate, and hour.


Functions

Scenario If a customer's activation date is earlier than 2015-10-01, the system


Instance will trigger the loyalty point rule. The rule is configured as follows:
if((Credit.ActiveDate < todate("01-10-2015
00:00:00","dd-MM-yyyy HH:mm:ss")))
return true;
else
return false;

1.2 Editing Modes


The Mobile Money system provides the simple mode and complex mode for modifying rules
on the GUI. This topic describes the application scopes and use examples of the two modes.
 Simple mode

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 4


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 1 Rule Description

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.

Figure 1.2 Configuring a rule in simple mode

 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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 5


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 1 Rule Description

Figure 1.3 Configuring a rule in complex mode

Table 3.1 Advantages and disadvantages of the two modes


Mode Advantage Disadvantage

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 6


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

2 Syntax

About This Chapter


When configuring rules in complex mode, operators need to write scripts using the script
language. This section describes the rule script syntax.
2.1 Operator
This topic describes the operators.
2.2 Data Type
This topic describes how to use the data types supported by the rule script.
2.3 Expression
This topic describes the syntax of some expressions used in rule configuration.
2.4 Function
Functions are used to perform logic processing or calculation processing on parameters and
export the processing result.

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 7


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Table 3.2 Operators


Operator Type Description

% Get remainder Gets the remainder by dividing an integer with


another integer.
For example, the remainder obtained by dividing 5
by 2 is 1.
* Multiply Multiplies two numbers.
+ Add Adds two numbers or character strings.
++ Increase Increases the number by 1 automatically.
automatically
- Subtract Subtracts a number from another number.
-- Decrease Decreases the number by 1 automatically.
automatically
/ Divide Divides a number by another number.
?: Ternary operator This operator can simply replace the if-else
statement. The content before ? is an expression,
the content between ? and : is the code executed
when the expression is true, and the content after :
is the code executed when the expression is false.
Take a?b:c as an example. If the value of a is true,
the value of b is returned. If the value of a is false,
the value of c is returned.
> Greater than Compares numbers with numbers, character strings
with character strings, and dates with dates.
Use the expression a > b as an example. If a is
greater than b, the result is true. If a is less than or
equal to b, the result is false. If a or b is null, the
result is false.
>= Greater than or Compares numbers with numbers, character strings
equal to with character strings, and dates with dates.
Use the expression a >= b as an example. If a is
greater than or equal to b, the result is true. If a is
less than b, the result is false. If a or b is null, the
result is false.
< Less than Compares numbers with numbers, character strings
with character strings, and dates with dates.
Use the expression a < b as an example. If a is less
than b, the result is true. If a is greater than or
equal to b, the result is false. If a or b is null, the
result is false.
<= Less than or Compares numbers with numbers, character strings
equal to with character strings, and dates with dates.
Use the expression a <= b as an example. If a is
less than or equal to b, the result is true. If a is

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 8


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Operator Type Description

greater than b, the result is false. If a or b is null,


the result is false.
== Equal to Compares numbers with numbers, character strings
with character strings, and dates with dates.
Use the expression a == b as an example. If a is
equal to b, the result is true. If a is greater than or
less than b, the result is false. If a or b is null, the
result is false.
!= Unequal to Compares numbers with numbers, character strings
with character strings, and dates with dates.
Use the expression a != b as an example. If a is
unequal to b, the result is true. If a is equal to b, the
result is false. If a or b is null, the result is false.
= Assign value Assigns the value of the right operand to the left
operand. For example, the expression a = b means
that the value of b is assigned to a.
*= Multiply and Multiplies the left operand with the right operand
assign value and assigns the result to the left operand. For
example, the expression a *= b is equivalent to the
expression a = a*b.
/= Divide and Divides the left operand with the right operand and
assign value assigns the result to the left operand. For example,
the expression a /= b is equivalent to the expression
a = a/b.
%= Get remainder Gets the remainder of the left and right operands
and assign value and assigns the result to the left operand. For
example, the expression a %= b is equivalent to the
expression a = a%b.
+= Add and assign Adds the left and right operands and assigns the
value result to the left operand. For example, the
expression a += b is equivalent to the expression a
= a + b.
-= Subtract and Subtracts the right operand from the left operand
assign value and assigns the result to the left operand. For
example, the expression a -= b is equivalent to the
expression a = a - b.
and or && And Performs the logic And operation on two Boolean
values. The result is true only when both operands
are true. If one of the operands is false, the result is
false.
or or || Or Performs the logic Or operation on two Boolean
values. The result is true when one of the two
operands is true. If result is false only when both
operands are false.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 9


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Operator Type Description

Not or ! Not Performs the logic Not operation on a Boolean


value. If the operand is true, the result is false. If
the operand is false, the result is true.
& Bitwise And Performs the bitwise And operation on two
numbers.
| Bitwise Or Performs the bitwise Or operation on two numbers.
^ Bitwise Performs the bitwise Exclusive Or operation on
Exclusive Or two numbers.
. Attribute access Performs the attribute access operation.
in In list Checks whether the left operand is in the list of the
right operand. If yes, the result is true. If no, the
result is false.
contain Include Checks whether the left operand includes the right
operand. If yes, the result is true. If no, the result is
false.

2.2 Data Type


This topic describes how to use the data types supported by the rule script.

2.2.1 Keyword
This topic describes the data type keywords.
Table 3.3 describes the data type keywords.

Table 3.3 Data type keywords


Type Keyword Scenario Example

Character char char chVar = 'c';


Character string string string strVar = "hello
world";
Integer int int intVar = 1;
Long integer long long longVar = 2L;
Floating float float floatVar = 3.1F;
Double floating double double doubleVar = 4.2D;
Boolean boolean boolean boolVar = true;
Date datetime datetime dateVar =
"20130426160232";

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 10


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Type Keyword Scenario Example

Set List List listVar = [1, 2, 3];


Map Map Map mapVar = [1:"hello
world", 2:"welcome you"];

2.2.2 String Special Syntax


This topic describes special syntax of the string data type, including the string attribute,
method, and operator.

String Attributes
Table 1.1 describes the string attributes.

Table 1.1 String attributes


Attribute Description Example

length Length of a character string. Obtain the length of the character


string "hello".
string str = "hello";
return str.length;

Return value: 5

String Methods
Table 1.1 describes the string methods.

Table 1.1 String methods


Method Description Example

substr(index, Truncates a specified length of Truncate the sub character string


length) characters starting from the "el" from the character string
specified position. The value of "hello".
index starts from 0. string str = "hello";
str.substr(1, 2);

Return value: "el"


has(substring Checks whether a character string Check whether the character string
) includes a specified sub character "hello" includes the sub character
string. The return value is a Boolean string "he".
value (true or false). string str = "hello";
str.has("he");

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 11


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Method Description Example

Return value: true


matches(subs Checks whether a character string Check whether the character string
tring) includes another character string "hello" matches the character string
containing the wildcard percent sign "hell%".
(%) or underline (_). The percent string str = "hello";
sign (%) indicates one or more str.matches("hell%");
characters and the underline (_)
indicates only one character. The
return value is a Boolean value (true Return value: true
or false).

String Operator
Table 1.1 describes the string operators.

Table 1.1 String operators


Operator Description Example

+ 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";

Return value: "hello world"


~= Matches the regular expression. Check whether the character string
"hello" matches the regular
expression "he.+".
string str = "hello";
str ~= "he.+";

Return value: true


like Compares two character strings. Compare the character string "hello"
The expression is in the left like with the character string "he%".
pattern format. The value of string str = "hello";
pattern supports the wildcard str like "he%";
percent sign (%) and underline (_).
The percent sign (%) indicates one
or more characters and the Return value: true
underline (_) indicates only one
character.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 12


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

2.2.3 Datetime Special Syntax


This topic describes special syntax of the datetime data type, including the datetime attributes
and methods.

Datetime Attributes
Table 1.1 describes the datetime attributes.

Table 1.1 Datetime attributes


Attribute Description Example

year Year in the datetime. Obtain the year in the datetime.


datetime dateVar1;
dateVar1.year;

month Month in the datetime. Obtain the month in the datetime.


datetime dateVar1;
dateVar1.month;

day Day in the datetime. Obtain the day in the datetime:


datetime dateVar1;
dateVar1.day;

hour Hour in the datetime. Obtain the hour in the datetime.


datetime dateVar1;
dateVar1.hour;

minute Minute in the datetime. Obtain the minute in the datetime.


datetime dateVar1;
dateVar1.minute;

second Second in the datetime. Obtain the second in the datetime.


datetime dateVar1;
dateVar1.second;

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

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 13


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Attribute Description Example


 4: Thursday
 5: Friday
 6: Saturday
 0: Sunday

Datetime Methods
Table 1.1 describes the datetime methods.

Table 1.1 Datetime methods


Method Description Example

yearDiff(xxD Number of years between two Calculate the number of years


ate) dates. If xxDate is earlier than the between dateVar1 and dateVar2.
other date, the value is a positive datetime dateVar1;
number. datetime dateVar2;
dateVar1.yearDiff(dateVar2);

monthDiff(x Number of months between two Calculate the number of months


xDate) dates. If xxDate is earlier than the between dateVar1 and dateVar2.
other date, the value is a positive datetime dateVar1;
number. datetime dateVar2;
dateVar1.monthDiff(dateVar2)
;

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);

hourDiff(xx Number of hours between two Calculate the number of hours


Date) dates. If xxDate is earlier than the between dateVar1 and dateVar2.
other date, the value is a positive datetime dateVar1;
number. datetime dateVar2;
dateVar1.hourDiff(dateVar2);

minuteDiff(x Number of minutes between two Calculate the number of minutes


xDate) dates. If xxDate is earlier than the between dateVar1 and dateVar2.
other date, the value is a positive datetime dateVar1;
number. datetime dateVar2;
dateVar1.minuteDiff(dateVar2

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 14


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Method Description Example

);

secondDiff(x Number of seconds between two Calculate the number of seconds


xDate) dates. If xxDate is earlier than the between dateVar1 and dateVar2.
other date, the value is a positive datetime dateVar1;
number. datetime dateVar2;
dateVar1.secondDiff(dateVar2
);

weekDiff(xx Number of weeks between two Calculate the number of weeks


Date) dates. If xxDate is earlier than the between dateVar1 and dateVar2.
other date, the value is a positive datetime dateVar1;
number. datetime dateVar2;
dateVar1.weekDiff(dateVar2);

2.2.4 List Special Syntax


This topic describes special syntax of the list data type, including the list definition, method,
and operator.

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.

Table 1.1 List methods


Method Description Example

add Adds elements to a list. Add two elements in a newly


defined list:
List<int> list = new
List<int>();
list.add(1);
list.add(2);

remove Deletes elements from a list. Delete the first element from the

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 15


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Method Description Example

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)
;

distinct Removes duplicate elements from a Remove duplicate elements from


list. The method can contain the list by age.
multiple parameters that can be any List<student> list = new
expressions. List<student>();
list.distinct(student.age);

size Calculates the size of a list. Calculate the size of a list.


List<int> list = new
List<int>();
list.size();

isEmpty Checks whether a list is empty. If Check whether a list is empty.


yes, the method returns true. If no, List<int> list = new
the method returns false. List<int>();
list.isEmpty();

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 16


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

List Operators
Table 1.1 describes the list operators.

Table 1.1 List operators


Operator Description Example

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.

2.2.5 Map Special Syntax


This topic describes special syntax of the map data type, including the map definition,
method, and operator.

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 17


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Table 1.1 Map methods


Method Description Example

put Adds elements to a map. Add two pairs of elements in a


newly defined map.
Map<int, string> map = new
Map<int, string>();
map.put(1, "hello world");
map.put(2, "welcome you");

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);

get Accesses elements in a map, for Access elements whose key is 2 in


example, map.get(xxx). The the map.
map[xxx] format is also supported. Map<int, string> map = new
NOTE Map<int, string>();
Similar to the get method, the map.put(1, "hello world");
map[index] method can also access map.put(2, "welcome you");
elements in a map. map.get(2);

size Calculates the size of a map. Calculate the size of a map.


Map<int, string> map = new
Map<int, string>();
map.put(1, "hello world");
map.put(2, "welcome you");
map.size();

isEmpty Checks whether a map is empty. If Check whether a map is empty.


yes, the method returns true. If no, Map<int, string> map = new
the method returns false. Map<int, string>();
map.isEmpty();

2.3 Expression
This topic describes the syntax of some expressions used in rule configuration.

2.3.1 Expression Syntax


This topic describes the expression syntax.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 18


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Each expression must have a return expression to indicate the return value of the expression.

Table 1.2 Expressions


Expressi Format Description
on Type

if-else if(logic expression) Condition expression. Code of the if


script statement expression is executed only when the if
else expression is true. Otherwise, code of the
script statement else expression is executed.
NOTE
Each branch of the if expression must have a
return expression.

switch switch(xxx) Multi-branch condition expression. The


{ code jumps to the corresponding case
case xxx: branch based on xxx and the expression
script statement; under this branch is executed. The code
break; jumps out of the branch at the break
case xxx: expression. If no matched case branch
script statement; exists, the expression under the default
break; branch is executed.
default:
NOTE
script statement;
Similar to the if expression, each branch of
break; the switch expression must have a return
} expression or a break expression. Otherwise,
the expression execution result contains
errors.

for for(initialization Loop expression. The expression


statement; loop condition; executes the loop body repeatedly until
loop increase [or the loop condition is false.
decrease])
{
loop body
}

while while(loop condition) Loop expression. The expression


{ executes the loop body if the loop
loop body condition is met and exits the loop body
} if the loop condition is not met.

until until(loop exit condition) Loop expression. The expression exits


{ the loop body if the loop exit condition is
loop body met and executes the loop body if the
} loop exit condition is not met.

do while do Loop expression. The expression


{ executes the loop body and then checks
loop body the loop condition. If the loop condition
}while(loop condition); is met, the expression continues
executing the loop body. If the loop

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 19


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 2 Syntax

Expressi Format Description


on Type

condition is not met, the expression exits


the loop body.
do until do Loop expression. The expression
{ executes the loop body and then checks
loop body the loop exit condition. If the loop exit
}until(loop exit condition is met, the expression exits the
condition); loop body. If the loop exit condition is
not met, the expression continues
executing the loop body.
case/whe case Multi-branch condition expression. The
n when condition1 system checks conditions of the when
script expressions one by one. If the condition
statement; of a when expression is met, the when
when condition2 expression is executed.
script
statement;
...
end;

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 20


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 3 Factor Reference

3 Factor Reference

About This Chapter


This topic describes factors in various scenarios.
3.1 Action and Transaction
This topic describes action and transaction factors.
3.2 Initiator, Credit, Debit, Requester, and Receiver
This topic describes initiator, credit, debit, requester, and receiver factors.
3.3 Bank Statement
This topic describes bank statement factors.
3.4 Tax Payer
This topic describes tax payer factors.

3.1 Action and Transaction


This topic describes action and transaction factors.
Table 1.3 describes action and transaction factors.

Table 1.3 Action and transaction factors


Factor Description

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.

InitiatedTime Time when a transaction or an action is initiated.


Service Service corresponding to a transaction or an action.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 21


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 3 Factor Reference

Factor Description

ReasonType Reason type corresponding to a transaction or an action.


NOTE
 In simple mode, the reason type name is displayed on the GUI and the action
type ID is displayed in the script automatically generated by the system.
 In complex mode, the operator must enter the reason type ID in the script.

Context Transaction context. This field is available only in complex mode.


Amount Transaction amount, in the minimum currency unit.
Currency Currency type of a transaction amount.
Channel Channel through which a transaction is initiated.
TransactionTy Type of a transaction. The system returns the transaction type ID.
pe NOTE
 In simple mode, the transaction type name is displayed on the GUI and the
transaction type ID is displayed in the script automatically generated by the
system.
 In complex mode, the operator must enter the transaction type ID in the script.

BillReference Bill reference number in the pay bill transaction.


Number
InvoiceNumb Invoice number in the pay bill transaction.
er
RechargeNum Recharge number in the buy airtime transaction.
ber
OrderId ID of a transaction.

3.2 Initiator, Credit, Debit, Requester, and Receiver


This topic describes initiator, credit, debit, requester, and receiver factors.
Table 1.4 describes initiator, credit, debit, requester, and receiver factors.

Table 1.4 Initiator, credit, debit, requester, and receiver factors


Factor Description

IdentityType Identity type of a participant.


IdentityId Identity ID of a participant.
ShortCode Short code of a participant. If the participant is not an organization, a null
string is sent back.
OrganizationI Organization ID of a participant. If the participant is not an organization, a

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 22


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 3 Factor Reference

Factor Description

d null string is sent back.


MSISDN MSISDN of a participant.
TrustLevel Trust level of a participant.
Birthday Birthday of a participant. If the participant's birthday is not recorded or the
participant does not have a birthday, an empty value is sent back.
Region Value of the KYC field Region of a participant. If the KYC field Region
of the participant is not recorded or the participant does not have this
KYC field, a null string is sent back.
City Value of the KYC field City of a participant. If the KYC field City of the
participant is not recorded or the participant does not have this KYC field,
a null string is sent back.
ActiveDate Date when a participant is activated.
RegisteredDat Date when a participant is registered.
e
Segments Segments of a participant. If there is no segment, an empty list is sent
back.
FirstName Value of the KYC field First Name of a participant. If the KYC field
First Name of the participant is not recorded or the participant does not
have this KYC field, a null string is sent back.
MiddleName Value of the KYC field Middle Name of a participant. If the KYC field
Middle Name of the participant is not recorded or the participant does not
have this KYC field, a null string is sent back.
LastName Value of the KYC field Last Name of a participant. If the KYC field Last
Name of the participant is not recorded or the participant does not have
this KYC field, a null string is sent back.
Organization Organization name of a participant. If the participant is not an
Name organization, a null string is sent back.

3.3 Bank Statement


This topic describes bank statement factors.
Table 1.5 describes bank statement factors.

Table 1.5 Bank statement factors


Factor Description

BankStatemen Bank statement number.


tNo

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 23


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 3 Factor Reference

Factor Description

TrustAccount Trust account of an SP.


Currency Currency code.
OpeningBalan Opening balance, for example, 632184,91. In the example, the comma (,)
ce indicates the decimal point.
CpsTransactio Transaction SN in the Mobile Money system.
nNo
ValueDate Transaction date.
TransactionA Transaction amount.
mount
ReasonType Alias of the transaction reason type.
BankTransacti Bank transaction SN.
onNo
TransactionDe Transaction details.
tail
EntryDate Date when the entry is generated.
CurrentEleme Value of the current element.
ntValue
EntriesCount Number of entries.
Substring_1~ File name character strings, which are Substring1 to Substring10 from the
Substring_10 left to the right and separated by underlines (_).
CreditIdentifie Identifier of the transaction credit party.
r
DebitCredit Debit or credit flag. (C: credit; D: debit)
FileID Bank statement file ID.
ClosingBalanc Closing balance, for example, 927937,93. In the example, the comma (,)
e indicates the decimal point.

3.4 Tax Payer


This topic describes tax payer factors.
Table 1.6 describes tax payer factors.

Table 1.6 Tax payer factors


Factor Description

Region Region to which the tax payer belongs.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 24


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 3 Factor Reference

Factor Description

City City to which the tax payer belongs.


Segments Segments of the tax payer.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 25


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 4 Function Reference

4 Function Reference

About This Chapter


Frequently used methods are encapsulated into functions for users to use. This topic describes
the functions and how to use the functions.
4.1 Overview
This topic describes precautions for using functions.
4.2 weekDay
This topic describes the weekDay function.
4.3 monthDiff
This topic describes the monthDiff function.
4.4 dayDiff
This topic describes the dayDiff function.
4.5 length
This topic describes the length function.
4.6 substr
This topic describes the substr function.
4.7 todate
This topic describes the todate function.
4.8 GetAccuInContext
This topic describes the GetAccuInContext function.
4.9 GetAccu
This topic describes the GetAccu function.
4.10 hour
This topic describes the hour function.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 26


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 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.

Return values of the function are as follows:


 1: Monday
 2: Tuesday
 3: Wednesday
 4: Thursday
 5: Friday
 6: Saturday
 0: Sunday

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 27


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 4 Function Reference

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;

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 28


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 4 Function Reference

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;

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 29


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 4 Function Reference

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:

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 30


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 4 Function Reference

− 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;

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 31


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 4 Function Reference

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;

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 32


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

5 Preset Function Reference

About This Chapter


This topic describes preset functions and their use scenarios. Functions provided on the GUI
can be used in both the simple and complex modes. Preset functions can only be used in
complex mode.

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 Daily Processing Functions


This topic describes preset daily processing functions, including the functions for calculating
the specified date, converting the date format, and obtaining the date.
5.2 Value Processing Functions
This topic describes preset value processing functions.
5.3 Character String Processing Functions
This topic describes preset character string processing functions.

5.1 Daily Processing Functions


This topic describes preset daily processing functions, including the functions for calculating
the specified date, converting the date format, and obtaining the date.

5.1.1 adddays
This topic describes the adddays function.

Format
adddays(Date, Integer)

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 33


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

If parameter 1 is null, the function returns null.

Scenario
Obtain the date ten days later than November 12, 2015.
datetime dateVar = "20151112000000";
return adddays(dateVar, 10);

Return value: 20151122000000

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.

If parameter 1 is null, the function returns null.

Scenario
Obtain the date ten hours later than 15 o'clock on November 12, 2015.
datetime dateVar = "20151112150000";

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 34


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

return addhours(dateVar, 10);

Return value: 20151113010000

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.

If parameter 1 is null, the function returns null.

Scenario
Obtain the date 50 minutes later than 23:11 on November 12, 2015.
datetime dateVar = "20151112231100";
return addminutes(dateVar, 50);

Return value: 20151113000100

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 35


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

Return Value
The function returns a value of the Date type.

If parameter 1 is null, the function returns null.

Scenario
Obtain the date three months later than November 12, 2015.
datetime dateVar = "20151112000000";
return addmonths(dateVar, 3);

Return value: 20160212000000

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.

If parameter 1 is null, the function returns null.

Scenario
Obtain the date three years later than November 12, 2015.
datetime dateVar = "20151112000000";
return addyears(dateVar, 3);

Return value: 20181112000000

5.1.6 currentDay
This topic describes the currentDay function.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 36


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

If the parameter is null, the function returns null.

Scenario
Return the integer (MMdd) combined by the month and date of November 12, 2015.
datetime dateVar = "20151112000000";
return currentDay(dateVar);

Return value: 1112

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.

If the parameter is null, the function returns null.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 37


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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");

Return value: 2015-11-12 00:00:00

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 38


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

If the parameter is null, the function returns null.

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.

If the parameter is null, the function returns null.

Scenario
Obtain the last day in November of 2015.
return lastday(201511);

Return value: 20151130

5.1.11 monthsbetween
This topic describes the monthsbetween function.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 39


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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);

Return value: 8.0

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();

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 40


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

Return value: 20151005000000

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.

If parameter 1 is null, the function returns null.

Scenario 1
Convert the character string "20130716" into a date.
return todate("20130716");

Return value: 20130716

Scenario 2
Convert the character string "20130716" into a date in the yyyy-MM-dd format.
return todate("20130716", "yyyy-MM-dd");

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 41


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

Return value: 2013-07-16

5.2 Value Processing Functions


This topic describes preset value processing functions.

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.

If the parameter is null, the function returns null.

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 42


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

If the parameter is null, the function returns null.

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.

 If the parameter is null, the function returns null.


 If the parameter value is not a number (for example, "abc"), the function returns 0.

Scenario
Convert the character string "1.11" into a value of the Double type.
return doubleconvert("1.11");

Return value: 1.11

5.2.4 floatconvert
This topic describes the floatconvert function.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 43


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

 If the parameter is null, the function returns null.


 If the parameter value is not a number (for example, "abc"), the function returns 0.

Scenario
Convert the character string "1.11" into a value of the Float type.
return floatconvert("1.11");

Return value: 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.

 If the parameter is null, the function returns null.


 If the parameter value is not a number (for example, "abc"), the function returns 0.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 44


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

 If the parameter is null, the function returns null.


 If the parameter value is not a number (for example, "abc"), the function returns 0.

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 45


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

 If the parameter is null, the function returns null.


 If the parameter value is not a number (for example, "abc"), the function returns 0.

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.

If the parameter is null, the function returns null.

Scenario
Obtain the largest integer that is of the Double type and is not greater than -2.4.
return floor(-2.4);

Return value: -3.0

5.2.9 greatest
This topic describes the greatest function.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 46


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 47


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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).

If the parameter is null, the function returns false.

Scenario
Check whether "2004" consists of only digits.
return isdigit("2004");

Return value: true

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 48


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

Scenario
Check whether null is empty.
return isnull(null);

Return value: true

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 49


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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);

Return value: 1.11

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 50


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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 Character String Processing Functions


This topic describes preset character string processing functions.

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 51


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

If the parameter is null, the function returns null.

Scenario
Obtain the ASCII characters corresponding to 67.
return chr(67);

Return value: A

5.3.3 indexof
This topic describes the indexof function.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 52


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 53


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

If the parameter is null, the function returns null.

Scenario
Remove the space character from the left of the character string " hello".
return lefttrim(" hello");

Or
return ltrim(" hello");

Return value: "hello"

5.3.6 righttrim/rtrim
This topic describes the righttrim/rtrim function.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 54


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

If the parameter is null, the function returns null.

Scenario
Remove space characters from the right of the character string "math ".
return righttrim("math ");

Or
return rtrim("math ");

Return value: "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.

If the parameter is null, the function returns null.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 55


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

Scenario
Remove space characters from both sides of the character string " hello ".
return trim(" hello ");

Return value: "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.

If the parameter is null, the function returns null.

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 56


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

 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*");

Return value: true

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.

If the parameter is null, the function returns null.

Scenario
Convert the uppercase letter in the character string "aBc" into a lowercase letter.
return lower("aBc");

Return value: "abc"

5.3.11 upper
This topic describes the upper function.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 57


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

If the parameter is null, the function returns null.

Scenario
Convert all lowercase letters in the character string "aBc" into uppercase letters.
return upper("aBc");

Return value: "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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 58


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

If parameter 1 is null, the function returns null.

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, "-");

Return value: "------math"

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.

If parameter 1 is null, the function returns null.

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, "-");

Return value: "math------"

5.3.14 split
This topic describes the split function.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 59


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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", ",");

Return value: ["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.

If parameter 1 is null, the function returns null.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 60


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

Scenario
Truncate the sub character string "lc" from the character string "welcome".
return substr("welcome", 2, 4);

Return value: "lc"

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.

If the parameter is null, the function returns null.

Scenario
Convert the character string "11.1" into a value of the Float type.
return tofloat("11.1");

Return value: 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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 61


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

Return Value
The function returns a value of the Integer type.

If the parameter is null, the function returns null.

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.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 62


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

datetime dateVar = "20151112000000";


return tostring(dateVar);

Return value: "20151112000000"

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");

Return value: "2015-11-12 00:00:00"

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.

If parameter 1 is null, the function returns null.

Scenario
Replace the character string "ab" in the character string "abdeabef" with the character string
"xx".
return replace("abdeabef", "ab", "xx");

Return value: "xxdexxef"

5.3.20 translate
This topic describes the translate function.

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 63


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

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.

If parameter 1 is null, the function returns null.

Scenario
Replace the character string "abc" in the character string "abcdefghij" with the character string
"123".
return translate("abcdefghij","abc","123");

Return value: "123defghij"

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

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 64


Copyright © Huawei
Technologies Co., Ltd.
Mobile Money
Rule Configuration Reference 5 Preset Function Reference

Return Value
The function returns a random 32-bit character string.

Scenario
Generate a random 32-bit character string.
return uuid();

Return value: "123defghijbacad123defghijbacadee"

Issue 01 (2017-07-28) Huawei Proprietary and Confidential 65


Copyright © Huawei
Technologies Co., Ltd.

You might also like