You are on page 1of 28

1. Welcome to the “Enquiry Routines” learning unit.

This learning unit will


enable you to understand the concept of creating enquiry routines in T24.
You will learn how to create and use Build and Conversion routines.

PRG6.Enquiry Routines-R09.01 1
After completing this learning unit, you will be able to:

•Explain different types of enquiry routines that can be attached to an enquiry


•Identify the stages where the enquiry routines would get executed
•Create Build and Conversion Routines

PRG6.Enquiry Routines-R09.01 2
1. A question that you ask T24 about its data is called an enquiry
2. In technical terms, it is a ‘SELECT’ statement executed in order to fetch data
from T24
3. A query to T24 is created using the ENQUIRY application
4. The output of the query can be displayed in any user defined format

PRG6.Enquiry Routines-R09.01 3
The flowchart will give you a clear idea on what happens behind the scenes when
you execute an ENQUIRY in T24.

1.The ENQUIRY.SELECT utility that is used to execute an enquiry in T24, first


picks up the application name from the field FILE.NAME
2.It will then read the STANDARD.SELECTION record of the application, locate the
given FIELD.NAME and create a list of IDs which satisfy the fixed selection if any.
3.Next it will apply the dynamic conditions specified in the selection criteria box to
the already selected list of IDs and will rebuild the list.
4.For each ID in the list, the corresponding record from the application is read.
5.Depending on the fields defined in the enquiry, the data is picked up and
displayed from left to right.

PRG6.Enquiry Routines-R09.01 4
Slide 4

SG2 A lot of emphasis has to be made on the working of the enquiry subsystem. The point that the enquiry
subsystem extracts and displays field by field has be made very clear as only then the delegates will
have a clear understanding of build and conversion routines
Sujoy Ghosh, 12/17/2007
1. Subroutines are similar to programs that enable users to read or write onto
single or multiple files.
2. Subroutines are executed from T24 by an internal call from an application,
version or from the command line.
3,4. ENQUIRY application enables user defined subroutines to be attached at
different stages to display the data in user defined format. When you enquire
T24 on an application, the data is gathered and displayed in its own format. But
what if the client wants to display the data in their own format? Can T24 do
this? No.
However, you can achieve this by writing an enquiry routine and attaching it to the
ENQUIRY record.

An example will make things clear as to why you would need an enquiry routine. If
you enquire T24 to display the CUSTOMER record whose MNEMONIC is ‘TEST’, it
would pick up all the records with MNEMONIC set to TEST and will display it in its
own format. But what if you do not want to display all the fields from the result
records but only ID, MENMONIC, SECTOR, LANGUAGE, TARGET and
NATIONALITY? T24 cannot do it by itself but only with the help of enquiry routines.

PRG6.Enquiry Routines-R09.01 5
1. Subroutines that are attached to the ENQUIRY application are called as
Enquiry Routines. There are two types of enquiry routines namely BUILD
ROUTINES and CONVERSION ROUTINES.
2. Build Routines are used to manipulate the selection criteria box. Why do you
need a routine to be attached to an enquiry, when you can directly specify fixed
and dynamic selection to extract required data? You can understand the need
for a build routine better with the help of an example.
To understand the need and use of a build routine, consider this requirement. The
bank wants to create an enquiry on the ACCOUNT application with fixed selection
set to ‘CATEGORY EQ 1001’. The SECTOR field is one of the dynamic selection
criteria. But the bank does not want to display records whose
WORKING.BALANCE is not in the range 50000 to 100000 if the SECTOR entered
is 6001 in the dynamic selection box. In other words, what they require is that an
additional dynamic selection criteria is added but without user input.
This can be achieved by using a build routine attached to the ENQUIRY record. As
its name suggests, it can build dynamic selection criteria.

3. Conversion Routines are used to manipulate the data in a field prior to display.
What can you do if you want to manipulate the data after the dynamic selection
is executed but before it is being displayed to the user? For example, for LD
application, an enquiry is written to display the currency and the amount. But
before the output is displayed, if the loan amount is in foreign currency, you
want another column which will hold the loan amount in local currency. In such

PRG6.Enquiry Routines-R09.01 6
a situation, you can write a routine and attach it to the particular field in the enquiry record.
This routine is termed as conversion routine. Conversion routine is specific to a field in
the enquiry record. Every field in the enquiry can have a conversion routine defined for it
in the field CONVERSION.

PRG6.Enquiry Routines-R8.02 6
1. Now you know what a build routine is and where it gets triggered. After the fixed
selection is executed in the enquiry, a build routine can be used to manipulate the
conditions specified in the selection criteria box before the output is displayed.
2. The build routine is attached to the field BUILD.ROUTINE in the ENQUIRY
record.

PRG6.Enquiry Routines-R09.01 7
You just learnt that a build routine can manipulate the dynamic selection criteria,
how does it do it?

• Build routine must have an argument which is a dynamic array passed to it.
This array resembles the structure of the selection criteria box.
• The dynamic array can be represented with any user defined name. The syntax
is <arrayname><column,row>. ENQ.DATA is not a common variable but a user
defined variable that has to be passed to the build routine.

Audio for screen shot:


The screen shot is an enquiry named ACCOUNT.TRG based on the ACCOUNT
application. The data that is stored in first column which is represented as
ENQ.DATA<1> is the name of the enquiry. The field names are stored in
second column represented as ENQ.DATA<2>, the operands in the third
column as ENQ.DATA<3> and the actual value in the fourth column as
ENQ.DATA<4>.

PRG6.Enquiry Routines-R09.01 8
Create an enquiry that will display Customer Id, the Account Id and the
respective working balance after accepting the category from the user.

For category 1001 - Balance should be in the range zero and 49999
For category 6001 - Balance should be in the range 50000 and 100000
For category greater than 7000 - Balance should be in the range 100000 and
500000

PRG6.Enquiry Routines-R09.01 9
The first step in attaching a build routine is to write the subroutine to manipulate the
criteria box.
LOCATE commands finds the position of an element within a specified dimension
of a dynamic array. For example, ENQ.DATA<2,1> searches the string in the 2nd
column from the 1st position. You can go through the jBASE website for more
information on the LOCATE command. As a part of the routine, add another row in
the selection criteria box for the working balance.
Now why do you think you have to add WORKING.BALANCE to the selection
criteria box through the routine? This is because, the value in this field should be
checked against the range required for a particular category before it is displayed.
This is where build routine gets into picture. You are manipulating the selection
criteria box.
When you give ENQ.DATA<2,1> for WORKING.BALANCE, you are trying to find
the string WORKING.BALANCE in the second column. But only CATEGORY is part
of the selection box. So then, BAL.POS will append one position and set
WORKING.BALANCE in the second position.

PRG6.Enquiry Routines-R09.01 10
Append the operand ‘RG’ to the ENQ.DATA array. RG is used to specify a range of
values. Depending on the category value dynamically add the amount field by
populating column four in the ENQ.DATA array.
Compile and catalog the routine using EB.COMPILE

PRG6.Enquiry Routines-R09.01 11
The second step is to create an enquiry on the ACCOUNT application with the
required fields and attach the name of the subroutine in the field BUILD.ROUTINE.
T24 does not throw an error while committing the record even if you enter any
wrong name. Therefore you can write the subroutine after the ENQUIRY record is
created.

PRG6.Enquiry Routines-R09.01 12
The output of the enquiry should be a combination of the condition specified in the
selection criteria box and the condition specified in the subroutine.
Note that all the Working Balances are within the range zero and 49999, which is
the range set for CATEGORY EQ 1001.

PRG6.Enquiry Routines-R09.01 13
Debug mode will help you understand how and when the values are
changed in the selection criteria box. Initially when you view the array
ENQ.DATA, you can see only CATEGORY into which the value is input by
the user. Note that BAL.POS is appended by one and therefore
WORKING.BALANCE is in second position in second column. After the
routine is triggered, if you now have a look at the contents of ENQ.DATA,
you will find that it is appended with WORKING.BALANCE.

PRG6.Enquiry Routines-R09.01 14
1. Conversion routines are used to manipulate the data in a field prior to display
2. Conversion routine is attached to the field CONVERSION for a particular field in
the ENQUIRY record

PRG6.Enquiry Routines-R09.01 15
1. There are some common variables that are exclusively used for enquiries.
I_ENQUIRY.COMMON is the insert file that holds the common variables
specific to enquiries. This file is similar to I_COMMON and I_EQUATE. Some of
the common variables are O.DATA, R.RECORD.
2. O.DATA is a common variable that holds the last extracted value in the enquiry.
This is similar to the variable COMI in I_COMMON which holds the last entered
value.
3. R.RECORD is another common variable defined in I_ENQUIRY.COMMON
which contains the record pertaining to the current ID that has been extracted.
These variables are used while writing a conversion routine.

PRG6.Enquiry Routines-R09.01 16
Create an enquiry that will list the LD contract numbers, and their respective loan
amounts. If the loan amount is in foreign currency, they have to be converted to
local currency and then displayed.
The output should have the following columns - ID, CCY, AMT, AMT.LCY

Hint: Multiply the LD loan amount with the ‘MID.REVAL.RATE’ in the CURRENCY
file for that particular currency to convert the foreign currency loan amount to local
currency amount

PRG6.Enquiry Routines-R09.01 17
The first step is to write a subroutine to manipulate the contents of the field before it
is displayed.

PRG6.Enquiry Routines-R09.01 18
Extract the currency for the current record being displayed. R.RECORD is an array
that contains the current record that is going to be displayed. Check if the currency
of the loan is local currency. If not, extract the value from MID.REVAL.RATE for the
foreign currency and multiply this rate with the loan amount and get the loan
amount in LCY. LCCY is the common variable which holds the local currency.
O.DATA contains the value of the last field to be displayed.

Compile and catalog the routine using EB.COMPILE

PRG6.Enquiry Routines-R09.01 19
The second step is to create an ENQUIRY record with all the required fields in the
output and attach the routine in the field CONVERSION for a field whose value has
to be manipulated before display. The routine name should be prefixed with ‘@ ‘ in
this field.
Attach the routine name to the field AMOUNT in the example as you want the
amount to be displayed in local currency.

PRG6.Enquiry Routines-R09.01 20
Note that the column AMT.LCY holds the loan amount in LCY. If the loan amount is
in foreign currency, the routine is triggered and the loan amount is displayed in
LCY. The value is a result of multiplying the original amount with 1.20125, which is
the value in the MID.REVAL.RATE field set for currency CAD.

PRG6.Enquiry Routines-R09.01 21
If you note the changes to the variable O.DATA, initially it holds the actual LD
amount in CAD. But as CAD is not local currency, it has to be multiplied with
the mid reval rate. To get the mid reval rate, you need to open the currency’s
record and check the field. After getting the value, multiply the amount in
CAD with the reval rate which is 1.20125 and populate the value to O.DATA

PRG6.Enquiry Routines-R09.01 22
1. QUESTION : Build routine is used to manipulate the selection criteria box.
TRUE
FALSE
2. QUESTION : O.DATA is the common variable that holds the last extracted value
TRUE
FALSE
3. QUESTION : R.RECORD holds the record pertaining to the current ID
TRUE
FALSE
4. QUESTION : I_ENQUIRY.COMMON is the insert file specific to a COMPANY
TRUE
FALSE – ENQUIRY application
5. QUESTION : Build routine need not have any argument
TRUE
FALSE – One argument required
6. QUESTION : Conversion routine is used to manipulate the data in a field before
display
TRUE
FALSE

PRG6.Enquiry Routines-R09.01 23
In this learning unit/course, you learnt about the enquiry routines in T24

You will now be able to:


•Explain different types of enquiry routines that can be attached to an enquiry
•Identify the stages where the enquiry routines would get executed
•Create Build and Conversion Routines

PRG6.Enquiry Routines-R09.01 24
PRG6.Enquiry Routines-R09.01 25
PRG6.Enquiry Routines-R09.01 26

You might also like