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 COBOL

Using a VIEW Typed Record

There are two kinds of VIEW typed records. The first, FML VIEW, is a COBOL record generated from an FML record. The second is simply an independent COBOL record.

The reason for converting FML records into COBOL records and back again (and the purpose of the FML VIEW typed records) is that FML functions are not available in the COBOL programming environment.

For more information on the FML typed record, refer to the BEA Tuxedo FML Function Reference.

To use VIEW typed records, you must perform the following steps:

Setting Environment Variables for a VIEW Typed Record

To use a VIEW typed record in an application, you must set the following environment variables.

Environment Variables for a VIEW Typed Record

Environment Variable

Description

FIELDTBLS or FIELDTBLS32

Comma-separated list of field table file names for FML or FML32 typed records. Required only for FML VIEW types.

FLDTBLDIR or FLDTBLDIR32

Colon-separated list of directories to search for the field table files for FML and FML32 typed records. For Microsoft Windows, use a semi-colon separated list. Required only for FML VIEW types.

VIEWFILES or VIEWFILES32

Comma-separated list of allowable file names for VIEW or VIEW32 description files.

VIEWDIR or VIEWDIR32

Colon-separated list of directories to search for VIEW or VIEW32 files. For Microsoft Windows, use a semi-colon separated list.

Creating a View Description File

To use a VIEW typed record, you must define the COBOL record in a view description file. The view description file includes, a view for each entry, a view that describes the characteristic COBOL procedure mapping and the potential FML conversion pattern. The name of the view corresponds to the name of the copy file that is included in COBOL program.

The following format is used for each record in the view description file.

$ /* View structure */
VIEW viewname
type cname fbname count flag size null

The following table describes the fields that must be specified in the view description file for each COBOL record.

View Description File Fields

Field

Description

type

Data type of the field. Can be set to short, long, float, double, char, string, or carray.

cname

Name of the field as it appears in the COBOL record.

fbname

If you will be using the FML-to-VIEW or VIEW-to-FML conversion routines, this field must be included to indicate the corresponding FML name. This field name must also appear in the FML field table file. This field is not required for FML-independent VIEWs.

count

Number of times field occurs.

flag

Specifies any of the following optional flag settings:

size

For STRING and CARRAY record types, specifies the maximum length of the value. This field is ignored for all other record types.

null

User-specified LOW-VALUE value, or - to indicate the default value for a field. LOW-VALUE values are used in VIEW typed records to indicate empty COBOL record members.

The default LOW-VALUE value for all numeric types is 0 (0.0 for dec_t). For character types, the default LOW-VALUE value is `\0'. For STRING and CARRAY types, the default LOW-VALUE value is " ".

Constants used, by convention, as escape characters can also be used to specify a LOW-VALUE value. The view compiler recognizes the following escape constants: \ddd (where d is an octal digit), \0, \n, \t, \v, \r, \f, \\, \', and \".

You may enclose STRING, CARRAY, and LOW-VALUE values in double or single quotes. The view compiler does not accept unescaped quotes within a user-specified LOW-VALUE value.

You can also specify the keyword NONE in the LOW-VALUE field of a view member description, which means that there is no LOW-VALUE value for the member. The maximum size of default values for string and character array members is 2660 characters. For more information, refer to the BEA Tuxedo FML Function Reference.

You can include a comment line by prefixing it with the # or $ character. Lines prefixed by a $ sign are included in the .h file.

The following listing is an excerpt from an example view description file based on an FML record. In this case, the fbname field must be specified and match that which appears in the corresponding field table file. Note that the CARRAY1 field includes an occurrence count of 2 and sets the C flag to indicate that an additional count element should be created. In addition, the L flag is set to establish a length element that indicates the number of characters with which the application populates the CARRAY1 field.

View Description File for FML VIEW


$ /* View structure */
VIEW MYVIEW
#type cname fbname count flag size null
float float1 FLOAT1 1 - - 0.0
double double1 DOUBLE1 1 - - 0.0
long long1 LONG1 1 - - 0
short short1 SHORT1 1 - - 0
int int1 INT1 1 - - 0
dec_t dec1 DEC1 1 - 9,16 0
char char1 CHAR1 1 - - '\0'
string string1 STRING1 1 - 20 '\0'
carray carray1 CARRAY1 2 CL 20 '\0'
END


The following listing illustrates the same view description file for an independent VIEW.

View Description File for an Independent View


$ /* View data structure */
VIEW MYVIEW
#type cname fbname count flag size null
float float1 - 1 - - -
double double1 - 1 - - -
long long1 - 1 - - -
short short1 - 1 - - -
int int1 - 1 - - -
dec_t dec1 - 1 - 9,16 -
char char1 - 1 - - -
string string1 - 1 - 20 -
carray carray1 - 2 CL 20 -
END


Note that the format is similar to the FML-dependent view, except that the fbname and null fields are not relevant and are ignored by the viewc compiler. You must include a value (for example, a dash) as a placeholder in these fields.

Executing the VIEW Compiler

To compile a VIEW typed record, run the viewc -C command, specifying the name of the view description file as an argument. To specify an independent VIEW, use the -n option. You can optionally specify a directory in which the resulting output file should be written. By default, the output file is written to the current directory.

For example, for an FML-dependent VIEW, the compiler is invoked as follows.

viewc -C myview.v

Note: To compile a VIEW32 typed record, run the viewc32 -C command.

For an independent VIEW, use the -n option on the command line, as follows.

viewc -C -n myview.v

The output of the viewc command includes:

The following listing provides an example of the COBOL COPY file created by viewc.

COBOL COPY File Example


*    VIEWFILE: "myview.v"
* VIEWNAME: "MYVIEW"
05 FLOAT1 USAGE IS COMP-1.
05 DOUBLE1 USAGE IS COMP-2.
05 LONG1 PIC S9(9) USAGE IS COMP-5.
05 SHORT1 PIC S9(4) USAGE IS COMP-5.
05 FILLER PIC X(02).
05 INT1 PIC S9(9) USAGE IS COMP-5.
05 DEC1.
07 DEC-EXP PIC S9(4) USAGE IS COMP-5.
07 DEC-POS PIC S9(4) USAGE IS COMP-5.
07 DEC-NDGTS PIC S9(4) USAGE IS COMP-5.
* DEC-DGTS is the actual packed decimal value
07 DEC-DGTS PIC S9(1)V9(16) COMP-3.
07 FILLER PIC X(07).
05 CHAR1 PIC X(01).
05 STRING1 PIC X(20).
05 FILLER PIC X(01).
05 L-CARRAY1 OCCURS 2 TIMES PIC 9(4) USAGE IS COMP-5.
* LENGTH OF CARRAY1
05 C-CARRAY1 PIC S9(4) USAGE IS COMP-5.
* COUNT OF CARRAY1
05 CARRAY1 OCCURS 2 TIMES PIC X(20).
05 FILLER PIC X(02).


COBOL COPY files for views must be brought into client programs and service subroutines with COPY statements.

In the previous example, the compiler includes FILLER files so that the alignment of fields in COBOL code matches the alignment in C code.

The format of the packed decimal value, DEC1, is composed of five fields. Four fields-DEC-EXP, DEC-POS, DEC-NDGTS, and FILLER-are used only in C (they are defined in the dec_t type); they are included in the COBOL record for filler. Do not use these fields in COBOL applications.

The fifth field, DEC-DGTS, is used by the system to store the actual packed decimal value. You should use this value within the COBOL program. ATMI calls operate on the DEC-DGTS field to:

The only restriction is that a COBOL program cannot directly pass a record to a C function outside of the ATMI interface because the decimal formats in the COBOL program and C function do not match.

Finally, note that the sample COBOL COPY file includes an L-CARRAY1 length field that occurs twice, once for each occurrence of CARRAY1, and a C-CARRAY1 count field.

viewc creates a C version of the header file that you can use to mix C and COBOL service and/or client programs.

See Also