Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

SCRIPTING

• Geetha
UET
Agenda

 Scripting Introduction

 Scripting Syntax

 Scripting Userhooks
Introduction

• Scripting is a programming language that FINACLE supports for


various events.

• Mainly used for customization and charge calculations.

- Business Logic (Customization)


- Formatting of account numbers
Terminology
• TBA_SCRIPTS

TBA_SCRIPTS is an environment variable set in the


commonenv.com file.

This is the directory where all the scripts should exist. The
application will look for this directory
$TBA_PROD_ROOT/cust/01/INFENG/scripts

If the script is not available in this directory, it will pick the script from
the directory $TBA_PROD_ROOT/prodbase/INFENG/scripts

If the script is also not available in this directory also, the default
logic (if available) will be applied as specified in each case.
Terminology

• Repository

A repository is a memory structure to store data of the user. Scripts


access data from repository only. Repository Structure is user based

• Userhook

A pre-defined function defined in Finacle to perform necessary


tasks. Using Userhooks the user can achieve certain required
operations in a script.
Process Diagram
Scripting Syntax

• All Scripts must begin with a ‘<--start’ & end with


‘end-->’

• Scripting is not very case sensitive


e.g. <--START or <--Start
Scripting Syntax

• Lines beginning with a ‘#’ is considered as a comment


e.g # this line is a comment

• Scratch pad variables ‘sv_a’ to ‘sv_z’ can be used within a script


to store runtime values.
e.g. sv_a = 10

• Arithmetic Operators like ‘+’, ‘-’, ‘*’, ‘/’ can be performed.


e.g sv_c = sv_a + sv_b
Scripting Syntax

• Comparison operators like „==„, „<=„, „>=„, „<„, „>‟, „!=„ can be used.
These return values „1‟ if TRUE and 0 if FALSE.
e.g. Sv_a > sv_b

• LOGICAL OPERATORS „AND‟, „OR‟

• UNARY OPERATOR
eg: sv_a = -sv_b. ( can be used only on number types)
Scripting Syntax

Control Structures

• IF ( Condition) THEN
statements
ELSE
statements
ENDIF

• WHILE (condition)
statements
DO
GOTO GOSUB

Transfers control from one part of script to another in


same script file

Syntax:

GOTO LabelName

GOSUB LabelName
Calling another script
A script can be called from another script.

Syntax:

Call scriptname
Or
Start scriptname
Exiting a Script

• Scripting provides a safe way of exiting the execution of the script.


Whenever the Script Engine finds EXIT statement in the execution
path stops the execution and returns to the Calling routine.

• To return from CALLED script to the calling script, use EXITSCRIPT


Built-in Utility Functions

• MID$ MID$ (Var, StartPosition, Length)

• LEFT$ LEFT$ (Var, Length)

• RIGHT$ RIGHT$ (Var, Length)

• CINT CINT (Var)

• CDOUBLE CDOUBLE (Var)

• TOLOWER TOLOWER (Var)

• TOUPPER TOUPPER (Var)


Built-in Utility Functions

• SET$ SET$ (Var1, From,Length, Var2)

• STRLEN STRLEN (Var)

• CHARAT CHARAT (Var, Position)

• LTRIM LTRIM (Var1, Var2)

• RTRIM RTRIM (Var1, Var2)

• TRIM TRIM (Var1, Var2)

• LPAD LPAD (Var1, Var2, Var3)

• RPAD RPAD (Var1, Var2, Var3)


Repositories and Classes
• Scripting can use certain variables, which are available from certain
memory areas called as repositories. The user can within the script
access the variables from the repositories.

• Repository is a memory area to store a set of Classes

• A Class is a set of name & Value pairs i.e 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”
Built-in Utility Functions

• REPEXISTS REPEXISTS (Var1)

• CLASSEXISTS CLASSEXISTS (Var1, Var2)

• FIELDEXISTS FIELDEXISTS (REP.CLA.FLD)

• GETPOSITION GETPOSITION (Var1, Var2)


Built-in Utility Functions

• STRICMP STRICMP (Var1, Var2)

• GETSTRING GETSTRING (Var1)

• CREATEREP CREATEREP (Var1)

• CREATECLASS CREATECLASS (Var1, Var2, Var3)

• DELETEREP DELETEREP (Var1)

• DELETECLASS DELETECLASS (Var1, Var2)


User hooks

 Userhooks are standard Fuctions.


 Generally user hooks interface with the scripts using a standard
repository called “BANCS”.
 There are 2 classes that have been predefined in this repository,
INPARAM and OUTPARAM
 INPARAM is the class that is used to populate specified fields in
the script so that the function can access those as parameters.
 All the field that are output by the function are populated in the
OUTPARAM.
Userhooks

Selection of fields from Database


Syntax:
sv_r = urhk_dbSelect(variable)

The variable can be a scratch pad variable (sv_a) or a


string (“user_id | select user_id from upr where
session_id = 'xxxx'”).

everything before '|' (pipe symbol) is taken as the title


value where as post pipe symbol is taken as query.
Userhooks
Using a SQL Statement in a Script
Syntax:
sv_a=urhk_dbSQL(variable)

The variable can be a scratch pad variable (sv_a) or a string (“update upr set
UESR_LOGGED_ON_FLG=‘N’ where session_id = 'xxxx'”).
Userhooks

DBCURSOROPEN
Syntax:

sv_a=“userid|select user_id from tbaadm.upr where user_id like


„FRESH%‟”
sv_b=urhk_dbcursoropen(sv_a)

opening cursor number will be stored in


BANCS.OUTPARAM.DB_CURSOR_NUMBER
Userhooks
DBCURSORFETCH
Syntax:

sv_a=BANCS.OUTPARAM.DB_CURSOR_NUMBER
sv_b=urhk_dbcursorfetch(sv_a)

for fetching all records from the cursor this userhook shall be place in
loop.
Userhooks

DBCURSORCLOSE
Syntax:

sv_a=BANCS.OUTPARAM.DB_CURSOR_NUMBER
sv_b=urhk_dbcursorclose(sv_a)

userhook return 0 on successful closing the cursor.


Userhooks

Print Repository Fields

Syntax:
sv_r =urhk_b2k_printRepos(variable)
Userhooks
Get Account Details

Syntax:
sv_a =urhk_getAcctDetailsInRepository(variable)

returns 0 if account is present in the database (irrespective of the state of


the account) else 1.
Userhooks

• BANCS.OUTPARAM.acctSolId
• BANCS.OUTPARAM.acctName
• BANCS.OUTPARAM.custId
• BANCS.OUTPARAM.acctCloseflg(Y/N)
• BANCS.OUTPARAM.ledgerNumber
• BANCS.OUTPARAM.AvailableAmt
• BANCS.OUTPARAM.FullAvailableAmt
Userhooks

Get Customer Details

Syntax:
sv_a=urhk_getCustomerDetails(variable)

Returns 0 if the customer is found else return


Value will be 1.
Userhooks

BANCS.OUTPARAM.CustName
BANCS.OUTPARAM.CustMaritalStatus
BANCS.OUTPARAM.NumOfAccounts
BANCS.OUTPARAM.CustMembershipDate
BANCS.OUTPARAM.DateOfBirth
BANCS.OUTPARAM.CustPermAddr1
BANCS.OUTPARAM.CustPermAddr2
Userhooks
Get the Scheme Details
Syntax:

sv_a =urhk_getSchemeDetailsInRepository(Variable)

returns 0 if the scheme is found else result in fatal error.


Userhooks

BANCS.OUTPARAM.SchemeDescription
BANCS.OUTPARAM.DefaultInstrumentType
BANCS.OUTPARAM.DefaultClearingTranCode
BANCS.OUTPARAM.NewAccountDuration
BANCS.OUTPARAM.SchemeType
BANCS.OUTPARAM.MinPostingWorkClass
Userhooks
Validating the Account

syntax:
sv_a=urhk_valAcctNumber(variable)
input to this function is account number(FORACID)

The output will be 0 in case of valid account number


else returns 1.
Userhooks

Eg:
<--start
trace on
sv_a==“TD_41_01”
sv_b ==urhk_valAcctNumber(sv_a)
print(sv_b)
trace off
end-->
Userhooks

Validation of SOLID

syntax:
sv_a =urhk_B2k_valSolId(“Sol_id”)

input to this function is sol_d.

returns 0 if the sol_id is valid else return 1.


Userhooks

eg:

<--start
trace on
sv_e =urhk_B2k_valSolId(“102”)
print(sv_e)
trace off
end -- >
Userhooks

Validation of Reference Code

Syntax:
Sv_a=urhk_B2k_valRefCode(variable)

input to this fucntion is reference code type and reference code


to be validated delimited by „|‟.

returns 0 if the code is valid else return 1.


Userhooks
eg:
<-- start
trace on
sv_a=urhk_B2k_valRefCode(01|Agra)
print(sv_a)
trace off
end-- >
Usehooks
• Date Functions
Adding Days and Months in a Given Date
Syntax:
sv_a=(“old_date”+”|”+”no_of_months_”+”|”+”no_of_
days”)
sv_b=urhk_B2k_Add_MonthsDays_To_date(sv_a)
userhook return 0 on success.

BANC.OUTPARAM.MODIFIED_DATE will contain modified date.


Userhooks
eg:
<--start
trace on
sv_a=(“10_12_2008”+”|”+”10”+”|”+”12”)
sv_b=urhk_B2k_Add_MonthsDays_To_date(sv_a)
print(sv_b)
print(BANCS.OURPARAM.MODIFIED_DATE)
trace off
end-->
Userhooks
Difference between two Dates
Syntax:
sv_a =urhk_B2k_dateDiff(“ “)

This userhook gives difference between two dates in no


of days
input: BANCS.INPARAM.date1
BANCS.INPARAM.date2
userhook returns 0 on success and difference will be stored
in BANCS.OUTPARAM.dateDiff.
Userhooks
eg:

<-- start
trace on
BANCS.INPARAM.date1=“10_12_2009”
BANCS.INPARAM.date2=“10_12_2008”
sv_e=urhk_B2k_dateDiff(“”)
print(BANCS.OUPARAM.dateDiff)
trace off
end-- >
Thank You

“The contents of this document are proprietary and confidential to Infosys Technologies Ltd. and may not be disclosed in whole or in part at any time, to any third party
without the prior written consent of Infosys Technologies Ltd.”

© 2007 Infosys Technologies Ltd. All rights reserved. Copyright in the whole and any part of this document belongs to Infosys Technologies Ltd. This work may not be used,
sold, transferred, adapted, abridged, copied or reproduced in whole or in part, in any manner or form, or in any media, without the prior written consent of Infosys
Technologies Ltd.

You might also like