CONVERSION ROUTINES : The routines that help in manipulating the data in a field prior to display are called conversion routines. They are attached to the Conversion field( ) in Enquiry. Globus gives us the flexibility of using any of the pre-defined conversion routines or attaching user-defined routines. Example: Create an enquiry that will list the LD contract numbers and their respective loan amounts. If 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.) The output should contain the fields – Contract.No(ID of LD), Currency, Amount, Buy-Rate(from CURRENCY table) and Conversion-Amount. Solution: 1. Write a subroutine to check whether the Amount in LD is in foreign currency or not and then use the CURRENCY table to get the BUY.RATE. Compile it. 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 = 0 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) 0LD.CURR = R.LD.REC LD.AMT = R.LD.REC 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 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 ID of LD.LOANS.AND.DEPOSITS is stored in O.DATA and the respective currency for this record is fetched from the ‘LD.LOANS.AND. DEPOSITS’ using F.READ. If the fetched currency is the same as the local currency then, the value 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. 2. Create an enquiry on LD.LOANS.AND.DEPOSITS to display the required fields as follows.
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.