Infobasic Programming
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA1
Agenda
Introduction to Infobasic
Arrays and types of arrays
Introduction to subroutines and programs
Important functions/commands in Infobasic
Steps to create a subroutine in T24
Compiling and cataloguing routines and programs
T24 routines – file operations
T24 routines – sequential file access
T24 – Creation of functions and routines with arguments
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA2
Introduction To Infobasic
Programming language used for T24
Simple – English like statements
No declaration of variables required
No data type specification is required
All variables by default have infinite variable length
– Multi value
– Sub Value
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA3
Arrays
Continuous allocation of bytes
All bytes in an array have the same name as that of the
array
Each byte is uniquely identified with the help of a
subscript.
T E M E N O S
0 1 2 3 4 5 6
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA4
Arrays In Infobasic
Dynamic Arrays
– Dynamic in nature
– Variable length
– Need not be declared
– Can hold any type of data
– Automatically increase or decrease in size depending on the
data
– All variables in Infobasic are dynamic arrays
Dimensioned arrays
– Have a fixed number of rows and columns
– Can hold any type of data
– Needs to be declared
– Used when dimensions and extents are known and are not
likely to change
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA5
Dynamic Array
CUSTOMER.NAME = ‘’
RATE = 0
DATE = “121202”
Can store any type and any amount of data.
Only initialisation is required.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA6
Arrays
Dynamic Arrays (Cont.)
– Uses delimiters to store data of various fields
ASCII Decimal Description
254 Field Marker
253 Value Marker
252 Sub-Value Marker
Filed1FMField2FM Value1VMValue2VMValue3VMValue4FMField4FMSubValue1SMSubValue2FMField6
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA7
Sample Record From The TEMENOS.TRG
1 Name TemenosTrg
2.1 Address India
2.2 Address UK
2.3 Address Geneva
3.1 Course Category Technical
4.1.1 Course Name jBASE
4.1.2 Course Name T24
3.2 Course Category Functional
4.2.1 Course Name Lending
4.2.2 Course Name Financials
5 Free Text
6 Inputter TRAINER.1
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA8
How will this record get stored in a dynamic array?
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA9
Storage In A Dynamic Array
TemenosTrgFMIndiaVMUKVMGenevaFMTechnicalVMFunctionalFM
jBASESMT24VMLendingSMFinancialsFMFMTrainer.1
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
10
Dimensioned Array
DIM ARRAY1(4,3)
4 – Rows
3 – Columns
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
11
Dimensioned Array (Cont.)
DIM ARRAY2(4)
4 – Rows
Unlimited columns (Each row will be a dynamic array)
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
12
Structure Of An Infobasic Program
PROGRAM – Executed from the database prompt
SUBROUTINE – Execute from within Globus
*Comments *Comments
PROGRAM <Programname> SUBROUTINE <Subroutinename>
Statement 1 Statement 1
Statement 2 Statement 2
Statement 3 Statement 3
RETURN
END END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
13
Compiling And Cataloguing Routines
EB.COMPILE TRG.BP TRG.RTN1
COMPILE CATALOG
Check for errors Check JBCDEV_LIB
Error – Exit
No Error JBCDEV_LIB
= $HOME/lib
Produce object code
$TRG.RTN1 $HOME/lib
TRG.BP
Is there place here
lib.so.1
$TRG.RTN1
Is there place here
lib.so.2
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
14
Compiling And Cataloguing Programs
EB.COMPILE TRG.BP TRG.PRG1
COMPILE CATALOG
Check for errors Check JBCDEV_BIN
Error – Exit
No Error JBCDEV_BIN
= $HOME/bin
Produce executable
$TRG.PRG1
TRG.BP $HOME/bin
$TRG.PRG1 TRG.PRG1
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
15
Executing Routines
Login into T24
Make an entry in
the PGM.FILE
At the command line
TRG.RTN1
JBCOBJECTLIST =
$HOME/globuslib;$HOME/lib
Execute the
routine
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
16
Executing Programs
Go to the
database prompt
jsh..> TRG.PRG1
PATH =
.;$HOME/globusbin;$HOME/bin;$PATH
Execute the
program
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
17
Writing A Simple Infobasic Program
Program to display ‘Hello World’
JED TRG.BP HELLO
PROGRAM HELLO
CRT “Hello World”
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
18
Compile And Execute The Program
Compile and catalog
EB.COMPILE TRG.BP HELLO
Execute the program
jsh..>HELLO
Hello World
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
19
Workshop 1
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
20
Control Structures
IF THEN ELSE
IF <condition> THEN
<statements>
END
ELSE
<statements>
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
21
Control Structures
BEGIN CASE … END CASE
BEGIN CASE
CASE <variable> = <value>
<statements>
CASE <variable> = <value>
<statements>
CASE <variable> = <value>
<statements>
CASE 1
<statements>
END CASE
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
22
Control Structures
FOR
FOR <variable> = <initialvalue> TO <maximumvalue>
<statements>
NEXT <variablename>
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
23
Control Structures
Open Loop
LOOP
CRT “Input 2 Numbers”
INPUT Y.NUM1
INPUT Y.NUM2
WHILE Y.NUM1:Y.NUM2
CRT “Total “ : Y.NUM1 + Y.NUM2
REPEAT
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
24
Built In Infobasic Functions
LEN(e) Length of the text in expression
COUNT(e,d) Number of occurrences of d in e
DCOUNT(e,d) Number of occurrences of d in e, +1
UPCASE(e) Converts e to uppercase
DOWNCASE(e) Converts e to lowercase
CHANGE(e,d,c) Change occurrences of d to c in e
OCONV(e,d) Convert e into the format specified in d
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
25
Structure Of A Subroutine
SUBROUTINE SubroutineName
$INSERT I_COMMON
$INSERT I_EQUATE
Actual Statements
Actual Statements
RETURN
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
26
Insert Files
I_COMMON
– Defines all common variables
I_EQUATE
– Equates a number of common variables
Insert files are available under GLOBUS.BP
Common variables get loaded when a user signs on
Some common variables are loaded when specific
applications are opened/specific actions are performed
Example : R.USER, ID.NEW
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
27
Example 2
Write a subroutine that will display the details
(Id, Mnemonic and Nationality)of a customer whose id is 100069
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
28
Algorithm
Step 1. Open the Customer File
Step 2. Read the Customer file and extract the record
with id 100069
Step 3. From the extracted record obtain the mnemonic
and nationality
Step 4. Display the customer id,mnemonic and
nationality.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
29
Open A File
Use the command OPEN
OPEN FBNK.CUSTOMER…….
But…….
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
30
Open A File (Cont.)
OPF – Open File
CALL OPF(FN.CUS,F.CUS)
FN.CUS = ‘F.CUSTOMER’ (File Name)
F.CUS = ‘’ (File Path)
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
31
Read A File
Use the Globus subroutine
CALL F.READ(1,2,3,4,5)
1 - File name
2 - ID of the record to be read
3 - Dynamic array that will hold the read record
4 - File Path
5 – Error Variable
CALL F.READ(FN.CUS,”100069”,R.CUSTOMER,F.CUS,CUS.ERR1)
F.READ always checks if the record is in cache. If yes, fetches the record from
the cache, else retrieves the record from the databse.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
32
Record Returned By F.READ
Contents of R.CUSTOMER
DAOHENGBKDAO HENG BANK INCDAO HENG BANK INC119 ASIAN MANSION 209
DELA ROSA ST LEGASPI VILLAGE MAKATI CITY MAN PH 1111
908100999PH4 PH 20000101 20000101
1118_RICKBANAT1ÿ28_ANDREABARNES1000612104218_RI
CKBANAT1US00100011
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
33
Extract Values
R.CUSTOMER<1>
R.CUSTOMER<15>
What happens after an upgrade?
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
34
I_F.CUSTOMER File
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
35
Display Parts Of A Record
Y.MNEMONIC = R.CUSTOMER<EB.CUS.MNEMONIC>
Y.NATIONALITY = R.CUSTOMER<EB.CUS.NATIONALITY>
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
36
Display Parts Of A Record(Cont.)
CRT “Customer Id: “:Y.CUS.ID
CRT “Customer Mnemonic: “:Y.MNEMONIC
CRT “Customer Nationality: “:Y.NATIONALITY
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
37
Solution 2
*Subroutine to display the details of customer 100069
SUBROUTINE CUS.DISPLAY.DETAILS
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.CUSTOMER
GOSUB INIT
GOSUB OPENFILES
GOSUB PROCESS
RETURN
INIT:
FN.CUS = ‘F.CUSTOMER’
F.CUS = ‘’
Y.CUS.ID = 100069
Y.MNEMONIC = ‘’
Y.NATIONALITY = ‘’
R.CUSTOMER = ‘’
CUS.ERR1 = ‘’
RETURN
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
38
Solution 2 (Cont.)
OPENFILES:
CALL OPF(FN.CUS,F.CUS)
RETURN
PROCESS:
CALL F.READ(FN.CUS,Y.CUS.ID,R.CUSTOMER,F.CUS,CUS.ERR1)
Y.MNEMONIC = R.CUSTOMER<EB.CUS.MNEMONIC>
Y.NATIONALITY = R.CUSTOMER<EB.CUS.NATIONALITY>
CRT “Customer Id: “:Y.CUS.ID
CRT “Customer Mnemonic: “:Y.MNEMONIC
CRT ‘Customer Nationality: “:Y.NATIONALITY
RETURN
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
39
Solution 2
Compile and catalog the routine
– EB.COMPILE TRG.BP CUS.DISPLAY.DETAILS
Make an entry in the PGM.FILE with the type set to ‘M’.
Execute the routine from the command line.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
40
Debugging …….
See the execution of the routine line by line
Insert the ‘DEBUG’ statement anywhere in the routine
Subroutine to display the details of customer 100069
SUBROUTINE CUS.DISPLAY.DETAILS
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.CUSTOMER
GOSUB INIT
GOSUB OPENFILES
GOSUB PROCESS
RETURN
INIT:
DEBUG
FN.CUS = ‘F.CUSTOMER’
F.CUS = ‘’
Y.CUS.ID = 100069
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
41
Debugging……….
Source changed to BP/CUS.DISPLAY.DETAILS
0011 DEBUG
jBASE debugger->S
0012 FN.CUS = 'F.CUSTOMER'
jBASE debugger->S
0013 F.CUS = ''
jBASE debugger->S
0014 Y.CUS.ID = 1038
jBASE debugger->S
0015 Y.MNEMONIC = ''
jBASE debugger->S
---------------------------------------
---------------------------------------
0023 PROCESS:
jBASE debugger->V FN.CUS
FN.CUS : FBNK.CUSTOMER
jBASE debugger->V F.CUS
F.CUS : File '../mbdemo.data/st/FBNK.CUST000'
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
42
Workshop 2
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
43
Example 3
Modify example 2 to display the mnemonic and nationality of all the
customers
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
44
Algorithm
Step 1. Open the Customer File
Step 2. Select all the customer ids
Step 3. Remove one customer id from the selected list
Step 4. For the extracted customer id extract the
corresponding record from the customer file
Step 5. From the extracted record extract the mnemonic and
nationality
Step 6. Display the customer id, mnemonic and nationality
Repeat Steps 3 to 6 for all customers
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
45
Select
Assign the select statement to a variable
SEL.CMD = “SELECT “:FN.CUS
Note the space
Use the Globus subroutine EB.READLIST to execute the
select statement
Use SSELECT instead of SELECT if you want data in a
sorted order
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
46
EB.READLIST
CALL EB.READLIST(1,2,3,4,5)
1 - Select Statement To Be Executed
2 - A dynamic array that will hold the ids of all records
selected, separated by field markers.
3 - File that will hold the results of the select
statement(Optional)
4 - Variable that will hold the number of records
selected
5 - Return Code
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
47
EB.READLIST (Cont.)
CALL EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.REC,RET.CODE)
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
48
Insight Into EB.READLIST – Execute Select
SEL.CMD = “SELECT “:FN.CUS:” WITH SECTOR > 1000”
CALL EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.REC,RET.CODE)
How does EB.READLIST execute this SELECT statement?
Picks up the SELECT statement
Performs an ‘EXECUTE SEL.CMD’ and store the output
on to SEL.LIST
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
49
Insight Into EB.READLIST - Internal Select
SEL.CMD = “SELECT “:FN.CUS
CALL EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.REC,RET.CODE)
How does EB.READLIST execute this SELECT statement?
Picks up the SELECT statement
Realizes that there are no conditions and no sorted select
in SEL.CMD
Performs an OPF for the file that you wish to select
CALL OPF(FN.CUS.F.CUS)
Performs ‘SELECT F.CUS’
– This is faster than ‘EXECUTE SEL.CMD’ as it is not actually
selecting the file
– It is only positioning the file pointer to the start of the file and then
will extract one ID after another and store it in SEL.LIST
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
50
Insight Into EB.READLIST - Internal Select
Use the facility of internal select in EB.READLIST when
– You wish to process most of the records of a file
– You do not want records in a sorted order
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
51
Repeating A Set Of Statements
Use LOOP and REMOVE(Discussed Earlier) to repeat
Steps 3 to 6
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
52
Solution 3
*Subroutine to display the mnemonic and nationality of all customers
SUBROUTINE CUS.DISPLAY.DETAILS
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.CUSTOMER
DEBUG
GOSUB INIT
GOSUB OPENFILES
GOSUB PROCESS
RETURN
INIT:
FN.CUS = 'F.CUSTOMER'
F.CUS = ''
Y.CUS.ID = ''
R.CUSTOMER = '‘
CUS.ERR1 = ''
Y.MNEMONIC = ''
Y.NATIONALITY = ''
SEL.CMD = ''
SEL.LIST = ''
NO.OF.REC = 0
RET.CODE = ''
RETURN
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
53
Solution 3 (Contd.)
OPENFILES:
CALL OPF(FN.CUS,F.CUS)
RETURN
PROCESS:
SEL.CMD = "SELECT ":FN.CUS
CALL EB.READLIST(SEL.CMD,SEL.LIST,'',NO.OF.REC,RET.CODE)
LOOP
REMOVE Y.CUS.ID FROM SEL.LIST SETTING POS
WHILE Y.CUS.ID:POS
CALL F.READ(FN.CUS,Y.CUS.ID,R.CUSTOMER,F.CUS,CUS.ERR1)
Y.MNEMONIC = R.CUSTOMER<EB.CUS.MNEMONIC>
Y.NATIONALITY = R.CUSTOMER<EB.CUS.NATIONALITY>
CRT "Customer Id: ":Y.CUS.ID
CRT "Customer Mnemonic: ":Y.MNEMONIC
CRT "Customer Nationality: ":Y.NATIONALITY
REPEAT
RETURN
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
54
Solution 3
Add a DEBUG statement in the routine
Compile and catalog the routine
Make an entry in the PGM.FILE with the type set to ‘M’.
Execute the routine from the command line.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
55
Workshop 3
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
56
Example 4
Amend example 3 to store the extracted all the customer Ids, their
mnemonics and nationalities in a dynamic array in the following
format
CusId*Mnemonic*NationalityFMCusId*Mnemonic*Nationality
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
57
Algorithm
Step 1. Open the Customer File
Step 2. Select all the customer ids
Step 3. Remove one customer id from the selected list
Step 4. For the extracted customer id extract the
corresponding record from the customer file
Step 5. From the extracted record extract the
mnemonic and nationality
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
58
Algorithm
Step 6. Store the customer id, mnemonic and the
nationality in a dynamic array
Repeat Steps 3 to 6 for all customers
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
59
Append Data In An Array
ARRAY<-1> = NewValue
ARRAY<-1> = Y.CUS.ID:’*’:Y.MNEMONIC:’*’:Y.NATIONALITY
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
60
Append Data In An Array (Cont.)
What if an array delimited with VM’s need to formed?
ARRAY<1,-1> = Value
What if an array delimited with SM’s need to be formed?
ARRAY<1,1,-1> = Value
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
61
Solution 4
*Subroutine to store the id, mnemonic and nationality of all *customers in an array
SUBROUTINE CUS.DISPLAY.DETAILS
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.CUSTOMER
GOSUB INIT
GOSUB OPENFILES
GOSUB PROCESS
RETURN
INIT:
FN.CUS = 'F.CUSTOMER'
F.CUS = ''
Y.CUS.ID = '‘
R.CUSTOMER = ''
CUS.ERR1 = ''
Y.MNEMONIC = ''
Y.NATIONALITY = ''
SEL.CMD = ''
SEL.LIST = ''
NO.OF.REC = 0
RET.CODE = ''
CUS.DETAILS.ARRAY = ''
RETURN
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
62
Solution 4 (Cont.)
OPENFILES:
CALL OPF(FN.CUS,F.CUS)
RETURN
PROCESS:
SEL.CMD = "SELECT ":FN.CUS
CALL EB.READLIST(SEL.CMD,SEL.LIST,'',NO.OF.REC,RET.CODE)
LOOP
REMOVE Y.CUS.ID FROM SEL.LIST SETTING POS
WHILE Y.CUS.ID:POS
CALL F.READ(FN.CUS,Y.CUS.ID,R.CUSTOMER,F.CUS,CUS.ERR1)
Y.MNEMONIC = R.CUSTOMER<EB.CUS.MNEMONIC>
Y.NATIONALITY = R.CUSTOMER<EB.CUS.NATIONALITY>
CUS.DETAILS.ARRAY<-1> =
Y.CUS.ID:'*':Y.MNEMONIC:'*':Y.NATIONALITY
REPEAT
RETURN
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
63
Solution 4
Add a DEBUG statement in the routine
Compile and catalog the routine
Make an entry in the PGM.FILE with the type set to ‘M’.
Execute the routine from the command line.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
64
Workshop 4
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
65
Example 5
• As a part of the COB process in T24, all savings accounts that
have balance less than 5000 need to be charged a fee. For this
purpose you are expected to create a local reference field by
name CHARGE in the Account application and write a
subroutine that will check the working balance of all savings
accounts, and if the working balance is lesser than 5000 then set
the value in the local reference field CHARGE to ‘Y’. As a part of
the COB process in T24, one of the COB routines will deduct a
charge from all accounts which have this field set to ‘Y’.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
66
Algorithm
Step 1 . Create the local reference field CHARGE using
the LOCAL.TABLE application and attach it to the
ACCOUNT application using the LOCAL.REF.TABLE
application.
Step 2. Open the ACCOUNT file
Step 3.Select all accounts with category = 6001(this
category might differ from one Globus installation to
another).
Step 4.For each of the accounts selected, read the
corresponding record from the ACCOUNT file
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
67
Algorithm (Cont.)
Step 4. Check the working balance of the account
and if the balance is less than 5000 then write the
entire ACCOUNT record into the ACCOUNT file with
the local reference field CHARGE set to ‘Y’
Step 5.Update the F.JOURNAL file.
Repeat steps 3 to 5 for all accounts using the LOOP
and REPEAT statements.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
68
Update a local reference field
R.ACCOUNT<AC.LOCAL.REF,1> = ‘Y’
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
69
Write into a hashed file
CALL F.WRITE(FN.ACC,Y.AC.ID,R.ACCOUNT)
• Parameters :
– File name
– Record Id
– Record to be written
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
70
Update the F.JOURNAL file
CALL JOURNAL.UPDATE(Y.AC.ID)
• Online Mode : F.WRITE to be followed by JOURNAL.UPDATE
• Batch Mode : F.WRITE should not be followed by
JOURNAL.UPDATE as the F.JOURNAL file is not available
during EOD.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
71
Solution 5
*Subroutine to check if the balance in all savings accounts are less than 5000 and if so,
*update a local reference field in the ACCOUNT file called CHARGE to ‘Y’.
SUBROUTINE ACC.BAL.CHECK
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.ACCOUNT
GOSUB INIT
GOSUB OPENFILES
GOSUB PROCESS
INIT:
FN.ACC = ‘F.ACCOUNT’
F.ACC = ‘’
Y.ACC.ID = ‘’
R.ACCOUNT = ‘’
Y.ACC.ERR = ‘’
RETURN
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
72
Solution 5
OPENFILES:
CALL OPF(FN.ACC,F.ACC)
RETURN
PROCESS:
SEL.CMD = “SELECT “:FN.ACC:” WITH CATEGORY = 6001”
CALL EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.REC,RET,CODE)
LOOP
REMOVE Y.ACC.ID FROM SEL.LIST SETTING POS
WHILE Y.ACC.ID:POS
CALL F.READ(FN.ACC,Y.ACC.ID,R.ACCOUNT,F.ACC,Y.ACC.ERR)
IF R.ACCOUNT<AC.WORKING.BALANCE> < 5000 THEN
R.ACCOUNT<AC.LOCAL.REF,1> = ‘Y’
CALL F.WRITE(FN.ACC,Y.ACC.ID,R.ACCOUNT)
CALL JOURNAL.UPDATE(Y.ACC.ID)
END
Y.ACC.ID = ‘’
R.ACCOUNT = ‘’
REPEAT
RETURN
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
73
What if another user updates the same Account record while you
are trying to update?
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
74
Always read and lock a record if you wish to update it.
Can F.READ, read and lock a record?
No. It can only read.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
75
F.READU
Use F.READU
Similar to F.READ
Read and lock a record
The lock will be released when
– The record is written back to the file
– There is an explicit RELEASE statement after obtaining the lock
– The routine terminates
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
76
F.READU
CALL F.READU(1,2,3,4,5,6)
1 – File Name
2 – ID
3 – Record
4 – File variable
5 – Error variable
6 – Retry Option
– P msg - prompt user with msg to retry if record locked
– R nn xx - retry xx times with a nn seconds sleep interval
– I - ignore the lock and return
– E - return immediately with an error message
– ‘’ – Retry continuously
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
77
Code With F.READU
PROCESS:
SEL.CMD = “SELECT “:FN.ACC:” WITH CATEGORY = 6001”
CALL EB.READLIST(SEL.CMD,SEL.LIST,’’,NO.OF.REC,RET,CODE)
LOOP
REMOVE Y.ACC.ID FROM SEL.LIST SETTING POS
WHILE Y.ACC.ID:POS
CALL F.READU(FN.ACC,Y.ACC.ID,R.ACCOUNT,F.ACC,Y.ACC.ERR,’’)
IF R.ACCOUNT<AC.WORKING.BALANCE> < 5000 THEN
R.ACCOUNT<AC.LOCAL.REF,1> = ‘Y’
CALL F.WRITE(FN.ACC,Y.ACC.ID,R.ACCOUNT)
JOURNAL.UPDATE(Y.ACC.ID)
END
Y.ACC.ID = ‘’
R.ACCOUNT = ‘’
REPEAT
RETURN
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
78
Solution 5
Add a DEBUG statement in the routine
Compile and catalog the routine
Make an entry in the PGM.FILE with the type set to ‘M’.
Execute the routine from the command line.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
79
Are there better ways to read data from a file?
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
80
CACHE.READ
Used to read data from the cache.
– It checks if the record is in cache
– If yes, retrieves it from the cache
– Else, does a OPF and F.READ to fetch the record and loads it in
the cache
– Will not pick up records from cache if they are more than
<SPF->CACHE.EXPIRY> seconds old.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
81
CACHE.READ (Cont.)
Doesn’t F.READ also perform a similar operation?
When should I use CACHE.READ ?
Use CACHE.READ when
– The record that you retrieve will not be frequently updated
– Best used for retrieving parameter records
– It is faster than F.READ as it does not require a call to OPF.
• Only when the record is not available in cache, it will perform
an OPF
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
82
CACHE.READ (Cont.)
CACHE.READ(FileName,ID,Record,Error)
FILENAME = Name of file - without the mnemonic
(Example : F.CUSTOMER)
ID = Valid values are
ID of a record
‘SelectIDs‘ (List of Ids from the ‘FileName’)
‘SSelectIDs’ (List of sorted Ids)
‘SSelectARs’ (List of sorted Ids in ascending order right justified)
Record = Data returned
Error = RECORD NOT FOUND for example
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
83
CACHE.READ (Cont.)
When
ID is passed to CACHE.READ
– Check if it exists in cache else will read from disk and load it to
cache
If ‘SelectIDs’ is passed to CACHE.READ
– Perform a call to EB.READLIST. Since there are no conditions
and it is not a sorted select, an internal selected will be
executed
If ‘SSelectedID’ or ‘SSelectARs’ is passed
– Perform a call to EB.READLIST. Since it is sorted select, will
actually select the file
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
84
Insight Into Reading And Writing Records
READ
F.READ
F.READU
F.READV
DBR
TRANS
WRITE
F.WRITE
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
85
Important T24 Routines
OVERLAY.EX
FATAL.ERROR
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
86
Workshop 5
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
87
Example 6
Write a program that will write a string “Infobasic programming” onto
a sequential file.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
88
Algorithm
Step1 . Create a non hashed file with the name
“TEMENOS.SEQ”
CREATE.FILE TEMENOS.SEQ TYPE=UD
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
89
Algorithm (Cont.)
Step 2. Open the non hashed file
OPENSEQ filename,recordid to pointer
OPENSEQ SEQ.FILE.NAME,RECORD.NAME TO SEQ.FILE.POINTER
Parameters:
SEQ.FILE.NAME = ‘TEMENOS.SEQ’
RECORD.NAME = ‘1’
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
90
Opening A Sequential File
OPENSEQ SEQ.FILE.NAME,RECORD.NAME TO SEQ.FILE.POINTER ELSE
CREATE SEQ.FILE.POINTER ELSE
CRT “Unable to create file pointer to file “:SEQ.FILE.NAME
STOP
END
END
CRT “Openseq was successful on file “:SEQ.FILE.NAME
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
91
Algorithm (Cont.)
Step 4 :Close the file once the operations are complete.
Use the CLOSESEQ command to close a
sequential file.
CLOSESEQ FilePointer
CLOSESEQ SEQ.FILE.POINTER
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
92
Solution 6
PROGRAM SEQFILE.ACCESS.WRITE
SEQ.FILE.NAME = ‘TEMENOS.SEQ’
RECORD.NAME = ‘1’
OPENSEQ SEQ.FILE.NAME,RECORD.NAME TO SEQ.FILE.POINTER ELSE
CREATE SEQ.FILE.POINTER ELSE
CRT “Unable to create file pointer to file “:SEQ.FILE.NAME
STOP
END
END
CRT “Openseq was successful on file “:SEQ.FILE.NAME
WRITESEQ “Infobasic programming” TO SEQ.FILE.POINTER ELSE
CRT “Unable to perform WRITESEQ”
END
CLOSESEQ SEQ.FILE.POINTER
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
93
Workshop 6
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
94
Example 7
Write a program that will read the data that has been written on to
the sequential file TEMENOS.SEQ .
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
95
Algorithm
Step 1 : Open the sequential file
Step 2 : Read the data from the sequential file and display it
Step 3 : Close the sequential file
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
96
Reading A Sequential File
READSEQ
READSEQ is the command that is used to read the data from a
sequential file.
READSEQ variablename FROM filepointer THEN …… ELSE…..
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
97
Reading A Sequential File
READSEQ Y.MSG FROM SEQ.FILE.POINTER THEN
CRT “Message Extracted :”:Y.MSG
END
ELSE
CRT “Unable to read from file “
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
98
Solution 7
PROGRAM SEQFILE.ACCESS.READ
SEQ.FILE.NAME = ‘TEMENOS.SEQ’
RECORD.NAME = ‘1’
OPENSEQ SEQ.FILE.NAME,RECORD.NAME TO SEQ.FILE.POINTER ELSE
CREATE SEQ.FILE.POINTER ELSE
CRT “Unable to create file pointer to file “:SEQ.FILE.NAME
STOP
END
END
CRT “Openseq was successful on file “:SEQ.FILE.NAME
READSEQ Y.MSG FROM SEQ.FILE.POINTER THEN
CRT “Message Extracted :”:Y.MSG
END
ELSE
CRT “Unable to read from file “
END
CLOSESEQ SEQ.FILE.POINTER
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS SA
99
More On OPENSEQ
An OPENSEQ command can also be used to open a file
provided along with the path of the file and the id.
SEQ.FILE.NAME = ‘./TEMENOS.SEQ/1’
OPENSEQ SEQ.FILE.NAME TO SEQ.FILE.POINTER
All the other WRITESEQ, READSEQ, CLOSESEQ
statements will remain the same.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS 100
SA
Workshop 7
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS 101
SA
Subroutines With Arguments
Subroutines can take in any number of parameters
Subroutines can return any number of values
When defining a subroutine, the parameters for that
subroutine are defined
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS 102
SA
Example 8 And Solution 8
Create a subroutine that will accept 2 integer
values, multiply them and return the result in a variable.
SUBROUTINE DEMO.CALLED.RTN(ARG.1,ARG.2,ARG.3)
ARG.3 = ARG.1 * ARG.2
RETURN
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS 103
SA
Solution 8 (Cont.)
Step 2
Create another subroutine that would supply the values and call the
DEMO.CALLELD.RTN.
SUBROUTINE DEMO.CALLING.RTN
VAR.1 = 10
VAR.2 = 20
VAR.3 = ‘’
CALL DEMO.CALLED.RTN(VAR.1,VAR.2,VAR.3)
PRINT ‘Result “:VAR.3
RETURN
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS 104
SA
Defining Functions
Functions can be created in infobasic using the
FUNCTION statement
Functions can taken in any number of arguments
Functions can and will return only one value using the
RETURN statement
Functions can be defined in a subroutine before it is
called using the DEFFUN function
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS 105
SA
Example 9 And Solution 9
Step 1
Create a function that will accept 2 integer values,
multiply them and return the result in a variable.
FUNCTION DEMO.FUNCTION(ARG.1,ARG.2)
RET.VALUE = ARG.1 * ARG.2
RETURN(RET.VALUE)
END
The RETURN statement is used to return a value in a
function.
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS 106
SA
Solution 9 (Cont.)
Step 2
Create a subroutine that will call the function DEMO.FUNCTION.
SUBROUTINE DEMO.SUB.CALLING.RTN
VAR.1 = 10
VAR.2 = 20
DEFFUN DEMO.FUNCTION(VAL.1,VAL.2)
VAR.3 = DEMO.FUNCTION(VAR.1,VAR.2)
CRT “Result :”:VAR.3
RETURN
END
T2BTT – R06 – 1.0 Copyright 2005 TEMENOS HEADQUARTERS 107
SA