100% found this document useful (2 votes)
1K views22 pages

In This Learning Unit, You Are Going To Learn About T24 API's

This document provides an overview of the T24 API's that will be covered. It lists the API's F.READ, F.MATREAD, F.READU, F.MATREADU, F.WRITE, F.MATWRITE, F.DELETE, CDT, CDD, and EXCHRATE. It then provides examples and explanations of how to use each API to perform operations like reading from and writing to databases, handling record locking, and performing date calculations.

Uploaded by

Youness Azza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
1K views22 pages

In This Learning Unit, You Are Going To Learn About T24 API's

This document provides an overview of the T24 API's that will be covered. It lists the API's F.READ, F.MATREAD, F.READU, F.MATREADU, F.WRITE, F.MATWRITE, F.DELETE, CDT, CDD, and EXCHRATE. It then provides examples and explanations of how to use each API to perform operations like reading from and writing to databases, handling record locking, and performing date calculations.

Uploaded by

Youness Azza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

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.

From STANDARD.SELECTION record for ACCOUNT we can find out


the position of CUSTOMER.ID, ACCOUNT.BALANCE and CURRENCY
in ACCOUNT application

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

Note: MAT is a keyword

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

Note: MAT is a keyword

10
Steps:
1. Open the file customer
2. Read the specific customer record
3. Retrieve the required data
4. Display the data.

After writing the subroutine, create an entry in PGM.FILE for this


subroutine as main line routine and execute it from T24.

11
Here is the list of API’s that could be used to write to a transaction
cache.

F.WRITE wraps the jBC command WRITE.


F.MATWRITE wraps the jBC command MATWRITE

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.,

DAYS = ‘C’ ; * to find the difference in Calendar days or Working days


CURRDATE=20110303
TRANSDATE=20110309
CALL CDD(‘’,CURRDATE,TRANSDATE,DAYS)

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

You might also like