Customizing Database Calls

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.

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: