4 8 1 Batch Control Concepts

Visual LANSA

4.8.1 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 field in one file is totaled into the field of another file. LANSA's batch control logic automatically maintains the control totals in files for you as records are inserted, updated and deleted. (The fields used in batch control can include key fields.)

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 file with a field which stores the total value of a given order.  This field 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 files 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 file level.  LANSA implements batch control using its object access modules (OAM).

Functions equivalent to batch control can be performed using file 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 fields 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 files structured like this:

Daily Totals File

Batch Totals File

Entry Data File

DATE

DATE

DATE

DDEBIT

BATCH

BATCH

DCREDIT

BDEBIT

TRANSACTION

 

BCREDIT

ACCOUNT

 

 

DESCRIPTION

 

 

DEBIT

 

 

CREDIT

 

  • 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" file in this example, the batch control logic component would be used to indicate that:

  • Fields DEBIT and CREDIT in the "Entry data" file should be accumulated by DATE and BATCH into fields BDEBIT and BCREDIT in the "Batch totals" file.
  • Fields DEBIT and CREDIT in the "Entry data" file should be accumulated by DATE into fields DDEBIT and DCREDIT in the "Daily totals" file.
  • When the I/O module for the "Entry data" file is compiled (see beginning of this chapter for discussion of I/O modules) it will contain logic to automatically maintain the batch control fields in the "Batch totals" and "Daily totals" files.
  • This means that whenever a record is added, updated or deleted from the "Entry data" file 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" file 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" file it will use the I/O module. The I/O module will maintain the batch control totals in the other 2 files without you even knowing of their existence.

Following is another, simpler example. An order header file and an order lines file have the following fields defined in them:

Order Header File

Order Lines File

ORDNUM

ORDNUM

CUSTNO

ORDLIN

DATE

PRODNO

TOTDUE

QUANTY

 

VALUE

 

  • In this structure, TOTDUE (in order header) is a count of all associated VALUE fields in the order lines file. TOTDUE is the total value of all associated lines in the order.

Also See

4.8.2 Batch Control Examples

Ý 4.8 Batch Control Development