You are on page 1of 41

ENQUIRY

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

 Invoke drilldown enquiries, i.e., from a summary ENQUIRY to a more


detailed view
 Launch an ENQUIRY as context sensitive while working with a related
application
 Launch applications and default information from the ENQUIRY into the
contract
 Display and sort the data in a number of formats
 Export ENQUIRY result into a Windows application such as an Excel
worksheet

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)

For more complex enquiries, including the embedded spreadsheet


functionality let us understand the Enquiry Designer in detail

Enquiry designer :

The Enquiry Designer is a method of creating Enquiries in GLOBUS, using


the features of the multi-window Desktop to design a new Enquiry,
modifying an existing one and displaying the information required.
Designer Workspace

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.

Following are the various fields in the “Full View” tab.

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

FIELD NO 1 = PAGE.SIZE (Mandatory input)

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

FIELD NO 2 = FILE.NAME (Mandatory input)

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.

Examples: CUSTOMER - Ascending sort by customer.

ACCOUNT DSND - Descending sort by Account


number

FIELD NO 5 = SELECTION.FLDS

Specifies the selection fields to be displayed in the ENQUIRY.SELECT


application. The ENQUIRY.SELECT application enables a user to specify
conditions on fields during run time. If this field is left blank then all the
selection field names (from STANDARD.SELECTION) will be displayed.

FIELD NO 6 = SEL.FLD.OPER

Defines for the associated SELECTION.FLDS, which operands are allowed


for the enquiry.

Example : SELECTION.FLDS = CUSTOMER


SEL.FLD.OPER = EQ

Valid operands : Null, EQ, RG, UL, LK, NR, GE, LE or LT or any
combination separated by a space.
FIELD NO 7 = REQUIRED.SEL

Specifies for the associated SELECTION.FLDS whether selection criteria


are mandatory for the enquiry. Certain Enquiries may require a specific
selection field to be specified. This may be in cases where the selection field
calls a routine or uses concat file processing to improve the performance of
the enquiry, or simply to limit the scope of the enquiry.

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:

ENQ<1> = NAME OF ENQUIRY


ENQ<2,1> = SELECTION FIELD NAMES (USER INPUT)
ENQ<3,1> = ASSOCIATED OPERANDS (EQ, LK) etc.
ENQ<4,1> = DATA LIST

This passed argument is used to manipulate the selection criteria.

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.

FIELD NO 11 = OPERATION (Mandatory Input)

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.

FIELD.NO Field reference in Numeric format.


(0 - ID) (Not recommended only use in cases
where (1-999) the record is built by a routine
and does not follow the layout of the
file

IDESC XXX Execute the I-descriptor defined in the


STANDARD.SELECTION record of the
FILE, as a Type I or J item, with the
FIELD.NAME XXX. The result is returned
in the same way as if the field was
extracted from the record.

SELECTION XXX Return the value of the SELECTION.FIELD


XXX entered in the selection criteria.

FIELD XXX Extract current value of enquiry field


XXX.

TOTAL XXX Total enquiry field XXX.

BREAK CHANGE XXX Break on change of enquiry field XXX.

BREAK LINE NN Break when line NN has been exceeded.

CALC XXX + YYY Add enquiry field XXX and YYY.

CALC XXX / YYY Divide enquiry field XXX by enquiry field


YYY.

CALC XXX * YYY Multiply two enquiry fields.

CALC XXX – YYY Subtract two enquiry fields.

CALC XXX : YYY Concatenate two enquiry fields.


IF AA GT BB XXX YYY Decision process.

If enquiry field AA is greater than enquiry field BB then


process enquiry field XXX or process enquiry field YYY and
return the value to this enquiry field. The valid operands are
EQ, NE, GT, LT, GE, LE, RG, NR, LK, UL. Field is
subvalued to allow the decision criteria to span more
than a single line for clarity.

"zzzzz" Use the constant contained in quotes.

!USER Extract current user id.


!TODAY Extract today’s date.
!COMPANY Extract current company id.
!LANGUAGE Extract user's language code.
!LOCAL.CCY Extract local currency code.
!LAST.WORKING.DAY Extract last working day.
!NEXT.WORKING.DAY Extract next working day.

Important note:

Never reference a record field (XXX or 0-999) during the processing of


a break. Always reference enquiry fields (FIELDXXX).

FIELD NO 14 = CONVERSION

Allows data to be converted prior to display.

The conversion operation allows the manipulation of the result of an enquiry


operation. The result of the conversion is then stored in the enquiry field.
The following conversions are supported:

Conversion Action

FIELD X,N1,N2 Extract from the data, delimited by X, the


N1th field to the N2th.

EXTRACT N1,N2 Extract from the data starting at position N1


for N2 bytes.
SUBSTITUTE X,Y If the data equals X then replace it with Y.

CONVERT X,Y Replace every occurrence of the character


X with Y.

VALUE X,Y Extract value X, sub-value Y from the data.

JULIAN Convert the data from YYYYMMDD


format
to PRIME internal format.

OCONV XXX Convert data using Info-Basic OCONV


instruction XXX. See Info-Basic manual.

ICONV XXX Convert data using Info-Basic ICONV


instruction XXX. See Info-Basic manual.

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.

@ XXX Call user subroutine XXX.

$ XXX Call user subroutine XXX at selection stage


only. Allows manipulation of user selection
criteria.

(1) 32 type A (alphanumeric) characters.


Conversion <space> argument.
FIELD NO 16 = TYPE

Allows further formatting of the data based on the type of field.

This formatting is performed immediately prior to display, (i.e. after


conversion)

CCY XXX Y Amount format using currency held in


enquiry field XXX and the negative amount
format specified in Y. Current valid formats
are

E formats a -ve number as <123,456.12>


M formats a -ve number as 123,456.12-
B formats a -ve number as 123,456.12db
N formats a -ve number as 123,456.12
null formats a -ve number as -123456.12

e.g. CCY CURRENCY E

TRANSLATE Translate data using 'dynamic text' mechanism.

LANGUAGE Extracts correct language value (based on users


language code) from the multi-valued field.

DATE Formats GLOBUS internal date format


(YYYYMMDD) to DD Mmm YYYY.

(1) The valid types are:

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:

ONCE Only processed once at the beginning of the


enquiry
END Only processed at the end of the enquiry
NEWPAGE Processed at the start of every new page
NONE Only processed if no records matched the
selection criteria.

FIELD NO 18 = SINGLE.MULTI

Specifies that the instruction should be processed for every multi/sub-value


occurrence. If 'M' is specified the instruction will be processed for every
multi-value and sub-value occurrence within the data record. All multi-
value/sub-value fields are taken to be associated and aligned accordingly on
the screen.

Valid values : Either S or M (single or multi). If null is specified then S


is used as the default.

FIELD NO 19 = ENQUIRY.NAME

Defines the name of the next enquiry, application or version to be invoked


when descending enquiry levels.
Example : ACCOUNT,AC.TEST I F3

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

Defines the name of the application to be used for SMS verification.

If an enquiry is based on a "NOFILE" application the only SMS verification


which can take place is based on 'linked' data defined in the conversion field.
In order to supplement these checks you can define, here, the name of the
application whose SMS rules should also be used.

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.

Can be either Y or No.

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

Specifies fields which on change of value between pages, certain reports


may be required to produce output for particular Customers and Accounts,
where it would be advantageous to create a separate report for each
Customer or Account. By specifying the relevant field name here, if the
value changes between pages, a new spool record will be created.

Must be defined previously on the Enquiry as a FIELD NAME.

Let us now understand how to create enquiries using some examples.

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.

Fields to be populated: File Name (FILE.NAME), Name (FIELD.NAME), Column


(COLUMN), Operation (OPERATION), Mask (LENGTH.MASK), Page Size
(PAGE.SIZE).

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

10.3 FIELD.NAME CURRENCY


11.3.1 OPERATION CURRENCY
12.3 COLUMN 31
13.3 LENGTH.MASK 3L
18.3 SINGLE.MULTI S
10.4 FIELD.NAME WORKING BALANCE
11.4.1 OPERATION WORKING.BALANCE
12.4 COLUMN 35
13.4 LENGTH.MASK 19R
16.4 TYPE CCY CURRENCY
18.4 SINGLE.MULTI S
Output

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

Design for header display in Classic

9.1.1 HEADER @(25,0) Training Enquiry


9.1.2 HEADER @(3,2) Acct
9.1.3 HEADER @(15,2) Cust
9.1.5 HEADER @(31,2) Ccy
9.1.6 HEADER @(45,2) WBal
Design for header display in Desktop

11.1.1 OPERATION ACCOUNT.NUMBER


12.1 COLUMN 3
13.1 LENGTH.MASK 10L
18.1 FIELD.LABEL Account
31.1 SINGLE.MULTI S
10.2 FIELD.NAME CUSTOMER
11.2.1 OPERATION CUSTOMER
12.2 COLUMN 15
13.2 LENGTH.MASK 10L
18.2 FIELD.LABEL Customer
31.2 SINGLE.MULTI S
10.3 FIELD.NAME CURRENCY
11.3.1 OPERATION CURRENCY
12.3 COLUMN 31
13.3 LENGTH.MASK 3L
18.3 FIELD.LABEL Currency
31.3 SINGLE.MULTI S
10.4 FIELD.NAME WORKING.BALANCE
11.4.1 OPERATION WORKING.BALANCE
12.4 COLUMN 35
13.4 LENGTH.MASK 19R
16.4 TYPE CCY CURRENCY
18.4 FIELD.LABEL Balance
31.4 SINGLE.MULTI S
Example 4
Add the customer mnemonic linked from the CUSTOMER file and sort the display in
customer number order. Using fixed selection ensure no negative or zero balances are
listed and that internal accounts (with no customer) are excluded.
Conversion (CONVERSION) Link to another file – see
help text Predefined Sort (FIXED.SORT)
Predefined Selection (FIXED.SELECTION)

3.1 FIXED.SELECTION WORKING.BALANCE GT '0'


3.1 FIXED.SELECTION CUSTOMER NE NULL
4.1 FIXED.SORT CUSTOMER
10.3 FIELD.NAME MNEMONIC
11.3.1 OPERATION CUSTOMER
12.3 COLUMN 56
13.3 LENGTH.MASK 10R
14.3.1 CONVERSION L CUSTOMER,1
18.3 SINGLE.MULTI S
Output

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

10.2 FIELD.NAME CUSTOMER


11.2.1 OPERATION CUSTOMER
13.2 LENGTH.MASK 10L
18.2 FIELD.LABEL Customer
31.2 SINGLE.MULTI S

10.3 FIELD.NAME B.CUS


11.3.1 OPERATION B C CUSTOMER
12.3 COLUMN P
17.3 DISPLAY.BREAK NEWPAGE

10.4 FIELD.NAME D.CUS


11.4.1 OPERATION FIELD CUSTOMER
12.4 COLUMN 15,1

10.7 FIELD.NAME MNEMONIC


11.7.1 OPERATION CUSTOMER
12.7 COLUMN 30,1
13.7 LENGTH.MASK 10R
14.7.1 CONVERSION L CUSTOMER,1
18.7 FIELD.LABEL Name
31.7 SINGLE.MULTI S

52.1 ATTRIBUTES PAGE


Output
Example 6
Restrict the selection criteria for your enquiry to the following: ACCOUNT.NUMBER,
CUSTOMER and CURRENCY.

Selection Field (SELECTION.FLDS)

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

3.1 FIXED.SELECTION WORKING.BALANCE GT "0"


3.2 FIXED.SELECTION CUSTOMER NE NULL
4.1 FIXED.SORT CUSTOMER
4.2 FIXED.SORT CURRENCY

5.1 SELECTION.FLDS. ACCOUNT.NUMBER


5.2 SELECTION.FLDS. CUSTOMER
5.3 SELECTION.FLDS. CURRENCY

9.1.1 HEADER @(25,0)Training Enquiry


9.1.2 HEADER @(3,1)Customer
9.1.3 HEADER @(3,2)Account
9.1.4 HEADER @(36,2)Balance

10.1 FIELD.NAME ACCT


11.1.1 OPERATION ACCOUNT.NUMBER
12.1 COLUMN 3
13.1 LENGTH.MASK 10L
31.1 SINGLE.MULTI S
10.2 FIELD.NAME CUSTOMER
11.2.1 OPERATION CUSTOMER
13.2 LENGTH.MASK 7L
20.2 SECTION HEADER
31.2 SINGLE.MULTI S
10.3 FIELD.NAME B.CUS
11.3.1 OPERATION B C CUSTOMER
12.3 COLUMN P
10.4 FIELD.NAME D.CUS
11.4.1 OPERATION FIELD CUSTOMER
12.4 COLUMN 15,1
17.4 DISPLAY.BREAK NEWPAGE
20.4 SECTION HEADER
10.5 FIELD.NAME CURRENCY
11.5.1 OPERATION CURRENCY
13.5 LENGTH.MASK 3L
20.5 SECTION HEADER
31.5 SINGLE.MULTI S
10.6 FIELD.NAME CUSCCY
11.6.1 OPERATION C CUSTOMER : CURRENCY
10.7 FIELD.NAME B.CUSCCY
11.7.1 OPERATION B C CUSCCY
10.8 FIELD.NAME WORKING.BALANCE
11.8.1 OPERATION WORKING.BALANCE
12.8 COLUMN 25
13.8 LENGTH.MASK 19R
16.8 TYPE CCY CURRENCY
31.8 SINGLE.MULTI S
10.9 FIELD.NAME TOTWB
11.9.1 OPERATION TOTAL WORKING.BALANCE
11.9 COLUMN 25
13.9 LENGTH.MASK 19R
16.9 TYPE CCY CURRENCY
17.9 DISPLAY.BREAK B.CUSCCY
10.10 FIELD.NAME TOTTEXT
11.10.1 OPERATION "Total"
12.10 COLUMN 16
17.10 DISPLAY.BREAK B.CUSCCY
10.11 FIELD.NAME TOTCCY
11.11.1 OPERATION FIELD CURRENCY
12.11 COLUMN 22
13.11 LENGTH.MASK 3L
17.11 DISPLAY.BREAK B.CUSCCY
10.12 FIELD.NAME MNEMONIC
11.12.1 OPERATION CUSTOMER
12.12 COLUMN 24,1
13.12 LENGTH.MASK 10R
14.12.1 CONVERSION L CUSTOMER,1
20.12 SECTION HEADER
31.12 SINGLE.MULTI S
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
36 PAGE.FIELDS 6 1ÿ2ÿ5ÿ6ÿ8ÿ12
38 MULTI.FIELDS 0
39 BREAK.FIELDS 2 3ÿ7
40 PROCESS.BREAKS 4 4ÿ9ÿ10ÿ11
41 TOTAL.FIELDS 19
42 NEXT.LVL.FLDS 11
52.1 ATTRIBUTES PAGE
54.1 GB SHORT.DESC EFM ENQUIRY
Output

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:

ENQ<1> = NAME OF ENQUIRY


ENQ<2,1> = SELECTION FIELD NAMES (USER INPUT)
ENQ<3,1> = ASSOCIATED OPERANDS (EQ, LK etc.)
ENQ<4,1> = DATA LIST

The basic functionality of the passed argument is to alter the selection


criteria when required.

An example will make the concept clear.

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,

For category 6000 - Balance should be in the range 60000


and 70000
For category 7000 - Balance should be in the range 20000
and 30000
For categories greater than 7000 - Balance should be greater
than 50000

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

application. This is precisely what you can achieve using the


“CONTEXT.ENQUIRY” application. When enquiries are loaded depending
on the application opened, those enquiries are
Figure 1.2 Part of CONTEXT.ENQUIRY Application Screen
termed ‘Application Level Context Enquiries’. If enquiries are opened when
a user right clicks on a particular field in an application those applications
are termed ‘Field Level Context Enquiries’.

The id of the CONTEXT.ENQUIRY record has to be in the following


format:
 For application level – ApplicationName
 For a field in an application - ApplicationName-FieldName
 For versions - ApplicationName, VersionName
 For fields in a version - ApplicationName,VersionName-FieldName

Let us understand it with an example:

Application level context enquiries


Example 1
Ensure that, whenever the ACCOUNT application is opened a user is given an option to
list the existing customer ids and their mnemonics. This option should be available only
when he opens the ACCOUNT application.

Solution
1. Create an enquiry(CUS.MNEMONIC.LIST) which will list the existing customer ids
and their respective mnemonics.

10.1 FIELD.NAME @ID


11.1.1 OPERATION @ID
12.1 COLUMN 1

10.1 FIELD.NAME MNEMONIC


11.1.1 OPERATION MNEMONIC
12.1 COLUMN 10

3.Open CONTEXT.ENQUIRY application and fill in the required data.


In the CONTEXT.ENQUIRY application create a new record with id as ‘CUSTOMER’.

ACCOUNT

Figure 1.3 CONTEXT.ENQUIRY application screen

Field level context enquiries

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

File to be used : CUSTOMER

10.1 FIELD.NAME SHORT.NAME


11.1.1 OPERATION SHORT.NAME
12.1 COLUMN 1

10.1 FIELD.NAME STREET1


11.1.1 OPERATION STREET1
12.1 COLUMN 20

2. Open the CONTEXT.ENQUIRY application and fill in the required data.


Drilldown Enquiries :

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.

Let us understand it with an example.

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

(change Field 10.1 ACCOUNT.NUMBER to ACCT)


Output

Context Based Workflow :

Context Based Workflow allows enquiries to launch applications, versions


and to automatically populate these applications with data from (or related
to) the ENQUIRY.
Let us understand it with an example.
Example 1

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

Step 1: Create an enquiry that will list the customer details.

File to be used : CUSTOMER

10.1 FIELD.NAME @ID


11.1.1 OPERATION @ID
12.1 COLUMN 1

10.1 FIELD.NAME SHORT.NAME


11.1.1 OPERATION SHORT.NAME
12.1 COLUMN 10

10.1 FIELD.NAME MNEMONIC


11.1.1 OPERATION MNEMONIC
12.1 COLUMN 25

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:

If the information that needs to be presented in an enquiry does not exist in a


single file, then the enquiry can me made to take information from routines.
To do this first let us understand the way in which enquiry subsystem works.

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.

If a field is specified in an enquiry the type and position of the field is


retrieved from the standard selection record of the file mentioned in the field
FILE.NAME.

Standard selection is an application that basically stores the dictionary for a


file. You could have data fields and logical fields (i.e. the information is a
calculated value for e.g. from a subroutine). However generally when you
try to input a standard selection record it will validate if a FILE.CONTROL
record exists for the file. The only exception to this is if the SS record id
begins with ‘NOFILE’. So for our above requirement we will need to create
an SS record with ID starting with ‘NOFILE’. In the record for the ID field
make it a R type field and attach a routine that would build a dynamic array
of Ids that need to be displayed in the enquiry.
I_ENQUIRY.COMMON, a common file that is used in enquiries – defines a
variable called O.DATA which contains the ID of the record that is currently
going to be displayed. Another common variable called R.RECORD (a
dynamic array) is used by the enquiry subsystem to display the record. So
you need to write a routine that would use the id defined in O.DATA and
populate R.RECORD.

Let us take an example and understand it.

Example 1

Create an enquiry which will display customer ids and their respective account balances
currency wise.

Format of output required:

Customer Number Currency Total Account Balance

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 :

Usually when we create enquiries the output of the enquiry is by default


directed to the screen. Incase the output of an enquiry has to be printed in a
report like format, then the need of the application ‘ENQUIRY.REPORT’
arises. The ENQUIRY.REPORT application takes into account the various
details like the printer id to which the output has to be directed to, the page
settings and the enquiry name whose data has to be directed to the printer.
Applications used in conjunction with ENQUIRY.REPORT are
PRINTER.ID application to define the valid printers on the system . A
'SYSTEM' entry must exist on this file. This is used as the default for all
output. DE.FORM.TYPE application to specify the page settings and
REPORT.CONTROL application to specify the printer routing. To run the
report the record in ENQUIRY.REPORT application should be opened in the
‘VERIFY’ mode.

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.

There is no restriction on width or depth of report. All other aspects of the


definition are the same.

Steps to ensure that the output of an enquiry named LOANS.LIST is sent to


the printer.

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.

2 ENQUIRY Enquiry Name


7 REPORT.CONTROL Report.Control Id

Step 5
To execute the report, open the ENQUIRY.REPORT record in the
‘VERIFY” mode and press F5.

You might also like