Scripting in Finacle – Part 1
Agenda
SI. No. Topic Name
1. Objectives
2. Scripting Syntax
Arithmetic/Logical Operators
3. Control/Loop statements
4. GOTO/GOSUB Statements
5. Built-in Utility Functions
6. Repositories and Classes
7. Call/Start Statements
8. Summary
3
Objectives
At the end of this module you will be able to:
• Explain scripting syntax.
• Arithmetic/Logical Operators
• Control/Loop statements
• GOTO/GOSUB Statements
• Built-in Utility Functions
• Repositories and Classes
• Call/Start Statements
Introduction
5
Scripting
• Scripting – a programming language supported by Finacle.
• It has its own syntax, built in functions and variables.
• It is used to fetch data from backend and insert fetching from
frontend.
• It has its own memory area called repositories.
6
Terminologies
The following is information on scripting terminologies.
$TBA_SCRIPTS
• It is an environment variable set in the commonenv.com file.
• It is the directory where all the scripts should exist.
Fetching the Scripts
• The application looks for the scripts in this directory
$TBA_PROD_ROOT/cust/<Bank_Id>/<Language_code>/scripts.
• If the script is not available in this directory, it picks the script from the
directory $TBA_PROD_ROOT/prodbase/INFENG/scripts.
7
Limitations of scripting using vi editor
• User must learn the syntax
• Developer needs to know the structure of repositories
• Need to be aware of the inputs, outputs and usage of
userhooks.
• No online assistance to the user
8
Finacle Script IDE
• Integrated Development Environment (IDE) for developing
Finacle scripts
• Based on Eclipse platform
• Provides industry standard IDE features
• Enforces coding standards in Finacle scripts
• Separately Licensed and priced component of Finacle UBS
9
Features of IDE
• More usability
• Online help
• Online Debugging
• Testing the script in the local machine
Scripting Syntax
11
Scripting Syntax
The following are some the rules for scripting syntax.
All Scripts must begin with a <--start and end with end-->
Scripting is not very case sensitive. Example: <--START or <--Start
Lines beginning with ‘#’ are considered as comments. They make the
script easier and better to understand. Example: # This line is a comment
12
Scripting Syntax (Contd.)
The following is for viewing the output in Finacle.
Logs
> User specific Log Directory
Debugging
• Trace on
• Trace off
13
Scripting Syntax (Contd.)
Scratch pad variables sv_a to sv_z can be used within a script to store
runtime values. They are allocated data type dynamically depending on
the initialization. Example: sv_a = 10
Arithmetic Operations like ‘+’, ‘-’, ‘*’, ‘/’ can be performed using respective
operators. Example: sv_c = sv_a + sv_b
14
Scripting Syntax: Examples
The following is an example of using a comment in scripting.
Using a comment in the Script
<--START
sv_a = 100
sv_b = 10
# This statement will add both the scratchpad variables
sv_c = sv_a + sv_b
PRINT(sv_c)
END-->
Arithmetic/Logical Operators
Control/Loop Statements
16
Scripting Syntax: Arithmetic Operators Examples
The following example shows how to use arithmetic operations.
Using Arithmetic Operators
<--START
sv_a = 100
sv_b = 10
# This statement will add both the scratchpad variables
sv_c = sv_a + sv_b
PRINT(sv_c)
# This statement will divide both the scratchpad variables
sv_f = sv_a / sv_b
PRINT(sv_f)
END-->
17
Scripting Syntax
The following are examples of using the below operators in scripting.
Comparison Operators
‘==‘, ‘<=‘, ‘>=‘, ‘<‘, ‘>’, ‘!=‘ can be used. This returns value ‘1’ if
TRUE and 0 if FALSE. Example: sv_a > sv_b
Logical Operators
This can be used for logical operations. Example: ‘AND’, ‘OR’
Unary Operator
This can be used only on number types. Example: sv_a=-sv_b.
18
Logical Operators
The following is an example of how to use the ‘OR’ operator.
<--START
# Script body goes here
sv_a = 10
sv_b = 20
IF((sv_a>sv_b) OR (sv_a<sv_b) ) THEN
#{
sv_c = sv_a+sv_b
PRINT(sv_c)
#}
ENDIF
END--> O/p → 30
19
Logical Operators (Contd.)
The following is an example for using the ‘AND’ operator.
<--START
# Script body goes here
sv_a = 10
sv_b = 20
IF((sv_a>sv_b) AND (sv_a<sv_b) ) THEN
#{
sv_c = sv_a+sv_b
PRINT(sv_c)
#}
ENDIF
END--> O/p → No output
20
Control Statements
The following are control statements.
IF - ELSE Control Statements
These are used to control the flow of the program. IF is used then
Statement 1 is considered. When ELSE is chosen then it is Statement
2 is considered.
WHILE Control Statement
This is used till the test condition is TRUE. A set of statements are
executed repetitively, and the execution stops once the test condition
becomes ‘FALSE’.
Syntax: WHILE (condition) statements
DO
GOTO/GOSUB
Statements
22
Calls Within a Script
The following are the calls within a script.
GOTO
It is a forward reference. Example: GOTO labelname
GOSUB
• It is both a forward and backward reference. If the call is made
within a conditional statement, the Label cannot be defined outside
the control.
• It returns as soon as it finds RETURN statement in the script.
Example: GOSUB labelname
Built-in Utility Functions
24
Built-in Utility Functions
The following information is on MID$ function.
MID$
MID$ (Variable, StartPosition, Length)
<--START
# Script body goes here
sv_a = MID$ (“543216789",3,5)
PRINT(sv_a)
END--> O/p →21678
25
Built-in Utility Functions (Contd.)
The following information is on the LEFT$ function.
LEFT$
LEFT$ (Variable, Length)
<--START
# Script body goes here
sv_a = LEFT$("1234567890",3)
PRINT(sv_a)
END-->
O/p →123
26
Built-in Utility Functions (Contd.)
The following information is on the RIGHT$ function.
RIGHT$
RIGHT$ (Variable, Length)
<--START
# Script body goes here
sv_a = RIGHT$("1234567890",3)
PRINT(sv_a)
END-->
O/p → 890
27
Built-in Utility Functions (Contd.)
The following information is on the SETS$ function.
SET$
SET$ (Variable1, From Position, Length, Variable2)
<--START
# Script body goes here
sv_a = SET$("1234567890",3,5,"ASDFG")
PRINT(sv_a)
END--> O/p →123ASDFG90
28
Built-in Utility Functions (Contd.)
The following information is on the STRLEN$ function.
STRLEN
STRLEN (Variable)
<--START
# Script body goes here
sv_a = "Finacle UBS"
sv_b = STRLEN(sv_a)
PRINT(sv_b)
END--> O/p → 11
29
Built-in Utility Functions (Contd.)
The following information is on the TOLOWER $ function.
TOLOWER
TOLOWER (Variable)
<--START
# Script body goes here
sv_a = "Finacle UBS"
sv_b = TOLOWER(sv_a)
PRINT(sv_b)
END--> O/p → finacle ubs
30
Built-in Utility Functions (Contd.)
The following information is on the TOUPPER $ function.
TOUPPER
TOUPPER (Variable)
<--START
# Script body goes here
sv_a = "Finacle UBS"
sv_b = TOUPPER(sv_a)
PRINT(sv_b)
END-->
O/p → FINACLE UBS
31
Built-in Utility Functions (Contd.)
The following information is on the STRICMP $ function.
STRICMP
STRICMP (Variable1, Variable2)
<--START
sv_a = "Hello"
sv_b = "hello"
IF(STRICMP(sv_a,sv_b) == 1) THEN
PRINT("Equal")
ELSE
PRINT ("Unequal")
ENDIF
END--> O/p →Equal
32
Built-in Utility Functions (Contd.)
The following information is on the CHARAT$ function.
CHARAT
CHARAT (Variable, Position)
<--START
# Script body goes here
sv_c = CHARAT("Finacle UBS",5)
PRINT(sv_c)
END--> O/p → l
33
Built-in Utility Functions (Contd.)
The following information is on the GETPOSITION$ function.
GETPOSITION
GETPOSITION (Variable1, Variable2)
<--START
# Script body goes here
sv_a = "Finacle UBS"
sv_b = "UBS"
sv_c = GETPOSITION(sv_a,sv_b)
PRINT(sv_c)
END--> O/p → 9
34
Built-in Utility Functions (Contd.)
The following information is on the GETSTRING $ function.
GETSTRING
GETSTRING (Variable1)
<--START
# Script body goes here
sv_a = 'A'
sv_b = GETSTRING(sv_a)
PRINT(sv_b)
END-->
O/p → “A”
35
Built-in Utility Functions (Contd.)
The following information is on the CINT$ function.
CINT
CINT (Variable)
<--START
# Script body goes here
sv_a = CINT("1234.50")
PRINT(sv_a)
END--> O/p → 1234
36
Built-in Utility Functions (Contd.)
The following information is on the CDOUBLE $ function.
CDOUBLE
CDOUBLE (Variable)
<--START
# Script body goes here
sv_a = CDOUBLE("1234.5678")
PRINT(sv_a)
END--> O/p → 1234.567800
37
Built-in Utility Functions (Contd.)
The following information is on the CDOUBLE$ function.
LTRIM
LTRIM (Variable1)
LTRIM (Variable1, Char1)
<--START
# Script body goes here
sv_a = " Finacle UBS"
sv_b = LTRIM(sv_a)
PRINT(sv_b)
END--> O/p → Finacle UBS
38
Built-in Utility Functions (Contd.)
The following information is on the RTRIM $ function.
RTRIM
RTRIM (Variable1)
RTRIM (Variable1, Char1)
<--START
# Script body goes here
sv_a = "Finacle UBS "
sv_b = RTRIM(sv_a)
PRINT(sv_b)
END--> O/p → Finacle UBS
39
Built-in Utility Functions (Contd.)
The following information is on the TRIM $ function.
TRIM
TRIM (Variable1)
TRIM (Variable1, Char1)
<--START
# Script body goes here
sv_a = " Finacle UBS "
sv_b = TRIM(sv_a)
PRINT(sv_b)
END--> O/p → UBS
40
Built-in Utility Functions (Contd.)
The following information is on the LPAD$ function.
LPAD
LPAD (Variable1, FinalNoCharInVar, Char1)
<--START
# Script body goes here
sv_a = LPAD("Finacle",10,'*')
sv_b = " UBS"
sv_c = sv_a+sv_b
PRINT(sv_c)
END--> O/p → ***Finacle UBS
41
Built-in Utility Functions (Contd.)
The following information is on the RPAD $ function.
RPAD
RPAD (Variable1, FinalNoCharInVar, Char1)
It is used for padding(adding) any specific no of characters from the
right-side to the variable.
<--START
# Script body goes here
sv_a = RPAD("Finacle",9,'*')
PRINT(sv_c)
END--> O/p → Finacle**
Repositories and Classes
43
Repositories and Classes
The following is the information on classes and repositories.
• Scripting can use certain variables, which are available from
certain memory areas called as repositories.
• Repository is a memory area to store a set of Classes.
• A Class is a set of name and value pairs, that is, Field name and
Field value of a particular Type.
• Type can be Integers, Float, Double, Character and String
• All Field Values are referred by,
“REPNAME.CLASSNAME.FIELDNAME”
Example: MYREP.integerCLASS.Field1
44
Built-in Utility Functions
The following are the built in utility functions.
REPEXISTS
REPEXISTS (“RepositoryName”)
Example: If (REPEXISTS(“TestRep”) == 0)
CLASSEXISTS
CLASSEXISTS (“RepositoryName”,“ClassName”)
Example: If (CLASSEXISTS(“TestRep”,”TestClass”) == 0)
FIELDEXISTS
FIELDEXISTS (RepositoryName.ClassName.FieldName)
Example: If (FIELDEXISTS(TestRep.TestClass.TestField) == 0)
45
Built-in Utility Functions (Contd.)
CREATEREP
CREATEREP (Variable1)
Example: CREATEREP(“TestRep”)
CREATECLASS
CREATECLASS (Variable1, Variable2, DataType1)
Example: CREATECLASS(“TestRep”,”TestClass”,1)
46
Built-in Utility Functions (Contd.)
DELETEREP
DELETEREP (Variable1)
Example: DELETEREP(“TestRep”)
DELETECLASS
DELETECLASS (Variable1, Variable2)
Example: DELETECLASS(“TestRep”,”TestClass”)
47
Built-in Utility Functions: Example
<--START
IF(REPEXISTS("TestRep") == 0) THEN
CREATEREP("TestRep")
ENDIF
IF(CLASSEXISTS("TestRep","TestClass") == 0) THEN
CREATECLASS("TestRep","TestClass",1)
ENDIF
IF(FIELDEXISTS(TestRep.TestClass.TestField) == 0) THEN
PRINT("TestRep.TestClass.TestField does not exist")
TestRep.TestClass.TestField = 10
PRINT(TestRep.TestClass.TestField)
ENDIF
DELETECLASS("TestRep","TestClass")
DELETEREP("TestRep")
END-->
Call/Start Statements
49
Calling another Script
The following is information on calling a script.
CALL
CALL(“ScriptName”)
or
CALL(“Path”,“ScriptName”)
The execution of the script returns to the same point in the old script as soon
as it finds EXITSCRIPT statement in the new script.
START
START(“ScriptName”)
or
START( “Path”,“ScriptName”)
The execution of the script does not return to the original script
50
Summary
In this session, you learnt:
• the following basic scripting syntax.
• Arithmetic/Logical Operators
• Control/Loop statements
• GOTO/GOSUB Statements
• Built-in Utility Functions
• Repositories and Classes
• Call/Start Statements.
Thank You
© 2013 Infosys Limited, Bangalore, India. All Rights Reserved. Infosys believes the information in this document is accurate as of its publication date; such information is subject to change
without notice. Infosys acknowledges the proprietary rights of other companies to the trademarks, product names and such other intellectual property rights mentioned in this document. Except
as expressly permitted, neither this documentation nor any part of it may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, printing,
photocopying, recording or otherwise, without the prior permission of Infosys Limited and/ or any named intellectual property rights holders under this document.