COBOL programs can access information held by the compiler and the operating system. This includes information on
the compilation of the source
CPU time used since LOGON
the task in which the object program is running, and
the terminal from which the program was called.
COBOL2000 supports access to this information with the following language elements:
Program-internal mnemonic names for the individual types of information, declared in the SPECIAL-NAMES paragraph of the Environment Division:
The ACCEPT statement of the Procedure Division can access the relevant information via these mnemonic names. Mnemonic names can be declared for information onthe compilation with COMPILER-INFO IS mnemonic-name
the CPU time used with CPU-TIME IS mnemonic-name
the task with PROCESS-INFO IS mnemonic-name
the terminal with TERMINAL-INFO IS mnemonic-name
the date with DATE-ISO4 IS mnemonic-name (with century)
The ACCEPT statement in the Procedure Division:
ACCEPT...FROM mnemonic-name
moves the information that is associated (in the SPECIAL-NAMES paragraph) with mnemonic-name into the specified receiving item.
The size of the data transfer is determined by the length of the receiving item specified in the ACCEPT statement; the data is aligned on the left in the item, as follows:
If the item is longer than the value to be transferred, it is padded with spaces on the right; if it is shorter, the value is truncated on the right during transfer to conform to the length of the item. This does not apply to CPU TIME: here a numerically correct transfer is always carried out.
The length (and possibly the structure) to be declared for the receiving item is determined by the type of information that the item is to receive. The formats of the various types of information are listed in the following section.
Contents and structure of the information
The following table explains the structure of the information that is made available to a COBOL program via the implementor-names COMPILER-INFO, CPU-TIME, PROCESS-INFO, TERMINAL-INFO and DATE-ISO4.
Character position(s) | Information for COMPILER-INFO |
1-10 | Compiler name (COBOL2000'BLANK', COBOL2000B, COBOL2000R) |
11-20 | Compiler version |
21-30 | Date of compilation |
31-38 | Time of compilation |
39-68 | The first eight characters of the PROGRAM-ID name |
Information for CPU-TIME | |
PIC 9(6)V9(4) | CPU time in ten thousandths of a second |
Character position(s) | Information for PROCESS-INFO |
1 | Type of job |
2-5 | Job sequence number |
6-13 | User identification |
14-21 | Account number |
22 | Privilege class of the job |
23-32 | Operating system version |
33-40 | Name of the next processor to which the terminal is connected. |
Character position(s) | Information for PROCESS-INFO |
41-120 | System administrator privileges; |
41-48 | SECADM |
49-56 | USERADM |
57-64 | HSMSADM |
65-72 | SECOLTP |
73-80 | TAPEADM |
81-88 | SATFGMMF |
89-96 | NETADM |
97-104 | FTADM |
105-112 | FTACADM |
113-120 | TSOS |
Character position(s) | Information for TERMINAL-INFO |
1-8 | Terminal name |
9-13 | Number of characters per line |
14-18 | Number of physical lines that can be output without activating the information |
19-23 | Number of characters that can be output without activating the information |
24-27 | Device type |
Character position(s) | Information for DATE-ISO4 |
1-14 | Current date (including century YYYY and numbered dayNNN of the current year) |
Table 15: structure of compiler and operation system information
Example 8-6
Data structures for acceptance of compiler and operating system information by means of the ACCEPT statement
* 01 COMPILER-INFORMATION. 02 COMPILER-NAME PIC X(10). 02 COMPILER-VERSION PIC X(10). 02 DATE-OF-COMPILATION PIC X(10). 02 TIME-OF-COMPILATION PIC X(8). 02 PROGRAM-NAME PIC X(30). * 01 CPU-TIME-IN-SECONDS PIC 9(6)V9(4). * 01 TASK-INFORMATION. 02 TASK-TYPE PIC X. 88 BATCH-TASK VALUE "B". 88 INTERACTIVE-TASK VALUE "D". 02 TASK-SEQUENCE-NUMBER PIC X(4). 02 USER-IDENTIFICATION PIC X(8). 02 ACCOUNT-NUMBER PIC X(8). 02 PRIVILEGE-IDENTIFIER PIC X. 88 SYSTEM-ADMINISTRATOR VALUE "S". 88 USER VALUE "U". 02 OPERATING-SYSTEM-VERSION PIC X(10). 02 PROCESSOR-NAME PIC X(8). 02 SYSTEM-ADMINISTRATOR-PRIVILEGE PIC X(80). * 01 TERMINAL-INFORMATION. 02 TERMINAL-NAME PIC X(8). 02 CHARS-PER-LINE PIC 9(5). 02 LINES-PER-SCREEN PIC 9(5). 02 CHARS-PER-SCREEN PIC 9(5). 02 DEVICE-TYPE PIC X(4). * 01 CURRENT-DATE. 05 YEAR PIC X(4). 05 FILLER PIC X. 05 MONTH PIC X(2). 05 FILLER PIC X. 05 DAY-OF-THE-MONTH PIC X(2). 05 DAY-OF-THE-YEAR PIC X(3). 05 FILLER PIC X.