Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Compilation error: Operand time-of-day is not declared

Compilation error: Operand time-of-day is not declared

Problem:

When compiling a program, the following error is reported by the compiler:

Operand time-of-day is not declared

Resolution:

In both the Server Express documentation and the Visual COBOL documentation, the special register TIME-OF-DAY is documented as being applicable to the OSVS dialect. In addition, the documentation generally says:

 TIME-OF-DAY    9(6) DISPLAY

The TIME-OF-DAY special register contains the value of the current time of day (24-hour clock) (as supplied by the COBOL execution environment), in the form: hhmmss where hh =hour, mm=minutes, and ss= seconds.  TIME-OF-DAY is valid only as the sending area of a MOVE statement.

Based on the above, here is a sample program I wrote to test this:

000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. TOD-TEST.
000003 ENVIRONMENT DIVISION.
000004 CONFIGURATION SECTION.
000005 DATA DIVISION.
000006 WORKING-STORAGE SECTION.
000007 01 TIME-OF-DAY-WS PIC 9(6).
000008 PROCEDURE DIVISION.
000009     MOVE TIME-OF-DAY TO TIME-OF-DAY-WS.
000010     DISPLAY 'TIME-OF-DAY IS ' TIME-OF-DAY-WS.
000011     STOP RUN.

This compiles successfully under Visual COBOL, and also under Server Express, if and only if one the following compiler directives is specified: OSVS or DOSVS or DIALECT"OSVS" or DIALECT"DOSVS".  Here are example command lines:

$> cob TOD-TEST.cbl                   <-- Fails
     9     MOVE TIME-OF-DAY TO TIME-OF-DAY-WS.
*  12-S********************                                                  **
**    Operand TIME-OF-DAY is not declared
cob32: error(s) in compilation: TOD-TEST.cbl
$> cob -C OSVS          TOD-TEST.cbl  <-- Succeeds
$> cob -C DOSVS         TOD-TEST.cbl  <-- Succeeds
$> cob -C DIALECT=OSVS  TOD-TEST.cbl  <-- Succeeds
$> cob -C DIALECT=DOSVS TOD-TEST.cbl  <-- Succeeds

To make it work with Visual COBOL, specify the OSVS compiler directive, or within a Visual COBOL for Eclipse project, under Properties > Micro Focus > Project Settings > COBOL, in the drop-down named "Language dialect", select "OS/VS COBOL".

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2016-11-01 14:16
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.