Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Disclaimer
December 2010 Other company, product and service names may be trademarks or service marks of others. The information contained in this documentation is provided for informational purposes only. While efforts were made to verify the completeness and accuracy of the information contained in this documentation, it is provided as is without warranty of any kind, express or implied. In addition, this information is based on IBMs current product plans and strategy, which are subject to change by IBM without notice. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this documentation or any other documentation. Nothing contained in this documentation is intended to, nor shall have the effect of, creating any warranties or representations from IBM (or its suppliers or licensors), or altering the terms and conditions of the applicable license agreement governing the use of IBM software. The following terms are trademarks of International Business Machines Corporation in the United States, or other countries, or both: IBM The IBM logo AIX Other company, product and service names may be trademarks or service marks of others. Copyright International Business Machines Corporation 2010. US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Acknowledgment
The following extract from Government Printing Office Form Number 19650795689 is presented for the information and guidance of the user: Any organization interested in reproducing the COBOL report and specifications in whole or in part, using ideas taken from this report as the basis for an instruction manual or for any other purpose is free to do so. However, all such organizations are requested to reproduce this section as part of the introduction to the document. Those using a short passage, as in a book review, are requested to mention COBOL in acknowledgment of the source, but need not quote this entire section. COBOL is an industry language and is not the property of any company or group of companies, or of any organization or group of organizations. No warranty, expressed or implied, is made by any contributor or by the COBOL Committee as to the accuracy and functioning of the programming system and language. Moreover, no responsibility is assumed by any contributor, or by the committee, in connection there with. Procedures have been established for the maintenance of COBOL. Inquiries concerning the procedures for proposing changes should be directed to the Executive Committee of the Conference on Data Systems Languages. The authors and copyright holders of copyrighted material: FLOW-MATIC (Trademark of Sperry Rand Corporation), Programming for the UNIVAC(R) I and II, Data Automation Systems copyrighted 1958, 1959, by Sperry Rand Corporation IBM Commercial Translator, Form No. F28-8013, copyrighted 1959 by IBM FACT, DSI 27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell
have specifically authorized the use of this material in whole or in part, in the COBOL specifications. Such authorization extends to the reproduction and use of COBOL specifications in programming manuals or similar publications. Note: The Conference on Data Systems Languages (CODASYL), mentioned above, is no longer in existence.
Introduction
This document presents topics to help you migrate COBOL source programs to IBM COBOL for AIX, V3.1 or later. COBOL programs created using a COBOL compiler other than the COBOL for AIX, V3.1 or later compiler will normally have some source code differences that will need to be modified to become compatible with COBOL for AIX, V3.1 or later. These differences are often the result of implementer extensions to Standard COBOL, but might also be due to differences in the operating system, or maybe for items in the COBOL standard that are specified as "implementor defined", or some combination of these. The number of differences will depend largely on how many extensions to Standard COBOL were coded in the COBOL source members that you are migrating. In this document, the term Standard COBOL 2002 refers to ISO/IEC 1989:2002(E) Information technology Programming languages COBOL. This does not imply that COBOL for AIX, V3.1 or later has implemented the new features found in Standard COBOL 2002 (although some have been implemented), we are simply using Standard COBOL 2002 to help you to identify extensions to Standard COBOL that you might encounter as you do your migration, differences between COBOL for AIX, V3.1 or later and Standard COBOL, and to help you to determine the changes you might need to make to resolve these. It will be useful for you to refer to the COBOL for AIX, V3.1 or later Language Reference and the COBOL for AIX, V3.1 or later Programming Guide when modifying COBOL code. You can find these books at the IBM COBOL for AIX Library web site: www.ibm.com/software/awdtools/cobol/aix/library/.
COBOL for AIX, PTF 3.1.0.3 or COBOL for AIX, V4.1 provides support to suppress some of the messages related to enforcing fixed format source code. You can rewrite your source in fixed format, or use a generally available utility to convert your source from free-format source to fixed format source.
$ cat sol-tcFreeFormat.cbl 000001 IDENTIFICATION DIVISION. 000002 PROGRAM-ID. FreeFormat. 000003 ENVIRONMENT DIVISION. 000004 DATA DIVISION. 000005 PROCEDURE DIVISION. 000006 000007 BEGIN-MY-PROGRAM. 000008 000009 DISPLAY "COBOL ON AIX 3.1.0...". 000010 STOP-MY-PROGRAM. 000011 STOP RUN.
According to Standard COBOL 2002 section 8.3.1.2.1.2 the length of an alphanumeric literal, excluding the separators that delimit the literal, shall be greater than zero and less than or equal to 160 alphanumeric character positions. Some precompilers provide an option to change the maximum length for a string literal to 160 characters to avoid generating invalid source code. Change your COBOL source to follow Standard COBOL 2002. You can change your code to split long literals. For example:
MOVE longliteral to ITEM-1. can be split as shown below: MOVE long to ITEM-1(1:4). MOVE literal to ITEM-1(5:).
$ cob2 -o tcNational2Alphanumeric tcNational2Alphanumeric.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 14 IGYPA3005-S "DATANATIONAL (NATIONAL ITEM)" and "DATAALPHANUMERIC (ALPHANUMERIC)" did not follow the "MOVE" statement compatibility rules. The statement was discarded. Messages Total Informational Warning Error Severe Terminating Printed: 1 1 End of compilation 1, program ND2AD, highest severity: Severe. Return code 12
According to STANDARD COBOL 2002 section 14.8.24.2 Syntax rules for the MOVE statement, you cannot MOVE a national data item to an alphanumeric data item. Change your COBOL source to follow Standard COBOL 2002.
000110 000120 GREETING. 000130 DISPLAY "WELCOME TO IBM COBOL FOR AIX 3.1.0...". 000140 000150 END-PARAGRAPH. 000160 DISPLAY "HAVE A NICE DAY!". 000170 STOP RUN. $ cob2 -o tcSameName tcSameName.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 9 IGYPA3007-S "GREETING" was not defined as a procedure-name. The statement was discarded. 12 IGYPS2007-E "GREETING" was defined as both a procedure-name and another data type. The procedure-name definition was discarded. Messages Total Informational Warning Error Severe Terminating Printed: 2 1 1 End of compilation 1, program GREETING, highest severity: Severe. Return code 12
According to Standard COBOL 2002 section 8.3.1.1 User-defined words, within a source element, a given user-defined word may be used as only one type of user-defined word. Further rules for uniqueness are specified in 8.4.1, Uniqueness of reference. Change your COBOL source to follow Standard COBOL 2002.
$ cat sol-tcSameName.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. GREETING. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 PROCEDURE DIVISION. 000070 000060 MY-PARAGRAPH. 000080 PERFORM HELLO. 000090 PERFORM END-PARAGRAPH. 000100 000110 HELLO. 000120 DISPLAY "WELCOME TO IBM COBOL FOR AIX 3.1.0...". 000130 000140 END-PARAGRAPH. 000150 DISPLAY "HAVE A NICE DAY!". 000160 STOP RUN.
Standard COBOL 2002 documents 13.7 Report section and section 13.8 Screen section. COBOL for AIX does not support REPORT SECTION or SCREEN SECTION.
10
000068 000070 000071 000072 000073 000074 000075 000076 000077 000078 000080 000081 000082 000083 000084 000085 000086 000090
77 COUNTER PIC 9. PROCEDURE DIVISION. MOVE "DAVID" TO MOVE "SMITH" TO MOVE "60000" TO MOVE "JENNY" TO MOVE "HU" TO MOVE "55000" TO
DISPLAY-RESULT. PERFORM VARYING COUNTER FROM 1 BY 1 UNTIL COUNTER > 2 DISPLAY "EMPLOYEE: " FNAME IN EMPLOYEES(COUNTER)" " LNAME IN EMPLOYEES(COUNTER)" " "Salary: " SALARY IN EMPLOYEES(COUNTER) END-PERFORM. STOP-PROGRAM. STOP RUN.
$ cob2 -o tcOccursClause tcOccursClause.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 9 IGYDS1063-E An "OCCURS" clause was found in the definition of a level-1 item. The "OCCURS" clause was discarded. 17 IGYPS2120-S Expected a reference-modification specification but found ")". The "MOVE" statement was discarded. Same message on line: 18 19 20 21 22 26 IGYPS2120-S Expected a reference-modification specification but found ")". The "DISPLAY" statement was discarded. Messages Total Informational Warning Error Severe Terminating Printed: 8 1 7 End of compilation 1, program TEST-CASE, highest severity: Severe. Return code 12
According to Standard COBOL 2002 section 13.16.36.2, Syntax rules for the OCCURS clause, the OCCURS clause shall not be specified in a data description entry that: a) Has a level-number of 01, 66, 77, or 88, or b) Has a variable-occurrence data item subordinate to it. You can change your code so that it compiles without messages. For example, if you change the code above using the definition of EMPLOYEES moved from level 01 to level 03, it will compile without messages:
$ cat sol-tcOccursClause.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 WORKING-STORAGE SECTION. 000061 000063 01 EMPLOYEES. 000064 03 EMPLOYEE OCCURS 100 TIMES. 000065 05 FNAME PIC X(10). 000066 05 LNAME PIC X(10). 000067 05 SALARY PIC 9(5). 000068 000069 77 COUNTER PIC 9. 000070
11
000071 PROCEDURE DIVISION. 000072 MOVE "DAVID" TO FNAME(1). 000073 MOVE "SMITH" TO LNAME(1). 000074 MOVE "60000" TO SALARY(1). 000075 MOVE "JENNY" TO FNAME(2). 000076 MOVE "HU" TO LNAME(2). 000077 MOVE "55000" TO SALARY(2). 000078 000080 DISPLAY-RESULT. 000082 PERFORM VARYING COUNTER FROM 1 BY 1 UNTIL COUNTER > 2 000084 DISPLAY "EMPLOYEE: " FNAME IN EMPLOYEE(COUNTER) " " 000085 LNAME IN EMPLOYEE(COUNTER) " " 000085 "Salary: " SALARY IN EMPLOYEE(COUNTER) 000086 END-PERFORM. 000087 STOP-PROGRAM. 000120 STOP RUN.
According to STANDARD COBOL 2002 section 8.3.1.1 User-defined words, within a source element, a given user-defined word may be used as only
12
one type of user-defined word. Further rules for uniqueness are specified in 8.4.1, Uniqueness of reference. Change your COBOL source to follow Standard COBOL 2002.
$ cat sol-tcSameName2.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 WORKING-STORAGE SECTION. 000070 000080 01 GREETING PIC X(20) VALUE "FROM IBM.". 000090 PROCEDURE DIVISION. 000100 MY-PROGRAM. 000110 PERFORM MY-GREETING. 000120 PERFORM END-PROGRAM. 000130 000140 MY-GREETING. 000150 DISPLAY "HELLO " GREETING. 000160 END-PROGRAM. 000170 STOP RUN.
13
According to Standard COBOL 2002 section 6.2 Fixed-form reference format, fixed-format source does not include extra or missing periods in the source. Change your COBOL source to follow Standard COBOL 2002.
$ cat sol-tcPeriods.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 PROCEDURE DIVISION. 000070 PERFORM GREETING. 000080 000090 000100 PERFORM END-PROGRAM. 000110 000120 GREETING. 000130 000140 000150 DISPLAY "HELLO FROM IBM.". 000160 END-PROGRAM. 000170 STOP RUN.
Because the COBOL for AIX compiler folds program-names to uppercase, if you have COBOL source that contains a call to a C function in mixed or lowercase characters, this function will be folded to uppercase characters.
14
The linker will not find the program and will produce an error message that indicates an unresolved symbol. You can use the PGMNAME compiler option to control how the COBOL for AIX compiler handles program-names. The default is PGMNAME(UPPER), but you can use PGMNAME(MIXED) to process the program-name as is, without truncation, translation or folding to uppercase. When you use PGMNAME(MIXED), remember to use the literal format of the programname, that is, make the program-name a literal string, for example programname or you will see the following message:
IGYDS1046-E A user-defined word was found as a "PROGRAM-ID" name under the "PGMNAME(LONGMIXED)" compiler option.
When "PGMNAME(LONGMIXED)" is in effect, a literal is expected for the "PROGRAM-ID" name. The name is accepted in its uppercased format. For an example about a COBOL program that calls C functions, see Example: COBOL program calling C functions in the COBOL for AIX, V3.1 Programming Guide.
$ cat sol-tcCallCFunction.cbl 000010 CBL PGMNAME(LONGMIXED) 000020 IDENTIFICATION DIVISION. 000030 PROGRAM-ID. "TEST-CASE". 000040 ENVIRONMENT DIVISION. 000050 CONFIGURATION SECTION. 000060 DATA DIVISION. 000070 WORKING-STORAGE SECTION. 000080 000090 PROCEDURE DIVISION. 000100 CALL "CFunction" 000110 DISPLAY "HELLO FROM COBOL...". 000120 STOP RUN. $ cob2 -o sol-tcCallCFunction sol-tcCallCFunction.cbl cTest.o PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... End of compilation 1, program TEST-CASE, no statements flagged. $ sol-tcCallCFunction HELLO FROM C... HELLO FROM COBOL...
At runtime a COBOL program containing an ACCEPT statement that assigns an input line that is longer than the data item, results in the remaining characters being discarded
In COBOL for AIX, the ACCEPT statement assigns the input line to the data item. If the input line is shorter than the data item, the data item is padded with spaces of the appropriate representation. When a program reads from a screen and the input line is longer than the data item, the remaining characters are discarded. When a program reads from a file and the input line is longer than the data item, the remaining characters are retained as the next input line for the file.
15
If the input data is longer than the receiving area, then COBOL for AIX pads the area with spaces of the appropriate representation for the receiving area. According to Standard COBOL 2002 section 14.8.1.3 General rules for the ACCEPT statement, the implementer shall define, for each hardware device, the size of a data transfer.
16
12 IGYPA3018-S Identifier "EMPLOYEE-ID (BINARY INTEGER)" was used in an "ACCEPT" statement. The statement was discarded. Messages Total Informational Warning Error Severe Terminating Printed: 1 1 End of compilation 1, program TEST-CASE, highest severity: Severe. Return code 12
According to STANDARD COBOL 2002 section 14.8.1.3 General, The ACCEPT statement causes the transfer of data from the hardware device. This data replaces the content of the data item referenced by identifier-1. Any conversion of data required between the hardware device and the data item referenced by identifier-1 is defined by the implementer. The COBOL for AIX implementation only allows displayable data (display, national, numeric, alphanumeric) which precludes binary formatted data. You can change the data type from COMP-5 to DISPLAY, but you will need to make further changes to the input source as well.
$ cat sol-tcAcceptBinary.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 WORKING-STORAGE SECTION. 000070 01 EMP-ID PIC 9(4) VALUE ZEROES. 000080 01 EMPLOYEE-ID PIC S9(4) COMP-5 VALUE ZERO. 000090 000100 PROCEDURE DIVISION. 000110 MY-PROGRAM. 000120 DISPLAY "PLEASE INSERT EMPLOYEE'S ID NUMBER..". 000130 ACCEPT EMP-ID. 000140 MOVE EMP-ID TO EMPLOYEE-ID. 000150 STOP RUN.
17
$ cob2 -o tcHyphenAssign tcHyphenAssign.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 12 IGYGR1387-S File system id SYS was specified for a file with "ORGANIZATION LINE SEQUENTIAL". The file system id was changed to NAT. Messages Total Informational Warning Error Severe Terminating Printed: 1 1 End of compilation 1, program TEST-CASE, highest severity: Severe. Return code 12$
The COBOL for AIX, V3.1 Language Reference describes the format of the ASSIGN clause as '<file-system-ID>-<system-file name>'. If there is a hyphen in the environment variable or the data name value, the first three characters to the left of the leftmost hyphen are treated as the file-system identifier. The character string to right of the leftmost hyphen is then used as the system file name (possibly including drive and path names). In the above source, the COBOL for AIX compiler takes the first three characters to the left of the leftmost hyphen, in this case, SYS and treats SYS as the file-system-identifier. The character string to the right of the leftmost hyphen is then used as the system file name, in this case, FILENAME. If there is no hyphen, or the character string to the left of the leftmost hyphen is less than three characters long, the entire character string is used as the system file name (possibly including drive and path names). So specifying S-FILENAME in the ASSIGN clause would work instead since the number of characters before the hyphen is less than three characters. Alternatively, you can specify SYSFILENAME in the ASSIGN clause.
$ cat sol-tcHyphenAssign.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. "TEST-CASE". 000030 ENVIRONMENT DIVISION. 000040 CONFIGURATION SECTION. 000050 INPUT-OUTPUT SECTION. 000060 FILE-CONTROL. 000070 SELECT DATA-INFO ASSIGN TO "SYSFILENAME" ORGANIZATION IS LINE SEQUENTIAL. 000080 DATA DIVISION. 000090 FILE SECTION. 000100 FD DATA-INFO. 000110 01 INFO-1 PIC N(132). 000120 PROCEDURE DIVISION. 000130 STOP RUN.
The COBOL for AIX compiler also handles LINE SEQUENTIAL by using the native (NAT) file-system-identifier. The same behavior results if you specified STL- FILENAME.
18
For more information about the ASSIGN clause, see ASSIGN clause in the COBOL for AIX, V3.1 Language Reference.
The COBOL for AIX compiler uses this format for floating point literals: [+|-] <mantissa>E [+|-] <exponent>. For more information about the "Rules for Floating Point Literals", see Numeric literals in the COBOL for AIX, V3.1 Language Reference.
$ cat sol-tcFloatingFormat.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 WORKING-STORAGE SECTION. 000070 01 FLOAT1 COMP-1 VALUE 1.3579E3. 000080 01 FLOAT2 COMP-1 VALUE 2.4680E3. 000090 000100 PROCEDURE DIVISION. 000110 DISPLAY "FLOAT 1 IS " FLOAT1. 000120 DISPLAY "FLOAT 2 IS " FLOAT2. 000130 STOP RUN.
19
Identification division must be the first division in each COBOL source program, factory definition, object definition, and method definition
When you use IBM COBOL for AIX to compile source code that contains an Identification division not as the first division in a COBOL source program, you receive the messages shown below:
$ cat tcIdentificationDivision.cbl 000010 ENVIRONMENT DIVISION. 000020 DATA DIVISION. 000030 000040 WORKING-STORAGE SECTION. 000050 01 GREETING GLOBAL PIC X(50) VALUE "HELLO FROM IBM...". 000060 01 GOODBYE GLOBAL PIC X(50) VALUE "HAVE A NICE DAY...". 000070 000080 IDENTIFICATION DIVISION. 000090 PROGRAM-ID. TEST-CASE. 000100 000110 PROCEDURE DIVISION. 000120 DISPLAY GREETING. 000130 DISPLAY GOODBYE. 000140 STOP RUN. $ cob2 -o tcIdentificationDivision tcIdentificationDivision.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 1 IGYDS1101-S Expected "IDENTIFICATION DIVISION" header, but found "ENVIRONMENT". "IDENTIFICATION DIVISION" header was assumed before "ENVIRONMENT". 8 IGYDS1003-E A "PROGRAM-ID" paragraph was not found. Programname "CBLNAM01" was assumed. 39 IGYSC0136-E End of source file was encountered or an "END PROGRAM" marker for a containing program was found, but an "END PROGRAM" marker for program "TEST-CASE" was not found. "END PROGRAM TEST-CASE" was assumed. 39 IGYSC0136-E End of source file was encountered or an "END PROGRAM" marker for a containing program was found, but an "END PROGRAM" marker for program "CBLNAM01" was not found. "END PROGRAM CBLNAM01" was assumed. Messages Total Informational Warning Error Severe Terminating Printed: 4 3 1 End of compilation 1, program CBLNAM01, highest severity: Severe. Return code 12
The identification division must be the first division in each COBOL source program, factory definition, object definition, and method definition. For more information about the program identification division, see Identification division in the COBOL for AIX, V3.1 Language Reference. According to STANDARD COBOL 2002 section E4.1.1 Source level organization, a source unit is a set of COBOL statements as specified in this document and consists of an identification division followed optionally by an environment division and/or a data division and/or a procedure division.
20
$ cat sol-tcIdentificationDivision.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 WORKING-STORAGE SECTION. 000070 01 GREETING GLOBAL PIC X(50) VALUE "HELLO FROM IBM...". 000080 01 GOODBYE GLOBAL PIC X(50) VALUE "HAVE A NICE DAY...". 000090 000100 PROCEDURE DIVISION. 000110 DISPLAY GREETING. 000120 DISPLAY GOODBYE. 000130 STOP RUN.
The COBOL for AIX compiler does not allow NULL in a CALL statement. For more information about the CALL statement, see CALL statement in the COBOL for AIX, V3.1 Language Reference. According to STANDARD COBOL 2002 section 14.4.8.2 Syntax rules do not identify NULL as a valid parameter for the CALL statement.
$ cat sol-tcCallNull.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 WORKING-STORAGE SECTION. 000070 01 VARIABLE PIC X(50). 000080
21
000110 PROCEDURE DIVISION. 000140 CALL "TEST-CASE2" USING VARIABLE. 000150 STOP RUN.
COMP-X
When you use IBM COBOL for AIX to compile source code that contains COMP-X, you receive the message shown below:
$ cat tcCompX.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 WORKING-STORAGE SECTION. 000070 01 STU-ID PIC S9(4) COMP-X VALUE ZERO. $ cob2 -o tcCompX tcCompX.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 7 IGYDS1089-S "COMP-X" was invalid. Scanning was resumed at the next area "A" item, level-number, or the start of the next clause. Messages Total Informational Warning Error Severe Terminating Printed: 1 1 End of compilation 1, program TEST-CASE, highest severity: Severe. Return code 12
The COBOL for AIX compiler does not support COMP-X. Change COMP-X to COMP-5 and make the corresponding change to the PICTURE clause. You might need to keep the allocated storage for the data item the same. The following table summarizes COMP-5 storage allocation:
---------------------------------------------------Picture Storage representation ---------------------------------------------------S9(1) thru S9(4) Binary halfword (2 bytes) S9(5) thru S9(9) Binary fullword (4 bytes) S9(10) thru S9(18) Binary doubleword (8 bytes) 9(1) thru 9(4) Binary halfword (2 bytes) 9(5) thru 9(9) Binary fullword (4 bytes) 9(10) thru 9(18) Binary double word (8 bytes) ---------------------------------------------------For more information about COMP-5, see the USAGE clause in the COBOL for AIX, V3.1 Language Reference.
22
23
Change RECORD SEQUENTIAL to LINE SEQUENTIAL and then compile using COBOL for AIX.
Runtime error occurs due to an uninitialized variable being converted to a display type
When you use IBM COBOL for AIX to compile source code that contains an uninitialized variable, for example:
$cat tcConvert2DisplayType.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. "TEST-CASE". 000030 ENVIRONMENT DIVISION. 000040 CONFIGURATION SECTION. 000050 DATA DIVISION. 000060 WORKING-STORAGE SECTION. 000070 01 EMP-INFO. 000080 05 EMP-ID PIC S9(5) sign is trailing separate. 000090 01 EMP-ID2 PIC S9(4). 000100 PROCEDURE DIVISION. 000120 MOVE EMP-ID OF EMP-INFO TO EMP-ID2. 000130 STOP RUN.
In general, these runtime error messages are the result of a variable being moved from one area of storage to another area where the variable being moved has not been initialized or it does not contain valid data. Change EMP-ID OF EMP-INFO so it is initialized to 0. For example:
$ cat sol-tcConvert2DisplayType.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. "TEST-CASE". 000030 ENVIRONMENT DIVISION. 000040 CONFIGURATION SECTION. 000050 DATA DIVISION. 000060 WORKING-STORAGE SECTION. 000070 01 EMP-INFO. 000080 05 EMP-ID PIC S9(5) SIGN IS TRAILING SEPARATE VALUE ZERO. 000090 01 EMP-ID2 PIC S9(4). 000100 PROCEDURE DIVISION. 000120 MOVE EMP-ID OF EMP-INFO TO EMP-ID2. 000130 STOP RUN.
24
The program runs without error. In addition to initializing EMP-ID to 0, you can compile using -qwsclear which clears a programs WORKING-STORAGE to binary zeros when the program is initialized. The storage is cleared before any VALUE clauses are applied. This is not the preferred approach due to performance considerations. For more information about WSCLEAR, see WSCLEAR in the COBOL for AIX, V3.1 Language Reference.
COBOL for AIX output does not contain a plus sign (+) when displaying positive numbers.
25
$ cat tcRedefineOccurs.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 000050 DATA DIVISION. 000060 WORKING-STORAGE SECTION. 000070 000080 01 EMPLOYEE-INFO. 000090 03 EMPLOYEE OCCURS 50 TIMES. 000100 05 NAME PIC X(10). 000110 05 AGE PIC 9(3). 000120 03 NEW-EMPLOYEE REDEFINES EMPLOYEE. 000130 05 NAME PIC X(20). 000140 05 AGE PIC 9(3). 000150 000160 PROCEDURE DIVISION. 000170 STOP RUN. $ cob2 -o tcRedefineOccurs tcRedefineOccurs.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 12 IGYDS1152-S A definition of an object of a "REDEFINES" clause contained an "OCCURS" clause. The "REDEFINES" clause was discarded. Messages Total Informational Warning Error Severe Terminating Printed: 1 1 End of compilation 1, program TEST-CASE, highest severity: Severe. Return code 12
COBOL for AIX does not support a redefined data item and an OCCURS clause for the same data item. For more information about the REDEFINES clause, see REDEFINES clause in the COBOL for AIX, V3.1 Language Reference. According to Standard COBOL 2002 section 13.16.42.2 Syntax rules, the data item being redefined cannot contain an OCCURS clause. You can change your code so that it compiles without messages. For example, if you change the code above by adding a group item and renumbering, it will compile without messages:
$ cat tcRedefineOccurs.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 000050 DATA DIVISION. 000060 WORKING-STORAGE SECTION. 000070 000080 01 EMPLOYEE-INFO.
26
90 03 EMPLOYEE-GROUP. 91 05 EMPLOYEE OCCURS 50 TIMES. 000100 10 NAME PIC X(10). 000110 10 AGE PIC 9(3). 000120 03 NEW-EMPLOYEE REDEFINES EMPLOYEE-GROUP. 000130 05 NAME PIC X(20). 000140 05 AGE PIC 9(3). 000150 000160 PROCEDURE DIVISION. 000170 STOP RUN.
000010 000020 000030 000040 000050 000060 000061 000062 000063 000064 000065 000066 000067 000070 000071 000072 000074 000075 000076 000077 000078 000079 000080 000081
IDENTIFICATION DIVISION. PROGRAM-ID. TEST-CASE. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 IND-AREA. 05 MESSAGES OCCURS 99 TIMES PIC 1 INDICATOR1. 88 MESSAGE-OFF VALUE B'0'. 88 MESSAGE-ON VALUE B'1'. 01 MESSAGE-SET. 05 MESSAGE-1 PIC 9(2) VALUE 01. PROCEDURE DIVISION. SET MESSAGE-OFF(MESSAGE-1) TO TRUE. IF MESSAGE-ON(MESSAGE-1) DISPLAY "IT'S TRUE" ELSE DISPLAY "IT'S FALSE" END-IF. STOP-PROGRAM. STOP RUN.
> cob2 tcBooleanLiteral.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 9 IGYDS1149-S "1" was not a valid combination of "PICTURE" string characters. A "PICTURE" string of "S9(1)" was assumed. 9 IGYDS1089-S "INDICATOR1" was invalid. Scanning was resumed at the next area "A" item, level-number, or the start of the next clause. 10 IGYDS0001-W A blank was missing before character "'" in column 47. A blank was assumed. Same message on line: 11 10 IGYGR0145-S "B" was not defined as a "SYMBOLIC CHARACTERS" figurative constant. "B" was discarded. Same message on line: 11 10 IGYGR1239-S Level-88 "VALUE" literal "B" was not compatible with the data category of the conditional variable. The literal was discarded. Same message on line: 11
27
10 IGYGR1239-S Level-88 "VALUE" literal "'0'" was not compatible with the data category of the conditional variable. The literal was discarded. 11 IGYGR1239-S Level-88 "VALUE" literal "'1'" was not compatible with the data category of the conditional variable. The literal was discarded. 16 IGYPS2061-S An error was found in the definition of conditionname "MESSAGE-OFF". The reference to this condition-name was discarded. 16 IGYPS2120-S Expected a reference-modification specification but found ")". The "SET" statement was discarded. 18 IGYPS2061-S An error was found in the definition of conditionname "MESSAGE-ON". The reference to this condition-name was discarded. 18 IGYPS2120-S Expected a reference-modification specification but found ")". The "IF" statement was discarded. Messages Total Informational Warning Error Severe Terminating Printed: 14 2 12 End of compilation 1, program TEST-CASE, highest severity: Severe. Return code 12
Change the PICTURE character-string symbol to X and use hexadecimal notation for alphanumeric literals for the values of X. For more information about the symbols used in the PICTURE clause, see Symbols used in the PICTURE clause in the COBOL for AIX, V3.1 Language Reference. For more information about the hexadecimal notation for alphanumeric literals, see Hexadecimal notation for alphanumeric literals in the COBOL for AIX, V3.1 Language Reference.
000010 000020 000030 000040 000050 000060 000061 000062 000063 000064 000065 000066 000067 000070 000071 000072 000074 000075 000076 000077 000078 000079 000080 000081 IDENTIFICATION DIVISION. PROGRAM-ID. TEST-CASE. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 IND-AREA. 05 MESSAGES OCCURS 99 TIMES PIC X. 88 MESSAGE-OFF VALUE X'00'. 88 MESSAGE-ON VALUE X'01' THROUGH X'FF'. 01 MESSAGE-SET. 05 MESSAGE-1 PIC 9(2) VALUE 01. PROCEDURE DIVISION. SET MESSAGE-OFF(MESSAGE-1) TO TRUE. IF MESSAGE-ON(MESSAGE-1) DISPLAY "IT'S TRUE" ELSE DISPLAY "IT'S FALSE" END-IF. STOP-PROGRAM. STOP RUN.
> cob2 sol-tcBooleanLiteral.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... End of compilation 1, program TEST-CASE, no statements flagged. > a.out IT'S FALSE
28