This example demonstrates ACCENT R's screen control features. This Process Module (PM) is used in a banking application where a bank customer can request a certified check over the telephone.
Four layouts are defined in the PM:
ACCT_WINDOW OKAY_WINDOW
INFO_WINDOW DISBURSE_WINDOWWhen a customer calls the bank and requests a certified check, a bank employee starts the PM. First the ACCT_WINDOW is displayed via GENERATE, SCREEN PASTE_WINDOW and FILL statements. Note that the SCREEN PASTE_WINDOW statement ensures that the window will remain pasted even after the FILL statement has completed execution. The bank employee enters the customer's account number in this window. GET statements retrieve the appropriate rows from the Accounts Data Set (DS) and the Customers DS. If the account number is invalid, a window is created via the @CREATE_WINDOW system function. An error message is placed in the window with a SCREEN PUT_LINE statement and the window is displayed by a SCREEN PASTE_WINDOW statement.
If the account number is valid, the INFO_WINDOW is displayed with data that identifies the customer and shows the account balance. The OKAY_WINDOW is also pasted. This window asks the bank employee to verify that the correct account was retrieved. If the bank employee responds "yes", the DISBURSE_WINDOW is pasted. This is where the information about the disbursement is entered. The customer tells the bank employee the amount of the certified check and where it is to be sent. If the disbursement entered is too small (less than $10.00) or too large (more than the account balance), an error message window is displayed via SCREEN PUT_LINE, @CREATE_WINDOW, and SCREEN PASTE_WINDOW.
After the disbursement information has been entered correctly, the OKAY_WINDOW is displayed again. This time, the user can verify that the entered information is correct and that it is okay to apply the transaction to the data base. The check amount is subtracted from the account balance and the balance field reduced appropriately. PUT statements change the account balance in the appropriate record in the Accounts DS. Finally, the screen is cleared with SCREEN KILL_SCREEN.
! This Process Module creates a disbursement record when a customer! calls the bank and requests a certified check. The customer gives! their account number which is used to retrieve account information! customer information that is displayed to the person taking! the order. The information displayed identifies the customer and! shows the account balance. The customer then provides the! information for the check and where it is to be sent. The amount! is checked against the account balance and the balance reduced! appropriately. This example demonstrates the ACCENT R's 4th GL,! RDBMS, and screen control features.!---------------------CONTROL SECTIONRELATE DI ACCOUNTS AS ACTS FOR UPDATERELATE DI CUSTOMERS AS CUSTS FOR INPUTRELATE DS DISBURSEMENTS AS DISB FOR CREATE APPENDING!---------------------DECLARE SECTIONACCOUNT, FLOAT, 8,2ACCT_ID, INT, 4 ! Window id for the ACCT_WINDOW layoutINFO_ID, INT, 4 ! Window id for the INFO_WINDOW layoutERR_ID, INT, 4 ! Window id for the error windowOKAY_ID, INT, 4 ! Window id for the OKAY_WINDOW layoutDISB_ID, INT, 4 ! Window id for the DISBURSE_WINDOW layoutMESS1_ID, INT, 4 ! Window id for the message window 1MESS2_ID, INT, 4 ! Window id for the message window 2! This is the first window that appears when the PM is executed.! It displays the title and prompts the user for an account number.LAYOUT SCREEN ACCT_WINDOW/ FILL 1 12 3 60 @NORMAL/ SELECTION @REVERSE/ BORDER @BOLD ''/ MESSAGE 1 15 @BOLD 'BLACKRIDGE STAPLETON BANK'/ LINE 2 1 2 60 @BOLD/ MESSAGE 3 2 @NORMAL 'Please enter Account Number'/ FIELD 3 31 8 @REVERSE ACCOUNT:D ENTER/ PERFORM END_ACCTLAYOUT END
Figure 12 Account Number Entry
! After the last digit of a valid account number has been entered,! this window appears. It displays rows from both the ACCOUNT! Data Set and the CUSTOMER Data Set.LAYOUT SCREEN INFO_WINDOW/ FILL 7 12 7 60 @NORMAL/ SELECTION @REVERSE/ BORDER @BOLD ''/ MESSAGE 1 2 @NORMAL 'Customer Number'/ FIELD 1 18 8 @REVERSE CUST_NUMBER:CUSTS SHOW/ MESSAGE 1 29 @NORMAL 'Social Security #'/ FIELD 1 47 11 @REVERSE SS_NO:CUSTS SHOW/ MESSAGE 3 2 @NORMAL 'Customer Name'/ FIELD 3 16 30 @REVERSE CUST_NAME:CUSTS SHOW/ MESSAGE 5 2 @NORMAL "Mother's Maiden Name"/ FIELD 5 23 30 @REVERSE MAIDEN:CUSTS SHOW/ MESSAGE 7 2 @NORMAL 'Account Balance'/ FIELD 7 19 14 @REVERSE BALANCE:ACTS SHOWLAYOUT END
Figure 13 Account Information Display
LAYOUT SCREEN OKAY_WINDOW/ MENU 1 1 3 25 @NORMAL/ SELECTION 1 0 @REVERSE + @BOLD/ BORDER @BOLD ''/ MESSAGE 2 2 @NORMAL 'Okay? '/ RECTANGLE 1 8 3 25 @BOLD/ ITEM 2 10 @NORMAL ''/ KEYWORD 2 10 @NORMAL 'Yes'/ ITEM 2 14 @NORMAL ''/ KEYWORD 2 14 @NORMAL 'No'/ ITEM 2 17 @NORMAL ''/ KEYWORD 2 17 @NORMAL 'Cancel'LAYOUT END
Figure 14 Account Verification Prompt
! This window is for entering the details about the disbursement.LAYOUT SCREEN DISBURSE_WINDOW/ FILL 16 12 7 60 @NORMAL/ SELECTION @REVERSE + @BOLD/ BORDER @BOLD ''/ MESSAGE 1 2 @NORMAL 'Check Amount'/ FIELD 1 15 14 @REVERSE AMOUNT:DISB:R DEFAULT/ PICTURE '$$$ $$$ $$$.DD'/ PERFORM CHECK_AMT ALWAYS AFTER/ MESSAGE 1 33 @NORMAL '(Enter 0 to cancel)'/ MESSAGE 3 2 @NORMAL 'Name of Payee'/ FIELD 3 16 30 @REVERSE CHECK_TO:DISB:R DEFAULT/ MESSAGE 5 2 @NORMAL 'Street Address of Payee'/ FIELD 5 26 30 @REVERSE ADDRESS_TO:DISB:R DEFAULT/ MESSAGE 7 2 @NORMAL 'City'/ FIELD 7 7 20 @REVERSE CITY_TO:DISB:R DEFAULT/ MESSAGE 7 30 @NORMAL 'State'/ FIELD 7 36 2 @REVERSE STATE_TO:DISB:R DEFAULT/ MESSAGE 7 39 @NORMAL 'Zip Code'/ FIELD 7 48 6 @REVERSE ZIPCODE_TO:DISB:R DEFAULT/ PERFORM DISB_END ALWAYS AFTERLAYOUT END
Figure 15 Disbursement Information
!---------------------PROCESS SECTION!---------------------ROUTINE END_ACCT! Exit the account screen as soon as the operator has entered the! account number.'END' TO @FILL_ACTION!---------------------ROUTINE CHECK_AMT! This trigger checks the amount entered. If the amount is 0,! then the trigger ends execution of the PM. If the amount is! less than ten dollars or greater than the account balance, then! the trigger displays a window with a message that asks the! operator to re-enter the amount.IF AMOUNT:DISB:R = 0'END' TO @FILL_ACTIONORIF AMOUNT:DISB:R =< 10.00IF:10 MESS1_ID = 0@CREATE_WINDOW (1, 46, @BORDER, @REVERSE) TO &MESS1_IDSCREEN PUT_LINE USING MESS1_ID, 'Amount cannot be less than'&'$10.00', 1, @NORMAL, @NOWRAPCONTINUE:10SCREEN PASTE_WINDOW USING MESS1_ID, 17, 10SCREEN RING_BELL USING MESS1_ID, 2'REDO' TO @FILL_ACTIONELSEIF:10 AMOUNT:DISB:R > BALANCE:ACTSIF:20 MESS2_ID = 0@CREATE_WINDOW (1,46, @BORDER, @REVERSE) TO &MESS2_IDSCREEN PUT_LINE USING MESS2_ID, &'Amount cannot exceed the account balance', 1, &@NORMAL, @NOWRAPCONTINUE:20SCREEN PASTE_WINDOW USING MESS2_ID, 17, 10SCREEN RING_BELL USING MESS2_ID, 2'REDO' TO @FILL_ACTIONELSE:10SCREEN UNPASTE_WINDOW USING MESS1_ID IF MESS1_ID # 0SCREEN UNPASTE_WINDOW USING MESS2_ID IF MESS2_ID # 0CONTINUE!---------------------ROUTINE DISB_END! Exit the disbursement screen as soon as the operator has entered! the zip code.SCREEN PASTE_WINDOW USING OKAY_ID, 14, 50SCREEN RING_BELL USING OKAY_ID, 2MENU OKAY_ID! Exit if the user chooses YES or CANCEL'END' TO @FILL_ACTION IF @MENU_CHOICE=1 OR 3SCREEN UNPASTE_WINDOW USING OKAY_ID1 TO @NEXT_ITEM IF @MENU_CHOICE = 2
Figure 16 Amount Checking
!---------------------DETAIL SECTION! This loop accepts an account number validates the account number,! and re-prompts if the correct account number was not entered.STARTGENERATE ACCT_WINDOW TO ACCT_ID IF ACCT_ID = 0SCREEN PASTE_WINDOW USING ACCT_ID, 3, 12FILL ACCT_ID FOR ENTER! Remove error message (no such account...) if it had previously! been PASTEd.SCREEN UNPASTE_WINDOW ERR_ID IF ERR_ID#0! Check if an account number was entered. If 0, then exit (cancel! transaction).IF:10 ACCOUNT:D#0! Look up the account record and the associated customer record.GET FROM ACTS MATCH BY ACCOUNT:D HUSHGET FROM CUSTS MATCH BY CUST_NUMBER:ACTS HUSH IF @AUX='YES'! Check if there was a matching account record.IF:20 @AUX='YES'! Display the information from the account record and customer! record for validating the caller.GENERATE INFO_WINDOW TO INFO_ID IF INFO_ID = 0SCREEN PASTE_WINDOW USING INFO_ID, 7, 12FILL INFO_ID FOR SHOW! Check if this is the right account and if the customer wishes to! proceed with the transaction by displaying the window with the! Yes-No-Cancel options.GENERATE OKAY_WINDOW TO OKAY_ID IF OKAY_ID = 0SCREEN PASTE_WINDOW USING OKAY_ID, 15, 20SCREEN RING_BELL USING OKAY_ID, 2MENU OKAY_ID
Figure 17 Disbursement Verification Prompt
! Was the answer yes?IF:30 @MENU_CHOICE = 1GENERATE DISBURSE_WINDOW TO DISB_ID IF DISB_ID = 0SCREEN PASTE_WINDOW USING DISB_ID, 15, 12! Start the loop to accept the information for the transaction and! to verify it was entered correctly.READY DISBFILL DISB_ID FOR CHANGE! Is the information correct?IF:40 @MENU_CHOICE = 1 AND AMOUNT:DISB:R # 0ACCOUNT:D TO ACCOUNT_NO:DISB:R@UDT TO DATE:DISB:R! Create the disbursement record.CREATE DISB! Update the account balance in the account record.BALANCE:ACTS - AMOUNT:DISB:R TO BALANCE:ACTSPUT ACTSCONTINUE:400 TO ACCOUNT:DELSE:30! The caller wishes to cancel the transaction (insufficient funds?).SCREEN UNPASTE_WINDOW USING OKAY_IDSCREEN UNPASTE_WINDOW USING INFO_ID! Did the user cancel the transaction (insufficient funds?).IF:40 @MENU_CHOICE = 30 TO ACCOUNT:DCONTINUE:40ELSE:20! If account given does not exist, paste error message window.IF:30 ERR_ID = 0@CREATE_WINDOW (2, 40, @BORDER, @REVERSE) TO&ERR_IDSCREEN PUT_LINE USING ERR_ID, 'No such account, please' &'re-enter', 1, @NORMAL, @WRAPSCREEN PUT_LINE USING ERR_ID, '(Enter account 0 to quit)'&,70, @NORMAL, @WRAPCONTINUE:30SCREEN PASTE_WINDOW USING ERR_ID, 10, 12CONTINUE:10! Check to see if finished with this transaction.LEAVE IF ACCOUNT:D = 0REPEAT!---------------------FINAL SECTIONSCREEN KILL_SCREEN! Check if a transaction was created and if so print the information! in the disbursement record.IF @MENU_CHOICE = 1STORE 'USE PM SHOW_DISBURSEMENTS' IN Command AREACONTINUEFigure 18 Disbursement Report Entry
Figure 18 above shows the report lines that are printed at the end of a transaction.