In This Learning Unit, You Are Going To Learn About T24 API's
In This Learning Unit, You Are Going To Learn About T24 API's
1
At the end of this session, you will be able to use the following API
F.READ, F.MATREAD,
F.READU, F.MATREADU
F.WRITE , F.MATWRITE
F.DELETE
CDT, CDD
EXCHRATE
2
Here is the list of API’s used to read from a database.
Once the data is read from the database the transaction cache is
updated, such that further access will be done through the cache.
F.READ wraps the jbc command READ
F.READU wraps the jbc command READU
F.MATREAD wraps the jbc command MATREAD
F.MATREAD wraps the jbc command MATREADU
3
4
Here you can see an example about how to program using T24 API’s.
5
Note: MAT is a keyword
6
Here you can see an example about how to program using T24 API’s.
This example demonstrates about how to read to a dimensioned array.
7
What is record locking?
Assume you open a record 101024 in the CUSTOMER application
using function ‘I’. Will someone else be able to open the same record
using function ‘I’ at the same time? NO.
How do we ensure that two people don’t open the same record at the
same time? This is achieved using the concept of record locking.
Whenever an application (T24 in our case) instructs the database
(jBASE in our case) that it wishes to have exclusive access to a record
(This is achieved using functions I,A,D and R), the database, marks that
particular record for exclusive access and then releases it to the user.
This record remains locked until the time,
a) The record is written back into the file
b) The record is deleted
c) The program in the application that asked for the lock either
terminates normally or abnormally
d) The program in the application that asked for the lock explicitly says
‘RELEASE’ so that the lock can get released
e) All locks held within a transaction are released after the transaction
is committed or aborted
8
Almost all the parameters are self explanatory, except for, the last
parameter of F.READU. It is used to inform, about what to do if the
record is locked.
And it can take any one of the following values:
P msg - Prompt the user with 'msg' if the record is locked. The default if
'msg' is null is 'xxxxx FILE id RECORD LOCKED - RETRY Y/N'
R nn xx - Retry xx times with a sleep interval of nn seconds. If xx is not
specified the record is continually retried.
I - Ignore the lock (The record variable is left blank)
E - Return immediately with an error message
Null - Retry continuously with a sleep interval of one second
9
Almost all the parameters are self explanative, except for, the last
parameter of F.MATREADU. It is used to inform, about what to do if the
record is locked.
And it can take any one of the following values:
P msg - Prompt the user with 'msg' if the record is locked. The default if
'msg' is null is 'xxxxx FILE id RECORD LOCKED - RETRY Y/N'
R nn xx - Retry xx times with a sleep interval of nn seconds. If xx is not
specified the record is continually retried.
I - Ignore the lock (The record variable is left blank)
E - Return immediately with an error message
Null - Retry continuously with a sleep interval of one second
10
Steps:
1. Open the file customer
2. Read the specific customer record
3. Retrieve the required data
4. Display the data.
11
Here is the list of API’s that could be used to write to a transaction
cache.
Note:
Writes happen at cache level. And there should be a mechanism to
flush the data into database. This mechanism is taken care by T24
itself. And the way the data is flushed to database is not discussed
here. Therefore if you try to write to the database, then the changes
may not be reflected in the database.
12
13
Note: MAT is a keyword
14
A lock will get released when,
1. An write is executed on the record that has been locked
2. If within a transaction block, write will not release the lock. Once the
transaction is complete, the lock gets released.
3. When a transaction comes to an end all locks get released
1. Internally calls the jBC command RELEASE
2. RELEASE <filename> releases all locks on the given file held by
current session
4. The API F.RELEASE is used.
Word of Caution
1. Use this API if the record is read with lock, but the no write had
happened.
2. If no record key is specified – All locks on the file name
specified are released
3. If no file name is specified, all locks are released (Online only)
15
This API is used to delete a record from cache. This routine takes in two
parameters – Filename and record id. The record is physically deleted
at the end of transaction block.
Note:
Deletes happens at cache level, and there should be a mechanism to
update the changes to the database. This mechanism is taken care by
T24 itself. And the same not discussed here.
16
CDT - Calculates forward or previous date from a start date using the number
of days. In this API the last parameter takes the no.of.days that has to be
added or subtracted from the given date. For ex.,
TRANS.DATE=20110301
CALL CDT(‘’, TRANS.DATE, ‘+5W’)
The above example computes a date that is 5 working days later than the
current date and the result will be stored in TRANS.DATE variable.
Note: The no.of.days specified could be working days (W) or calendar days (
C)
17
CDD - Calculates the difference, in days, between two supplied dates. In this
API the last parameter is an input as well as output parameter. Do not pass
the last parameter as a constant. For ex.,
This above example finds the difference between the dates and the result can
be positive or negative.
18
19
1.OPF
2. P msg - Prompt the user with 'msg' if the record is locked. The
default if 'msg' is null is 'xxxxx FILE id RECORD LOCKED - RETRY
Y/N'
R nn xx - Retry xx times with a sleep interval of nn seconds. If xx is not
specified the record is continually retried.
I - Ignore the lock (Record is left blank)
E - Return immediately with an error message
Null - Retry continuously with a sleep interval of one second
3. F.READ
4. FWT holds the ID list.
FWC holds the corresponding record.
20
Now you will be able to use
F.READ, F.MATREAD,
F.READU, F.MATREADU
F.WRITE , F.MATWRITE
F.DELETE
CDT, CDD
EXCHRATE
21
22