Differences between revisions 4 and 5
Revision 4 as of 2007-07-26 01:59:17
Size: 3664
Editor: paul
Comment:
Revision 5 as of 2007-07-26 02:10:46
Size: 4904
Editor: paul
Comment:
Deletions are marked like this. Additions are marked like this.
Line 45: Line 45:

== Transaction Files ==
The transaction files ''tran.dat'' and ''daytrn.dat'' consist of 128 byte records. The first 100 records are reserved for summary transactions for 100 different transaction types. e.g. record 21 is the summary transaction for DRINVs (Debtor Invoices).

fOR ''daytrn.dat'', each summary transaction record maintains a linked list of batch header transactions of that particular transaction type. The batch header transaction may then contain a list of batch lines which are also maintained via a singly linked list.

A transaction summary record consists of:

* A pointer to the first transaction of this type (batch) - ''slnkf''

* A pointer to the last transaction of this type (batch) - ''slnkl''

* A pointer to the first unposted transaction (for daytrn.dat) - ''slnkfb''

For each header other pointers (record numbers, not memory addresses) are used including:

* ''lnext'' - pointer to the next batch this type

* ''pline'' - pointer to the first line of this batch

* ''ptrrec'' - pointers to the record to which this transaction belongs.

For each line of the batch:

* ''lnext'' - points to the next line in this batch.

* ''phead'' - points to the batch header transaction.

Data Structures

CONTROL allows for the maintaining of information for an unlimited number of companies. A number of files are maintained for each company. There are essentially three different types of files used in CONTROL: Master, Transaction and Index.

All data files are a collection of fixed size records. The first few records in a file are reserved for special purposes.

N.B. This level of detail on the file contents generally isn't necessary as the routines used to access the data/index/transaction files are quite stable and the issues are generally more related to changing data record layouts/content.

The first 32 bytes of record 0 (zero) is referred to as the file descriptor block and contains control information pertaining to the file

* size of the static and variable parts of the record

* total record size

* number of free records

* free list pointer, etc (see s_fdblk and s_ifdblk in file://ccdev/std/hdrs/common.h ).

This information can be changed using the program spatch.

The remainder of record 0 is the "control record" - used to store operation modifying parameters which can be changed by CONTROL programs: e.g. drcont is used to alter accounts receivable (debtors) control parameters.

For Master files, the second record in the file (record 1) is usually reserved for the 'default' record which is the record that is 'altered' when a new record is added. Hence default values can be set for all fields that can be accessed in the file maintenance program. (default values can be altered by pressing the DEFAULT RECORD key in the Alter option of the appropriate file maintenance program)

Additions to the file are made to the end of the file, that is the next available record in the file. However, if deletions have been made, then the record used will be one from a list of 'free' records within the file. The beginning of the free list is pointed to by a free list pointer in the control record of the file.

The free list is a singly linked list of records and are pointed to by the free list pointer which is adjusted as requests for new records are made or records are added to the free pool.

When a record is deleted, the record is marked as 'free', an linked into the free list, becoming the new head of the list. Similarly, if a free record is requested, then the first available, the records at the had of the free list is returned, and the free list pointer adjusted to the next in the list.

Master Files

Examples of master files are stock.dat (for stock records), debtor.dat for customer records), cred.dat (for supplier records).

In general, each record is separated into two halves, one half for static information (e.g. stock description, customer name and address) and the other half for variable information (e.g. current balance, sales statistics, etc.).

For each record of most aster files, one or more singly linked lists of transactions are maintained.

For example a list if financial transactions for the creditor could consist o a linked list of Creditor Adjustments, Sundry Creditor Invoices, Creditor Payments and Creditor Invoices for Stock.

To maintain these lists, two pointers are used - a pointer to the first transaction on the list and a pointer to the last transaction on the list (used for easy linking to the end of the list).

Transactions on a list are linked by the lnkrec field in the transaction (see file:/ccdev/std/hdrs/tran.h) and points to the master file record it belongs to by the ptrrec field. (N.B. The data is an record index rather than a file offset (PM 26/07/2007))

Transaction Files

The transaction files tran.dat and daytrn.dat consist of 128 byte records. The first 100 records are reserved for summary transactions for 100 different transaction types. e.g. record 21 is the summary transaction for DRINVs (Debtor Invoices).

fOR daytrn.dat, each summary transaction record maintains a linked list of batch header transactions of that particular transaction type. The batch header transaction may then contain a list of batch lines which are also maintained via a singly linked list.

A transaction summary record consists of:

* A pointer to the first transaction of this type (batch) - slnkf

* A pointer to the last transaction of this type (batch) - slnkl

* A pointer to the first unposted transaction (for daytrn.dat) - slnkfb

For each header other pointers (record numbers, not memory addresses) are used including:

* lnext - pointer to the next batch this type

* pline - pointer to the first line of this batch

* ptrrec - pointers to the record to which this transaction belongs.

For each line of the batch:

* lnext - points to the next line in this batch.

* phead - points to the batch header transaction.

CONTROL/Software/Development/DataStructures (last edited 2016-01-06 03:27:34 by test10)