Build RTN

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

BUILD ROUTINE

These are subroutines that get invoked prior to the actual selection of records
from the file and after the user specifies the selection criteria. These routines
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 arguments is to alter the selection criteria
when required.
Example: Create an enquiry to see the account information of a particular or a
set of customers by using a Build Routine to supply the predefined selection
criteria to the enquiry.
Solution:
Step 1: Write a subroutine to define the predefined selection criteria and compile
it. The subroutine is as follows:
0001:
SUBROUTINE E.BUILD.CUSTOMER(ENQUIRY.DATA)
0002:
0003: $INSERT I_EQUATE
0004: $INSERT I_COMMON
0005: $INSERT I_ENQUIRY.COMMON
0006:
0007:
LOCATE 'CUSTOMER' IN ENQUIRY.DATA<2,1> SETTING POS ELSE
0008:
ENQUIRY.DATA<2,POS> = 'CUSTOMER'
0009:
ENQUIRY.DATA<3,POS> = 'EQ'
0010:
ENQUIRY.DATA<4,POS> = '100069'
0011:
END
0012:
0013:
RETURN
0014:
0015: END

Step 2: Create an enquiry to display the account details of customers and attach
the above subroutine in field number 8.1 (Build Routine).

The output of the above enquiry is

Example - 2: Create an enquiry that 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 1001 Balance should be in the range 100 and 200000.
For Category 1000 Balance should be in the range 1000 and 100000.
For Categories greater than 1001 Balance should be greater than 1000.
0001:
SUBROUTINE E.AC.BUILD.BAL(ENQ.DATA)
0002: $INSERT I_COMMON
0003: $INSERT I_EQUATE
0004: $INSERT I_ENQUIRY.COMMON
0005:
0006:
CATEG = ENQ.DATA<4,1>
0007:
IF CATEG = 1001 THEN
0008:
ENQ.DATA<2,2>='WORKING.BALANCE'
0009:
ENQ.DATA<3,2> = 'RG'
0010:
ENQ.DATA<4,2> = '100 2000000'
0011:
END
0012:
IF CATEG = 1000 THEN
0013:
ENQ.DATA<2,2>='WORKING.BALANCE'
0014:
ENQ.DATA<3,2> = 'RG'
0015:
ENQ.DATA<4,2> = '1000 200000'
0016:
END
0017:
IF CATEG > 1001 THEN
0018:
ENQ.DATA<2,2>='WORKING.BALANCE'
0019:
ENQ.DATA<3,2> = 'GT'
0020:
ENQ.DATA<4,2> = '1000'
0021:
END
0022:
RETURN

Enquiry Design:

The selection criteria looks as follows:

The output of the enquiry is as follows:

You might also like