PRG2.Infobasic Programming Advanced
PRG2.Infobasic Programming Advanced
PRG2.Infobasic Programming Advanced
No part of this document may be reproduced or transmitted in any form or by any means,
electronic or mechanical, for any purpose, without the express written permission of TEMENOS Holdings NV.
Published by:
Temenos Training Publications
Temenos Corporate Education Centre,
Temenos India Private Ltd,
No.146, Sterling Road, Nungambakkam, Chennai: 600 034, INDIA.
Ph: +91 44 2822 2001. E-mail: indtr@temenos.com
Authoring Contributions:
Alagammai Palaniappan (First Edition, 2001) – Temenos India Private Ltd.
Thankful Acknowledgements:
Temenos Corporate Training Team
Warning: This document is protected by copyright law and international treaties. No part of this
document may be reproduced or transmitted in any form or by any means, electronic or mechanical,
for any purpose, without the express written permission of TEMENOS Holdings NV Unauthorized
reproduction or distribution of this presentation or any portion of it, may result in severe civil and
criminal penalties, and will be prosecuted to the maximum extent possible under applicable law.”
Information in this document is subject to change without notice.
Trademarks
jBASE®, jBC, jEDI, TM and TM are registered trademarks of TEMENOS Holdings NV in Switzerland
and other countries.
UNIX is a registered trademark of The Open Group. All other trademarks and copyrights mentioned herein may
be the trademarks or registered trademarks of their respective owners.
Table of Content
Preface................................................................................................................................................... 6
Scope of this document...................................................................................................................... 6
Who should read this.......................................................................................................................... 6
Conventions Used............................................................................................................................... 6
Software and their versions................................................................................................................ 6
Example 1.............................................................................................................................................. 7
Solution 1............................................................................................................................................ 7
Algorithm......................................................................................................................................... 7
Step 1.............................................................................................................................................. 7
Steps 2 And 3.................................................................................................................................. 7
Step 4.............................................................................................................................................. 7
F.READU......................................................................................................................................... 7
Step 5.............................................................................................................................................. 8
F.WRITE.......................................................................................................................................... 8
Step 6.............................................................................................................................................. 9
Consolidated Solution 1................................................................................................................ 10
An Insight Into Reading And Writing In T24.......................................................................................... 11
CACHE.READ.................................................................................................................................. 14
Important T24 Routines........................................................................................................................ 15
OVERLAY.EX.................................................................................................................................... 15
FATAL.ERROR................................................................................................................................. 15
Writing Data...................................................................................................................................... 15
Creating Subroutines With Arguments.................................................................................................. 16
Example 2......................................................................................................................................... 16
Step 1............................................................................................................................................ 16
Step 2............................................................................................................................................ 16
Defining Functions In Infobasic............................................................................................................. 17
Example 3......................................................................................................................................... 17
Step 1............................................................................................................................................ 17
Step 2............................................................................................................................................ 17
Additional Information........................................................................................................................... 18
LOCATE............................................................................................................................................ 18
F.DELETE......................................................................................................................................... 19
Infobasic Commands........................................................................................................................ 19
MATREAD..................................................................................................................................... 19
MATWRITE................................................................................................................................... 19
CONVERT..................................................................................................................................... 20
DELETE........................................................................................................................................ 20
Preface
Conventions Used
– Features available in the latest available T24 release release are prefixed
with a symbol.
– Information requiring special attention are marked in italics and prefixed with
a symbol.
Example 1
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’.
Solution 1
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 T24 installation to
another).
Step 4.For each of the accounts selected, read the corresponding record from the ACCOUNT file
Step 5.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 6.Update the F.JOURNAL file.
Repeat steps 3 to 5 for all accounts using the LOOP and REPEAT statements.
Step 1
Create the local reference filed CHARGE in the ACCOUNT application using the LOCAL.TABLE and
the LOCAL.REF.TABLE applications.
Steps 2 And 3
As discussed earlier use OPF and EB.READLIST.
Step 4
Now we need to read the record from the ACCOUNT file. Normally we would use the F.READ
statement to read a record from a file. But we need to understand that , when we read a record, we
only obtain a shared lock on the record and hence multiple people can read the record simultaneously.
Since the record that we are to read by might updated by us, we need to ensure that we have
exclusive control over the record. Hence we need to use F.READU instead of F.READ.
F.READU
Parameters
FILEID file name
KEY record-id
REC record returned
F.FILEID file variable
ER returning error message
TEMENOS Training Publications Page 7 of 20 Copyright © 2006 TEMENOS HEADQUARTERS SA
2007.1
PRG2 – Infobasic Programming
Step 5
Once the working balance has been extracted and is found to be lesser then 5000, now the local
reference field CHARGE needs to be set to ‘Y’ and the entire account record needs to be written on to
the ACCOUNT file.
R.ACCOUNT<AC.LOCAL.REF,1> = ‘Y’.
Note that there is just one physical field called LOCAL.REF in most of the applications in T24. By
using LOCAL.TABLE and the LOCAL.REF.TABLE applications, we are just multi-valuing the field
LOCAL.REF and giving the new multi value field a new name. Therefore, once a local reference field
is created, it would not affect the physical layout of the file(would not affect the dict) but will only affect
the STANDARD.SELECTION. All local reference fields will have an entry in the SS application with the
Usr Type set to ‘I’ – I descriptor.
F.WRITE
F.WRITE is a core T24 subroutine that is used to write a record on to a file.
When the system is in the Online mode, as mentioned earlier, the write will only happen to the cache.
It is only when a subsequent call to JOURNAL.UPDATE is encountered, the data will be flushed to the
disk.
JOURNAL.UPDATE is a core T24 routine that takes care of updating the F.JOURNAL file and also
ensures transaction management. Please note that JOURNAL.UPDATE, if called when the system is
in Batch mode, will not update the JOURNAL file.
Transaction management can be explicitly triggered in T24 using the EB.TRANS routine.
Statement 1
Statement 2
Statement 3
CALL EB.TRANS(“END”, ‘End of transaction block”)
If it any point within a transaction block the transaction needs to aborted, the T24 subroutine
TRANSACTION.ABORT can be called.
CALL TRANSACTION.ABORT
Syntax
F.WRITE(<filename>,<id of record>,<dynamic record variable>)
Example
CALL F.WRITE(FN.ACC,Y.AC.ID,R.ACCOUNT)
Step 6
Use the T24 subroutine JOURNAL.UPDATE to update the F.JOURNAL file.
CALL JOURNAL.UPDATE(Y.AC.ID)
Note
While writing subroutines that would get executed during the Online stage of T24, a call to F.WRITE
will fail if it does not find a subsequent call to JOURNAL.UPDATE. During the batch stage, since the
F.JOURNAL file is not maintained, a call to F.WRITE does not require a subsequent call to
JOURNAL.UPDATE.
Consolidated Solution 1
*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.AC.ID = ‘’
R.ACCOUNT = ‘’
Y.ACC.ERR = ‘’
RETRY = ‘’
RETURN
OPENFILES:
CALL OPF(FN.ACC,F.ACC)
RETURN
PROCESS:
SEL.CMD=“SELECT “:FN.ACC:” WITH CATEGORY=6001 AND WORKING.BALANCE < 5000”
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,RETRY)
R.ACCOUNT<AC.LOCAL.REF,1> = ‘Y’
CALL F.WRITE(FN.ACC,Y.ACC.ID,R.ACCOUNT)
Y.AC.ID = ‘’
R.ACCOUNT = ‘’
REPEAT
In the above example, F.WRITE is called within a loop and JOURNAL.UPDATE is called outside the
loop. In this case the system is in Online mode and hence all the writes triggered by F.WRITE would
happen only to the cache. It is only when the control comes out of the loop the data from the cache will
actually get flushed to the disk. Care should be taken when calling F.WRITE within a loop – it might
lead to using up all the cache.
Note: Use JOURNAL.UPDATE cautiously. Only mainline routines like the one above will need a call to
JOURNAL.UPDATE. When routines are attached to T24, T24 itself will make a call to
JOURNAL.UPDATE
Working of F.READ
1. Obtain the file name and the record id
2. Perform SMS validations
3. Check if the record is in cache. If it is in cache, will fetch it
4. If it is not in cache, read from the file in the disk and load the record into cache
Working of F.READU
1. Obtain the file name and record id
2. Perform SMS validations
3. Check if the record is in cache and if so, check if it is locked. If not locked, go to the disk and
lock it
4. If the record is not in cache, read and lock the record from the disk
F.READU holds info of all record locks so that they can be released during a transaction abort.
Whenever we lock a record using F.READU, the lock gets released when
a. That record is written back to the file
b. When the program terminates
c. When an explicit RELEASE statement is encountered
TEMENOS Training Publications Page 11 of 20 Copyright © 2006 TEMENOS HEADQUARTERS SA
2007.1
PRG2 – Infobasic Programming
In T24, in many routines, even if there is no explicit RELEASE statement, the locks get releases. This
is because of the RELEASE statement in JOURNAL.UPDATE.
Working of F.READV
Similar to F.READU, but fetches only one field of the record unlike F.READ that fetches the whole
record.
READ: Extract data from a file. F.READ and F.READV call READ internally to extract data. Always use
F.READ, F.READU or F.READV to extract data. Never use READ.
READ <Record> FROM <File Name>, <ID> ELSE <Message>
READ REC FROM F.FL, ID ELSE GOSUB “Record Not Found”
READU: Extract data from a file and lock it. F.READU internally calls this to extract data.
READU <Record> FROM <File Name>, <ID> ELSE <Message>
READU REC FROM F.FL, ID ELSE GOSUB CRT “Record Not Found”
Please note, when we use READ or READU, we need to specify the actual name of the file that we
are to open, as OPF is not called to open the file.
OPEN <File Name> TO <File Variable> ELSE ABORT
OPEN “FBNK.CUSTOMER” TO F.FL ELSE ABORT
Outgoing Parameters:
CALL DBR(<FileName:FM:FldToBeFetched:FM:”LangSpecFld”>,<ID>,<RetVar>)
CALL DBR(“CUSTOMER”:FM:EB.CUS.SHORT.NAME:FM:”L”:,100069,Y.RET.VAL)
All the above routines are core T24 routines that can be used to extract data from T24. All these
routines in-turn have to call Infobasic commands to actually obtain data. Following are the various
Infobasic commands that can be used to extract data.
CACHE.READ
CACHE.READ is a routine that is used to read a record from a file in T24. CACHE.READ will
Check if the record required is in cache
Is yes, check if it is not older than the number of seconds specified in the field
CACHE.EXPIRY in SPF. If not older, extract the record and return to the user
Else will perform F.READ to extract the record
Load the extracted record on to cache
Return the record to the user.
CACHE.READ(FileName,ID,Record,Error)
CALL OVERLAY.EX
FATAL.ERROR
Routine to display system errors, log them to the protocol file and exit. The text that needs to be
displayed as a fatal error needs to be set in the common variable TEXT. The FATAL.ERROR routine
takes in one parameter. This parameter can hold any value, but is usually set to the name of the file on
which the fatal error occurred.
TEXT = “Customer File Not Accessible”
CALL FATAL.ERROR(“CUSTOMER”)
The above command will result in updating a record in the PROTOCOL file with the ID : <UserName> .
This user name is the name of the user for whom the fatal error was generated.
Writing Data
We have already learnt that F.WRITE is used to write data on to T24. F.WRITE internally calls WRITE
to actually write.
WRITE <Record> ON <Filename>,<ID> ON ERROR <Message>
WRITE
Please note that when a WRITE is executed on a record that has been locked, the WRITE statement
will release the lock.
Always used F.WRITE to write records to the database.
Example 2
Step 1
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
While defining subroutines in Infobasic, we cannot specify which are the incoming and which are the
return parameters. Therefore just specify the arguments one after the other along with the subroutine
definition as done above. Since the subroutine is storing the result in the variable ARG.3, the system
would understand that ARG.3 is the return parameter.
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
Example 3
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
Step 2
Now the function defined above can be called from any program/subroutine. Now create a subroutine
that would supply values and call the above-defined function. When calling a function, the function
needs to be defined first using the DEFFUN command and only then the function should be called.
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
Incase of a function, only the incoming parameters need to be defined. There can and will be only one
return value and that will directly get assigned to the variable on the right side of the equation as
defined above.
Un-initialized variables VAL.1 and VAL.2 have been given to demonstrate that any variable can be
given at the time of defining a function.
Additional Information
LOCATE
LOCATE statement is used to locate the position of a string or determine the position to insert in to
maintain a specific sequence.
Syntax
LOCATE expr IN dynamic.array<FIELD,VALUE>,STARTPOS
BY sort.expr SETTING variable
THEN statements ELSE statements
Additional Information
Sort.Expr :
Example
DAYS = “MON:”FM:”TUE”:FM:”WED”:FM:”THU”:FM:”FRI”
LOCATE “WED” IN DAYS SETTING FOUND ELSE FOUND = 0
CRT “Position of WED in DAYS dynamic array :”:FOUND
LOCATE “SAT” IN DAYS BY “AL” SETTING POS ELSE
INS “SAT” BEFORE DAYS<POS>
END
CRT “Position where SAT has been inserted :”:POS
CRT “Days dynamic array after inserting SAT :”:DAYS
Output
F.DELETE
F.DELETE is also a core T24 subroutine that is used to delete a record from a file.
Syntax
F.DELETE(FileName,Id of the record to be deleted)
CALL F.DELETE(FN.CUS,Y.CUSID)
Infobasic Commands
MATREAD
MATREAD is a command that is used to read the contents of a dimensioned/dynamic array. You can
specify the id of the record to be picked up from the array. Incase the read is successful, then the
statements following the ‘THEN’ statements are executed else the statements following the ‘ELSE’
statement are executed.
Syntax
Example
MATRED Array1 from F.REGISTER.DETAILS,ID1 THEN ….. ELSE …..
The above statement will search for a record with id specified in the variable ID1, if found, it will
transfer the record to the array Array1.
MATWRITE
MATWRITE is used to build a dynamic array from a specified dimensioned array and write it to the file
opened to file.variable using a key of record.id.
Syntax
MATWRITE matrix ON file.variable,KEY
TEMENOS Training Publications Page 19 of 20 Copyright © 2006 TEMENOS HEADQUARTERS SA
2007.1
PRG2 – Infobasic Programming
Example
DIM ARRAY1(5)
MATREAD ARRAY1 FROM TEM1,101 ELSE
MAT ARRAY1 = ‘’
END
MATWRITE ARRAY1 ON TEM1,100
CONVERT
Use the CONVERT command to convert characters to other characters.
Y.STRING = “TEMENOSFMT24”
CONVERT FM TO VM IN Y.STRING
CRT Y.STRING
TEMENOSVMT24
DELETE
Use the DELETE command to delete a record. The F.DELETE T24 routine uses this statement to
delete a record.
DELETE <FileName>,<ID>