bdfp1m0tProgramming Concepts and Reference

Problem and Solution

Assume that you are in charge of the data processing department of a major airline. The director of marketing has created a new plan known as the Gold Club. Members of the Gold Club will have certain benefits not available to the general public, such as the use of a private lounge at most airports, the ability to pre-reserve seats, and the availability of special meals with 24 hours notice.

Members join the club by paying a membership fee, which covers one year's membership. Once a person is a member, he or she receives an additional month's free membership for every 1000 miles flown on the airline.

About 100 000 members are expected to join the club in its first year of operation. You must design a system to keep track of members, update their mileage credits from an existing departure control system, and update their membership expiration dates at regular intervals.

To see what the problem involves, write down all the relevant information for each member as follows:

In addition to setting up and maintaining the file, you must create a process that deducts 1000 miles from the current credit and adds one month to the expiration date whenever the mileage credit reaches 1000.

The easiest plan is to hold the information for each member in one fixed-length LREC with all the member LRECs being held in a fixed file.

Although this method could work adequately, it has the following disadvantages:

A better solution is to use basic indexing. In the detail file, each subfile holds a number of different LRECs, but all the LRECs in the subfile relate to one club member. Each subfile in the detail file is pointed to by an index LREC in the index file. Each index LREC also contains the member number as the index key.

The member information can be distributed over several variable-length LRECs. Different LREC types contain different information; for example:

Assembler LREC ID C Language LREC ID Data fields
X'80' 0x80 Member initials and surname.
X'90' 0x90 Member address. This is as many as six lines, separated by a delimiter. In our sample assembler application, an asterisk (*) is used as the delimiter. In our sample C language application, a null character (0\n) is used as the delimiter.
X'A0' 0xA0 Meal, seat, and payment method preferences.
X'B0' 0xB0 Mileage credit and current expiration date.

In addition, one subfile indexed using the dummy member number 9999999999, contains the following LRECs:

Assembler LREC ID C Language LREC ID Data fields
X'C0' 0xC0 Previously deleted member number.
X'D0' 0xD0 Next available membership number.

This subfile normally contains only one LREC. The LREC has one field (apart from the LREC ID), which is the next available member number (at startup, this is 0000000001).

However, when a member is deleted, the member number is returned to this subfile and can be reused. LRECs are organized in the subfile in available member number order, so any reusable member number LRECs are at the start of the subfile.

Some advantages of this method are:

It might seem expensive in DASD storage to use 100 000 pool blocks for the detail file. However, you can choose any size from 381 bytes (L1 size) upward to suit your application. A reasonable size to allow for future expansion is 1055 bytes (L2). If the information about any member exceeds 1055 bytes, the TPFDF product creates overflow blocks automatically. You can choose the size of overflow blocks to be the same as the prime blocks or larger.

Note:
To be very economical in the use of DASD, set the overflow blocks to a larger size (for example L4) and set bit 5 of SW00OP1. The TPFDF product then uses the smaller (prime block) size for overflow blocks unless they require the larger size.