BEA Logo BEA Tuxedo Release 7.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   Tuxedo Doc Home   |   Programming   |   Topic List   |   Previous   |   Next   |   Contents

   Programming a BEA Tuxedo Application Using FML

Dividing Records into Fields: Data Structures Versus Fielded Buffers

Except under unusual conditions where a data record is a complete and indivisible entity, you need to be able to break records into fields to be able to use or change the information the record contains. In the BEA Tuxedo system records can be divided into fields through either of the following:

Using Structures to Divide Records into Fields

One common way of subdividing records is with a structure that divides a contiguous area of storage into fields. The fields are given names for identification; the kind of data carried in each field is shown by a data type declaration.

For example, if a data item in a C language program is to contain information about an employee's identification number, name, address, and gender, it could be set up with a structure such as the following.

struct S {
long empid;
char name[20];
char addr[40];
char gender;
};

Here the data type of the field named empid is declared to be a long integer, name and addr are declared to be character arrays of 20 and 40 characters respectively, and gender is declared to be a single character, presumably with a range of m or f.

If, in your C program, the variable p points to a structure of type struct S, the references p-->empid, p-->name, p-->addr and p-->gender can be used to address the fields.

The COBOL COPY file for the same data structure would be as follows (the application would supply the 01 line).

05 EMPID                           PIC S9(9) USAGE IS COMP-5.
05 NAME PIC X(20).
05 ADDR PIC X(40).
05 GENDER PIC X(01).
05 FILLER PIC X(03).

If, in your COBOL program, the 01 line is named MYREC, the references EMPID IN MYREC, NAME IN MYREC, ADDR IN MYREC, and GENDER IN MYREC can be used to access the fields.

Although this method of representing data is widely used and is often appropriate, it has two major potential disadvantages:

Using Fielded Buffers to Divide Records into Fields

Fielded buffers provide an alternative method for subdividing a record into fields.

A fielded buffer is a data structure that provides associative access to the fields of a record; that is, the name of a field is associated with an identifier that includes the storage location as well as the data type of the field.

The main advantage of the fielded buffer is data independence. Fields can be added to the buffer, deleted from it, or changed in length without forcing programs that reference the fields to be recompiled. To achieve this data independence, fields are:

Fielded buffers can be used throughout the BEA Tuxedo system as the standard method of representing data sent between cooperating processes.