Professional Documents
Culture Documents
Nofile Enquiry
Nofile Enquiry
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.
Example 15
Create an enquiry which will display customer ids and their respective account balances
currency wise.
Solution 15
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,FIRST.ID,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”
FILE.NAME......... NOFILE.ENQ1
--------------------------------------------------------------------------
1. 1 SYS.FIELD.NAME.
2. 1 SYS.TYPE.......
3. 1. 1 SYS.FIELD.NO
4. 1. 1 SYS.VAL.PROG
5. 1 SYS.CONVERSION.
6. 1 SYS.DISPLAY.FMT
7. 1 SYS.ALT.INDEX..
8. 1. 1 SYS.IDX.FILE
9. 1 SYS.INDEX.NULLS
10. 1 SYS.SINGLE.MULT
11. 1 SYS.LANG.FIELD.
12. 1 SYS.GENERATED..
13. 1. 1 SYS.CNV.TYPE
14. 1. 1 SYS.REL.FILE
15. 1 USR.FIELD.NAME. ID
16. 1 USR.TYPE....... R
17. 1. 1 USR.FIELD.NO LIST.IDS
18. 1. 1 USR.VAL.PROG
19. 1 USR.CONVERSION.
20. 1 USR.DISPLAY.FMT 30L
21. 1 USR.ALT.INDEX..
22. 1. 1 USR.IDX.FILE
23. 1 USR.INDEX.NULLS
24. 1 USR.SINGLE.MULT S
25. 1 USR.LANG.FIELD.
26. 1. 1 USR.CNV.TYPE
27. 1. 1 USR.REL.FILE
28 REBUILD.SYS.FLDS..
29 DEFAULT.ENRICH....
30 SPARE.2...........
31 SPARE.3...........
32 SPARE.4...........
Step 4
Create the enquiry
ENQUIRY........... CUSENQ1
--------------------------------------------------------------------------
1 PAGE.SIZE ........ 4,19
2 FILE.NAME......... NOFILE.ENQ1
3. 1 FIXED.SELECTION ID
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..... @ID
11. 1. 1 OPERATION... 0
12. 1 COLUMN.........
13. 1 LENGTH.MASK....
14. 1. 1 CONVERSION.. @ DISPLAY.RECORDS
15. 1. 1 COMMENTS....
16. 1 TYPE...........
17. 1 DISPLAY.BREAK..
18. 1 FIELD.LABEL....
19. 1 FIELD.DISP.TYPE