SPI Programming Manual (G06.24+, H06.03+, J06.03+)
SPI Programming in COBOL
SPI Programming Manual—427506-006
7-2
Declarations Needed in COBOL Programs
Declarations Needed in COBOL Programs
In addition to the declarations provided in the definition files, you must add these
declarations to your COBOL programs.
SPI Buffer
In the Data Division of your program, you must set up the file for requester-server
communication. Use a file description (FD) entry similar to:
FD SERVER-FILE LABEL RECORDS ARE OMITTED.
Immediately following this statement, include a COPY statement for the SPI buffer
declaration. The ZSPIDEF.
subsysCOB definition file for each NonStop Kernel
subsystem includes a buffer declaration named
subsys-DDL-MSG-BUFFER, which
has the structure described in SPI Message Buffer
on page 2-13. To allocate a buffer
of the recommended size, your COPY statement should be similar to (this example is
for sending commands to Pathway):
copy ZPWY-DDL-MSG-BUFFER of $SYSTEM.ZSPIDEF.ZSPICOB.
Then you can easily refer to the Z-MSGCODE (-28), Z-BUFLEN, and Z-OCCURS
fields of this structure as needed.
If you wish to define a buffer larger than the recommended size in order to handle a
large number of response records per response message, you can write your own
buffer declaration, following the pattern of
subsys-DDL-MSG-BUFFER.
Interpreting Boolean Values
Tokens and token fields of token type ZSPI-TYP-BOOLEAN (or other token types
based on ZSPI-DDL-BOOLEAN) become type PIC XX in COBOL. Therefore, COBOL
does not support the named values ZSPI-VAL-TRUE and ZSPI-VAL-FALSE.
To interpret the values of Boolean tokens and fields, it is recommended that your
programs define PIC XX variables or fields in working storage, use VALUE clauses to
initialize them to HIGH-VALUES (true) or LOW-VALUES (false), and then reference
the PIC XX fields when the true or false values are needed in operations with fields of
type ZSPI-TYP-BOOLEAN.
For example, consider the ZTMF field of ZPWY-DDL-DEF-PROG. A COBOL program
could set or test this field as follows:
.
.
WORKING-STORAGE.
01 COBOL-VAL-TRUE PIC XX VALUE HIGH-VALUES.
01 COBOL-VAL-FALSE PIC XX VALUE LOW-VALUES.
.
.
PROCEDURE DIVISION