Professional Documents
Culture Documents
Having the data in a database is worth little unless it can be extracted and
utilized. The real power of a GLOBUS database will be the experience and
knowledge in unlocking the data and in presenting correct and complete
information back to users. An ENQUIRY is a question you ask the system
about your data. They are similar to select statements as they enables a user
to extract data from single or multiple files in addition to presenting complex
data in any required format. There is much more that one can do with an
enquiry, like
Creating an enquiry :
An enquiry can be created using any one of the following ways:
The Enquiry Wizard(Available under the Tools menu) helps you create
simple list style enquiries.
The Enquiry Designer(Available under the Tools menu)
Enquiry designer :
Let us understand the various fields in the “Full View”, as it comprises of all
the data spread across other tabs like Selection, Data Columns etc. It deals
with different selections, the data to be displayed, linking to other enquiries,
data regarding advanced manipulation and data regarding audit fields too.
1 PAGE.SIZE ........
2 FILE.NAME.........
3.1 FIXED.SELECTION
4.1 FIXED.SORT.....
5.1 SELECTION.FLDS.
6.1 SEL.FLD.OPER...
7.1 REQUIRED.SEL...
8.1 BUILD.ROUTINE..
9.1.1 HEADER......
10.1 FIELD.NAME.....
11.1.1 OPERATION...
12.1 COLUMN.........
13.1 LENGTH.MASK....
14.1.1 CONVERSION..
15.1.1 COMMENTS....
16.1 TYPE...........
17.1 DISPLAY.BREAK..
18.1 SINGLE.MULTI...
19.1 ENQUIRY.NAME...
20.1.1 SEL.CRIT ...
21.1 LABEL.FIELD....
22.1 NXT.LVL.DESC...
23. PAGE.FIELDS.......
24. STATIC.FIELDS.....
25. MULTI.FIELDS......
26. BREAK.FIELDS......
27. PROCESS.BREAKS....
28. TOTAL.FIELDS......
29. NEXT.LVL.FLDS.....
30. LINES.OSIDE.PAGE..
31. SMS.APPLICATION...
32. SMS.ID............
33. SMS.ABORT.........
34. USE.FIELD.NUMBERS.
35. CUSTOMER.NO.FLD...
36. ACCOUNT.NO.FLD....
37.1 SPOOL.BRK.FLD..
38.1.1 GB DESCRIPT.
39. RESERVED.3........
40. RESERVED.2........
41. RESERVED.1........
42. RECORD.STATUS.....
43. CURR.NO...........
44.1 INPUTTER.......
45. DATE.TIME.........
46. AUTHORISER........
47. CO.CODE...........
48. DEPT.CODE.........
These co-ordinates define the screen page which will be used by the enquiry.
It does not restrict the enquiry from addressing other areas of the screen, but
it should be noted that these areas are not refreshed automatically by moving
from one page to the next.
(1) XX,YY where XX defines the first line of the page and YY the last.
Must be numeric, in the range 0 - 24, and be separated by a ','.
This is the main file to be accessed / displayed by the enquiry system. The
file must have a valid entry on F.FILE.CONTROL and should not contain
the 'F.' or 'FXXX.' prefix.
FIELD NO 3 = FIXED.SELECTION
Identifies the fixed selection criteria for the enquiry. This selection will be
performed when an enquiry is invoked. It’s functionality is similar to the
functionality of the “where” clause in a “select“ statement.
Examples: APPLICATION.ID EQ LD
FIELD NO 4 = FIXED.SORT
Specifies the fixed sort field names. It’s functionality is similar to the “order
by” clause in a “select” statement. Sorting can happen either in the
ascending or descending order of a single or multiple fields.
FIELD NO 5 = SELECTION.FLDS
FIELD NO 6 = SEL.FLD.OPER
Valid operands : Null, EQ, RG, UL, LK, NR, GE, LE or LT or any
combination separated by a space.
FIELD NO 7 = REQUIRED.SEL
FIELD NO 8 = BUILD.ROUTINE
Routine to be invoked prior to the actual selection of data from the file but
after the selection criteria is specified when running the enquiry. This routine
must have one passed argument, which will contain the following:
FIELD NO 10 = FIELD.NAME
Defines an identification for the field used in the enquiry. It need not contain
the actual name of the field as specified in the Standard Selection record. In
case the name is the same as specified in the Standard Selection record, then
the same value gets defaulted to the Operation field.
This contains the actual name of the enquiry field as defined in the
StandardSelection record. The following instructions are supported:
Instruction Action
FIELD.NAME Dynamically locates the field
reference by using FILE.NAME's
STANDARD.SELECTION record.
Important note:
FIELD NO 14 = CONVERSION
Conversion Action
LINK XXX,YYY Read file XXX using the current data as the
key and return field name YYY as defined
in the STANDARD.SELECTION record for
XXX. Do not specify F. or company
mnemonic in file name. Field Name YYY
may be a data field or an I or J descriptor
defined in the Standard Selection record of
file XXX Note that if a multi or sub-valued
item is returned from a LINK version, the
multi and sub values are converted to
spaces, so the result cannot be displayed
in separate lines.
CCY XXX
TRANSLATE
LANGUAGE
DATE
FIELD NO 17 = DISPLAY.BREAK
Defines enquiry field to be processed only when a break condition is met. In
the case of total fields, the total will be displayed (providing Column has
been specified) and the current total cleared.
Standard break names are provided for certain conditions. They are:
FIELD NO 18 = SINGLE.MULTI
FIELD NO 19 = ENQUIRY.NAME
This will invoke a version by name AC.TEST in the input mode and
automatically generate the id.
FIELD NO 20 = SEL.CRITERIA
Selection criteria for the next level enquiry. Valid only when invoking
another enquiry on the next level (not used when calling an application).
The valid operands are EQ, NE, GT, LT, GE, LE, RG, NR, LK, and UL.
Example : CUSTOMER EQ CUST.ID
FIELD NO 21 = LABEL.FIELD
Specifies the enquiry field name, on which if right clicked leads to the next
level enquiry, version or application.
FIELD NO 31 = SMS.APPLICATION
FIELD NO 32 = SMS.ID
The enquiry field which holds the id of the record to be read from
SMS.APPLICATION.
Each time this enquiry field is processed then the record from
SMS.APPLICATION will be read and subsequently verified for SMS. If it
does not pass the SMS check then the current record will not be displayed.
FIELD NO 33 = SMS.ABORT
Flag to indicate if the enquiry is to be aborted when the first SMS violation
is recorded.
The enquiry system will read and SMS verify all records it selects. This can
be very time consuming if all the records fail the SMS checks. Consequently
this flag enables the enquiry to abort at the first SMS violation encountered.
FIELD NO 34 = USE.FIELD.NUMBERS
Specifies whether field numbers entered in the OPERATION field should
not be converted to the relevant field name.
May be Y or NO.
FIELD NO 35 = CUSTOMER.NO.FLD
Indicates the defined field, which contains the value of the customer number,
to be used for purposes of spooling. Used in conjunction with
ENQUIRY.REPORT application, which we will discuss as we go on.
FIELD NO 36 = ACCOUNT.NO.FLD
Indicates the defined field, which contains the value of the account number,
to be used for purposes of spooling. Used in conjunction with
ENQUIRY.REPORT module
FIELD NO 37 = SPOOL.BRK.FLD
Example 1
Using the Enquiry Designer, create a grid enquiry, which displays the
ACCOUNT.NUMBER and CUSTOMER number for the client base from the
ACCOUNT file.
Note that you must give a field a Column co-ordinate for it to appear in the Enquiry e.g. 3
and 29. The Page Size default will be set to 4,19. Run your enquiry in both GUI and
Classic.
Solution 1
1. PAGE.SIZE 4,19
2. FILE.NAME ACCOUNT
10.1 FIELD.NAME ACCOUNT.NUMBER
11.1.1 OPERATION ACCOUNT.NUMBER
12.1 COLUMN 3
13.1 LENGTH.MASK 16R
18.1 SINGLE.MULTI S
10.2 FIELD.NAME CUSTOMER
11.2.1 OPERATION CUSTOMER
12.2 COLUMN 20
13.2 LENGTH.MASK 10R
18.2 SINGLE.MULTI S
Output
Example 2
Add the CURRENCY and the WORKING.BALANCE of the accounts to your enquiry
ensuring the working balance is formatted according to the currency of the account.
Field Name (FIELD.NAME), Column (COLUMN), Type (TYPE). See the helptext on
Type
Solution 2
Example 3
Give each column a header. Note that headings in Classic must be input in the HEADER
field in Enquiry Designer Full View. For Desktop grid enquiries the Heading
(FIELD.LABEL) field should be used. Give the report a header. See the difference in
Desktop and Classic.
Note that the HEADER fields must be added as Sub Values, not Multi Values
Solution 3
Display the accounts owned by a customer on a separate page per customer. To do this
you will need to create a break field specifying that you wish to start a new page when
the customer changes. Use the Break Change operation with a column of ‘P’ which is
used to throw a page. Show the customer number and name in the header rather than on
each line. Make the report a page report – PAGE value in ATTIRIBUTES field. Tidy the
report.
Operation (OPERATION)
Column (COLUMN)
Display Break (DISPLAY.BREAK)
ATTRIBUTES
Note: Your enquiry should now be shown as a page rather than as a grid.
Solution 5
Solution 6
5. 1 SELECTION.FLDS. ACCOUNT.NUMBER
5. 2 SELECTION.FLDS. CUSTOMER
5. 3 SELECTION.FLDS. CURRENCY
Output
Example 8
Add a total for working Balance for each Customer. The total should appear on the break
field defined earlier
Name (FIELD.NAME), Operation (OPERATION), Col (COLUMN),
Break (DISPLAY.BREAK)
Solution 8
10.8 FIELD.NAME TOTWB
11.8.1 OPERATION TOTAL WORKING.BALANCE
12.8 COLUMN 25
17.8 DISPLAY.BREAK B.CUS
10.9 FIELD.NAME TOTTEXT
11.9.1 OPERATION "Total"
12.9 COLUMN 19
17.9 DISPLAY.BREAK B.CUS
Output
Example 9
Make the Enquiry Break on Currency as well, so that the Enquiry makes more sense. To
do this the totaling must be done on a break for both Currency change and Customer
change. For this to work a working field should be set up that concatenates Cust. No. and
Currency. Then a break field should be established for this field. Each time the value
changes the Enquiry should total (for details of Concatenating see help text for
‘Operation’). You can choose whether to make the break a page break or not. If the break
is a page break, put the currency into the header.
Solution 9
1 PAGE.SIZE 4,19
2 FILE.NAME ACCOUNT
Enquiries subroutines :
Now that we are clear about creating simple enquiries let us proceed and
create ‘enquiries with subroutines’. As we are aware, subroutines are
programs that enable a user to read and write onto a single file or multiple
files. These subroutines when attached to enquiries, add more functionality
to them. There are two different types of subroutines that can be attached to
an enquiry namely,
Build routine
Conversion routine
Before we learn to write these subroutines it is vital for us to know about the
file ‘I_ENQUIRY.COMMON’. It is an insert file like I_COMMON and
I_EQUATE, but specific to enquiries and contains common variables
specific to enquiries. A commonly used variable in I_ENQUIRY.COMMON
is O.DATA. We will learn more about it in the ‘NOFILE ENQUIRY’ section.
Build Routines
These are subroutines, which get invoked prior to the actual selection of
records from the file and after the user specifies the selection criteria. They
have to be attached to the field ‘8.1 BUILD ROUTINE’. This routine must
have one passed argument which will contain the following:
Example 1
Create an enquiry which will accept the category from the user and display the list of
accounts provided their balances are greater than a certain amount. For instance,
Solution 1
Step 1
Create a routine (AC.BUILD.BAL)
SUBROUTINE AC.BUILD.BAL(ENQ.DATA)
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_ENQUIRY.COMMON
CATEG = ENQ.DATA<4,1>
IF CATEG = 6000 THEN
ENQ.DATA<2,2> = 'WORKING.BALANCE'
ENQ.DATA<3,2> = 'RG'
ENQ.DATA<4,2> = '60000 70000'
PRINT "DONE"
END
IF CATEG = 7000 THEN
ENQ.DATA<2,2> = 'WORKING.BALANCE'
ENQ.DATA<3,2> = 'RG'
ENQ.DATA<4,2> = '20000 30000'
END
IF CATEG > 7000 THEN
ENQ.DATA<2,2> = 'WORKING.BALANCE'
ENQ.DATA<3,2> = 'GT'
ENQ.DATA<4,2> = '50000'
END
RETURN
END
Create the enquiry and attach the routine in field number 8.1
Conversion Routines
Conversion routines are the ones that help us to manipulate the data in a
field prior to display. They are attached to the Conversion field. GLOBUS
gives us the flexibility of using any of the pre-defined conversion routines
or attaching user-defined routines. Let us understand it with an example.
Example 1
Create an enquiry that will list the LD contract numbers, and their respective loan
amounts. Incase the loan amounts are in foreign currency, they have to be converted to
local currency and then displayed.(Hint: Multiply the LD loan amount with the
‘BUY.RATE’ in the CURRENCY file for that particular currency to convert the foreign
currency loan amount to local currency amount)
Format of output required:
LD Contract Number Amount In Local Currency
Solution 1
File to be used : LD
Field to be used : @ID,
SUBROUTINE E.CONV.LD.AMT
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_ENQUIRY.COMMON
$INSERT I_F.LD.LOANS.AND.DEPOSITS
$INSERT I_F.CURRENCY
R.LD.REC = ''
VAR1 = 0
LD.CURR = ''
LD.AMT = 0
LD.NEW.AMOUNT = 0
EXCH.RATE = 0
RET.CODE = ''
LD.ID = O.DATA
FN.LD = 'F.LD.LOANS.AND.DEPOSITS' ; FV.LD = ''
CALL F.READ(FN.LD,LD.ID,R.LD.REC,FV.LD,ERR1)
LD.CURR = R.LD.REC<LD.CURRENCY>
LD.AMT = R.LD.REC<LD.AMOUNT>
IF LD.CURR NE LCCY THEN
FN.CURRENCY = 'F.CURRENCY' ; FV.CURRENCY = ''
CALL OPF(FN.CURRENCY,FV.CURRENCY)
CALL F.READ(FN.CURRENCY,LD.CURR,R.CUR.REC,FV.CURRENCY,ERR2)
CUR.BUY.RATE = R.CUR.REC<EB.CUR.BUY.RATE>
LD.NEW.AMOUNT = CUR.BUY.RATE * LD.AMT
O.DATA = LD.NEW.AMOUNT
END
ELSE
O.DATA = LD.AMT
END
RETURN
END
In the above subroutine the loan amount which is stored in O.DATA is
extracted and the respective currency for that amount is fetched from the
‘LD.LOANS.AND.DEPOSITS’. If the fetched currency is the same as the
local currency then , the value is displayed in the enquiry else the
‘BUY.RATE’ for that particular currency is extracted from the CURRENCY
file and is multiplied with the amount. This calculated value is then sent
back to the enquiry through the O.DATA variable.
Context enquiries :
When you open the CUSTOMER application and choose the menu option -
Enquiry, you would see a list of enquiries listed pertaining to the
CUSTOMER application.. Incase you open the ACCOUNT application you
would find a different set of enquiries listed which pertain to the ACCOUNT
Solution
1. Create an enquiry(CUS.MNEMONIC.LIST) which will list the existing customer ids
and their respective mnemonics.
ACCOUNT
Example 1
Ensure that, whenever a user rightclicks on the customer number field in the ACCOUNT
application, the respective customer’s name and address have to be listed.
Solution 1
1. Create an enquiry that will list the customers names and their addresses
Now that we are familiar with CONTEXT enquiries let us move one step
further and link enquiries. An important feature of the ENQUIRY system is
to be able to extract data from the current ENQUIRY and use it as the
selection criteria for the next, 'lower level' ENQUIRY. This is exactly what a
‘Drilldown enquiry’ can do.
Example 1
Create an enquiry which lists all account numbers and their mnemonics.Link an enquiry
by name ACCT.BAL.TODAY that display all entries for the account specified. Make the
drill-down available from the account number in your enquiry.
Enquiry (ENQUIRY.NAME), Selection (SEL.CRIT), Field to highlight
(LABEL.FIELD), Description (NXT.LVL.DESC)
Note that the field names must be different in each Enquiry, for the link to be meaningful
Solution 1
32.1 ENQUIRY.NAME ACCT.BAL.TODAY
33.1.1 SEL.CRIT ACCOUNT.NUMBER EQ ACCT
34.1 LABEL.FIELD ACCT 1
35.1 NXT.LVL.DESC Acct Bal Today enquiry
Create an enquiry that will list the customer details. From the list, on right clicking a
particular customer number a user should be able to create an account for that customer.
The customer number should get defaulted in the ‘customer number’ field in the
ACCOUNT file. The customer mnemonic has to be defaulted in the ACCOUNT
mnemonic field.
Solution 1
Note : ACCREATE is the name of the version which will automatically get
invoked in the input mode, id gets automatically generated and the customer
number and mnemonic get defaulted in the version the ‘CUSTOMER’ field
and ‘MNEMONIC’ field respectively.
Step 2
Create the version ACCOUNT, ACCREATE.
‘Nofile’ enquiry:
The enquiry subsystem first builds up a list of ids, then picks up each id and
constructs a record and then displays the records. If the information that
needs to be presented does not exist in a file then subroutines can be written
to do the task. Basically 2 routines needs to be written – one which will
construct a list of ids and one which will accept the id and build the record
based on the id.
Example 1
Create an enquiry which will display customer ids and their respective account balances
currency wise.
Solution
Step1
Create a subroutine that will build the list of ids.
SUBROUTINE LIST.IDS(YID.LIST)
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.CUSTOMER
$INSERT I_F.ACCOUNT
$INSERT I_F.CUSTOMER.ACCOUNT
$INSERT I_F.MM.MONEY.MARKET
$INSERT I_F.LD.LOANS.AND.DEPOSITS
SEL.COMMAND = ‘’
FIRST.ID = 0
ID1 = 0
R.CUS.REC = ‘’
R.ACCT.REC = ‘’
R.REC = ‘’
CUS.ACCT.BAL = 0
CUST.REC.AMT = ‘’
CUST.REC.NAME = ‘’
RES.REC = ‘’
FN.CUSTOMER = 'F.CUSTOMER' ; FV.CUSTOMER = ' '
CALL OPF(FN.CUSTOMER,FV.CUSTOMER)
SEL.COMMAND = "SELECT " : FN.CUSTOMER
SEL.LIST = ""
CALL EB.READLIST(SEL.COMMAND,SEL.LIST,"",NO.OF.REC,ERR1)
LOOP
REMOVE FIRST.ID FROM SEL.LIST SETTING POS
WHILE FIRST.ID:POS
FN.CUST.ACC = 'F.CUSTOMER.ACCOUNT' ; FV.CUST.ACC = ''
CALL OPF(FN.CUST.ACC,FV.CUST.ACC)
CALL F.READ(FN.CUST.ACC,ID1,R.CUS.ACCT.REC,FV.CUST.ACC,ERR2)
Y.CNT = DCOUNT(R.ACCT.CUS.REC,FM)
FOR I = 1 TO Y.CNT
Y.ACCT = R.CUS.ACCT.REC<I>
FN.ACCOUNT = 'FBNK.ACCOUNT' ; FV.ACCOUNT = ''
CALL OPF(FN.ACCOUNT,FV.ACCOUNT)
CALL F.READ(FN.ACCOUNT,Y.ACCT,R.ACCT.REC,FV.ACCOUNT,ERR3)
Y.CUST = DEP.ACC<CUSTOMER>
Y.CURR = DEP.ACC<CURRENCY>
Y.AMT = DEP.ACC<ONLINE.ACTUAL.BAL>
IF Y.CURR = LCCY THEN
CUS.AMT += Y.AMT
END
ELSE
CALL
EXCHRATE('1',Y.CURR,T.AMT,LCCY,'','',EXCH.RATE,'',LCY.AMT,RET.CODE)
CUS.AMT += LCY.AMT
END
EXCH.RATE = 0
LCY.AMT = 0
NEXT I
Y.TOTAMT = CUS.AMT
IF Y.TOTAMT GT 0 THEN
CUST.REC.NAME<-1> = Y.CUST:’*’:Y.TOTAMT
END
Y.TOTAMT = 0
CUS.AMT = 0
REPEAT
YID.LIST = CUST.REC.NAME
RETURN
END
Step 2
Create another subroutine that will extract each id from the list and pick up the respective
balance and populate it in the enquiry
SUBROUTINE DISPLAY.RECORDS
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_ENQUIRY.COMMON
R.RECORD = ''
CUS.NAME = ''
CUS.AMT = ''
Y = O.DATA
CUS.NAME = FIELDS(Y,"*",1)
CUS.AMT = FIELDS(Y,"*",2)
R.RECORD<10> = CUS.NAME
R.RECORD<11> = CUS.AMT
RETURN
END
Step 3
Create the Standard Selection record which should start with “NOFILE”
Step 4
Create the enquiry
Enquiry report :
PRINTER.ID
DE.FORM.TYPE
REPORT.CONTROL
ENQUIRY.REPORT
Tip :
To run the report during the end of day the id of the ENQUIRY.REPORT
record should be entered in the DATA field of the BATCH record for the job
EB.PRINT, preceded by ENQ.
When defining the ENQUIRY (report) the PAGE.SIZE in ENQUIRY should
be set to the size of the report page.
Step 1
Define the printer using the PRINTER.ID application. You could also use an
existing printer id.
Step 2
Define the form type using the DE.FORM.TYPE application. You could use
an existing form type.
Step 3
Create a record in the REPORT.CONTROL application for routing to
printer.
Step 4
Create a record in the ENQUIRY.REPORT application with the enquiry
name and the REPORT.CONTROL id so that the output is routed to the
printer.
Step 5
To execute the report, open the ENQUIRY.REPORT record in the
‘VERIFY” mode and press F5.