OpenTP1 Version 7 Programming Reference COBOL Language

[Contents][Index][Back][Next]

1.1.2 Coding rules

Organization of this subsection
(1) Notes on coding
(2) Notes on naming
(3) Termination method
(4) When using Windows

(1) Notes on coding

Write UAPs to be used with OpenTP1 by coding them in COBOL/2# or COBOL85. OpenTP1 facilities are made available by using COBOL-UAP creation programs residing in the OpenTP1 library.

In addition, any system calls and program libraries can also be used. However, it is recommendable to use OS-provided standard statements and system calls when writing UAPs in order to assure high portability of the UAPs.

When creating UAPs in the COBOL language which use system calls and arbitrary program libraries, note the following:

  1. When issuing a signal from the UAP, do not register the type of a signal handler (SIGILL or SIGBUS) which creates a core file during operation with the signal default specified. If the signal handler is registered, a core file is not created even when the program terminates abnormally. As a result, troubleshooting is impossible.
  2. When issuing a signal from the UAP, do not use COBOL-UAP creation programs in the OpenTP1 library from the signal handler.
  3. Do not use the following system call:
    • chdir (change of the current working directory)
  4. Do not use the following system calls after the UAP start statement:
    • fork (new process creation)
    • exec (file execution)
    • system (shell command issuance)
  5. Do not use a jump statement (e.g., GOTO statement) which extends over service programs.
  6. When using another program library, do not use Xlib and OSF/Motif programs which control event-driven dispatching.
  7. When creating UAPs using the COBOL language, make sure that data areas such as unique-name-1 always begin at an even address. If a data area such as unique-name-1 begins at an odd address, a bus error will occur.
    Suppose that a unique-name-3 data area that is to be used in CBLDCMCF is defined in an array, the send data length in bytes is an odd number, and SYNC is not specified for the structure (in other words, no boundary alignment will be performed). In this situation, if a second data item in the array is set as an argument in CBLDCMCF, a bus error will occur when function processing is attempted.
  8. The MCF event information area for MCF event processing MHPs (C system or V system) that was created in the COBOL language must have a spare area length at least 2 bytes longer than the spare area length of the MCF event information area for C.

If the OS is HP-UX, the bind mode for linkage must be specified as immediate. If an executable file created in another mode is used as an OpenTP1 UAP, the system operation is unpredictable. To check that the bind mode of the created UAP is immediate, use the chatr command of the OS.

#
COBOL/2 cannot be used depending on the OS.

(2) Notes on naming

We recommend that you include a certain prefix character string in names of any variables or definitions coded by the user. If any names duplicate those used by the OS or OpenTP1, system operation is unpredictable.

(a) Service program names, program names, and entry names

Service programs must be given names which are 20 or less alphanumeric characters in length and begin with an alphabetic character. Do not give service programs or entries the following names:

(b) External variable names

Do not give external variables the following names except when such names are used according to the instructions in this manual:

(3) Termination method

Programs (main programs) which are directly activated by OpenTP1 must terminate with STOP RUN. Service programs must terminate with EXIT PROGRAM. If a main program does not terminate with STOP RUN, COBOL85 count and other information will not be output for the program.

(4) When using Windows

When using OpenTP1 (TP1/LiNK) with Windows, compile and link-edit a UAP conforming to the specifications of the COBOL complier for Windows.