Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.
You can execute custom logic at any of several Express-provided events that occur during database call processing:
Event
|
Occurrence
|
Before DB Access
|
Before a non-loop database call executes
|
Before Loop
|
Before a loop database call executes
|
Normal Status
|
After processing records, and before moving them to the window or screen
|
Normal-X Status
|
For looped records only. After Normal Status executes, and before moving records to the window or screen
|
Error Status
|
After the database call returns an Error status flag
|
Exception Status
|
After the database call returns an Exception status flag
|
After DB Access
|
After a non-loop database call executes
|
After Loop
|
After a loop database call executes
|
The Normal Status and Normal-X Status events enable you to add custom logic before looped records map to your screen. Use these events when you want to map only some of the records that a loop obtains. In your custom code, write conditional logic to determine which records to map. Online Express provides a flag, OK-TO-PROCEED, that you set to True to map and process the record, or False to bypass mapping and processing. You can ignore the flag if you do not use this event; the flag is set to True by default.
The following example illustrates both events. Suppose that you must map the records that show annual sales of $100,000 or more in the Northwest region, and calculate and map the grand total of those records.
- First, you define a loop call and qualify it to obtain the records of $100,000 or more.
- Then, you tailor the loop call with two paragraphs.
- The first paragraph (at the Normal-X Status event) checks the records obtained by the loop and process records of the Northwest region only.
- The second paragraph (at the Normal Status event) calculates the grand total of those records, and maps the total to the screen.
Using the Normal Status Events - Generated Code
DB-PROCESS REC SALES-RECORD
... WHERE ANNUAL-SALES-TOTAL > 99999
PERFORM CHECK-BEFORE-MAPPING-PARA
IF OK-TO-PROCEED
ADD 1 TO CTR
PERFORM RECORD-STOREKEY-PARA
PERFORM CALC-AND-MAP-PARA
MOVE REC-TO-SCREEN-LB1
.
.
.
CHECK-BEFORE-MAPPING-PARA
TRUE OK-TO-PROCEED
IF SALES-REGION NOT = NORTHWEST
FALSE OK-TO-PROCEED
CALC-AND-MAP-PARA
calculation and mapping routine for grand total
In the example code:
- The CHECK-BEFORE-MAPPING-PARA paragraph executes at the Normal Status event. Express generates the paragraph PERFORM statement.
- The CALC-AND-MAP-PARA paragraph executes at the Normal-X Status event. Express generates the paragraph PERFORM statement.
- Online Express generates all code subordinate to the DB-PROCESS call.