Batch Control Concepts
Batch control is a special feature of the LANSA Repository. Batch control logic is used to define the logic by which a numeric column in one table is totaled into the column of another table. LANSA's batch control logic automatically maintains the control totals in tables for you as records are inserted, updated and deleted. (The columns used in batch control can include key columns.)
Batch control is often used as a means of verifying totals during data entry. For example, batch control could be used to maintain an order header table with a column which stores the total value of a given order. This column is calculated by adding up the order amounts from each of the order lines for the specified order. Batch control could also be used to keep track of the total number of lines in a given order.
Batch control logic in tables can improve performance by reducing the amount of database I/O. It also simplifies application logic by centralizing calculations and performing them automatically. Batch control logic is defined at the table level. LANSA implements batch control using its Object Access Modules (OAM).
Functions equivalent to batch control can be performed using table level triggers. Though the trigger approach requires manual coding of the trigger functions, the ability to manually code the application logic makes the trigger very flexible and very powerful. Triggers are the recommended approach for implementing batch control type logic.
Important: Please note that the use of batch control logic, and the repository columns used to support it, may not be consistent with the practices of logical data modeling.
Following is an example of batch control:
-
A "batched transaction" data entry application may use three control tables structured like this:
|
-
In this structure, BDEBIT and BCREDIT are totals of all DEBIT and CREDIT values for a particular DATE and BATCH.
-
Likewise, DDEBIT and DCREDIT are totals of CREDIT and DEBIT values for a particular DATE.
When setting up the definition of the "Entry data" table in this example, the batch control logic component would be used to indicate that:
-
Columns DEBIT and CREDIT in the "Entry data" table should be accumulated by DATE and BATCH into columns BDEBIT and BCREDIT in the "Batch totals" table.
-
Columns DEBIT and CREDIT in the "Entry data" table should be accumulated by DATE into columns DDEBIT and DCREDIT in the "Daily totals" table.
-
When the I/O module for the "Entry data" table is compiled (see beginning of this chapter for discussion of I/O modules) it will contain logic to automatically maintain the batch control columns in the "Batch totals" and "Daily totals" tables.
-
This means that whenever a record is added, updated or deleted from the "Entry data" table the totals will be maintained. No other logic is required to maintain the totals.
-
The logic generated will handle changes to the batch control "keys" as well. Thus, even if a record in the "Entry data" table was changed from BATCH 1234 to 4567 and DATE 010187 to 150187 the control totals will be maintained correctly.
-
If a user creates a function to add records to the "Entry data" table it will use the I/O module. The I/O module will maintain the batch control totals in the other two tables without you even knowing of their existence.
Following is another, simpler example. An order header table and an order lines table have the following columns defined in them:
|
-
In this structure, TOTDUE (in order header) is a count of all associated VALUE columns in the order lines table. TOTDUE is the total value of all associated lines in the order.
Also See