Está en la página 1de 28

Migrating to IBM COBOL for AIX Mi

Migrating to IBM COBOL for AIX

Migrating to IBM COBOL for AIX Mi

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.

Migrating to IBM COBOL for AIX Mi

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.

Migrating to IBM COBOL for AIX Mi

Table of Contents Acknowledgment ___________________________________________ 3 Introduction _______________________________________________ 5


File suffix of ".cob" for COBOL source______________________________ 5 Free-format COBOL source files ___________________________________ 6 Alphanumeric literal longer than 160 characters in COBOL source files __ 7 MOVE from national data item to alphanumeric data item _____________ 8 Procedure using same name as the program identifier__________________ 8 REPORT SECTION and SCREEN SECTION_______________________ 10 OCCURS clause in level 01 _______________________________________ 10 User-defined word as both data name and procedure name ____________ 12 Extra and misplaced periods in COBOL source ______________________ 13 Undefined symbol errors for C functions being called _________________ 14 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 ______________________________ 15 Embedded NULLs replaced by blank characters _____________________ 16 BINARY formatted data in an ACCEPT statement ___________________ 16 Hyphen in an ASSIGN statement __________________________________ 17 Format of floating point literals ___________________________________ 19 Identification division must be the first division in each COBOL source program, factory definition, object definition, and method definition ____ 20 NULL in a CALL statement ______________________________________ 21 COMP-X ______________________________________________________ 22 RECORD SEQUENTIAL file organization__________________________ 23 Runtime error occurs due to an uninitialized variable being converted to a display type ____________________________________________________ 24 Output contains a plus sign (+) when displaying positive numbers_______ 25 Redefined data item and OCCURS clause___________________________ 26 Modify Boolean PICTURE character string and literal________________ 27

Migrating to IBM COBOL for AIX Mi

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/.

File suffix of ".cob" for COBOL source


COBOL for AIX, PTF 3.1.0.3 or COBOL for AIX, V4.1 provides support for the .cob suffix for COBOL source files. You can now compile a COBOL program using a .cob suffix in addition to the .cbl suffix.
$ cob2 -o tcCobol tcCobol.cob PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... End of compilation 1, program TEST-CASE, no statements flagged.

Migrating to IBM COBOL for AIX Mi

Free-format COBOL source files


When you use IBM COBOL for AIX to compile source code that contains free-format COBOL source, you receive the messages shown below:
$ cat tcFreeFormat.cbl 000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. FreeFormat. 000300 ENVIRONMENT DIVISION. 000400 DATA DIVISION. 000500 000600 PROCEDURE DIVISION. 000700 BEGIN-MY-PROGRAM. 000800 DISPLAY "COBOL ON AIX 3.1.0...". 000900 STOP RUN. $ cob2 tcFreeFormat.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 6 IGYPS0017-E "PROCEDURE" should begin in area "A". It was processed as if found in area "A". 8 IGYPS0009-E "DISPLAY" should not begin in area "A". It was processed as if found in area "B". Messages Total Informational Warning Error Severe Terminating Printed: 2 2 End of compilation 1, program FREEFORMAT, highest severity: Error. Return code 8

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.

Migrating to IBM COBOL for AIX Mi

Alphanumeric literal longer than 160 characters in COBOL source files


When you use IBM COBOL for AIX to compile source code that contains one or more alphanumeric literals longer than 160 characters, you receive the message shown below:
$ cat tcAlphanumeric160.cbl 000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. TEST-CASE. 000300 ENVIRONMENT DIVISION. 000400 000500 DATA DIVISION. 000600 WORKING-STORAGE SECTION. 000700 000800 01 VARIABLE PIC N(300) VALUE "BEGIN = = = = = = = 000900" = = = = = = = = = = = = = = = = = = = = = 001000" = = = = = = = = = = = = = = = = = = = = = 001100" = = = = = = = = = = = = = = = = = = = = = 001200"= = = = = = = = = = = = = = = END". 001300 001400 PROCEDURE DIVISION. 001500 DISPLAY VARIABLE. 001600 STOP RUN. $ cob2 -o tcAlphanumeric160 tcAlphanumeric160.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 8 IGYDS0026-E An alphanumeric literal that was longer than 160 characters was specified. The literal was truncated to 160 characters. Messages Total Informational Warning Error Severe Terminating Printed: 1 1 End of compilation 1, program TEST-CASE, highest severity: Error. Return code 8

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:).

Migrating to IBM COBOL for AIX Mi

MOVE from national data item to alphanumeric data item


When you use IBM COBOL for AIX to compile source code that contains a MOVE statement from a national data item to an alphanumeric data item, you receive the message shown below:
$ cat tcNational2Alphanumeric.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. ND2AD. 000030 ENVIRONMENT DIVISION. 000040 CONFIGURATION SECTION. 000050 000060 DATA DIVISION. 000070 WORKING-STORAGE SECTION. 000080 000090 01 DataNational PIC N(100). 000100 000110 01 DataAlphanumeric PIC X(100). 000120 000130 PROCEDURE DIVISION. 000140 MOVE DataNational TO DataAlphanumeric. 000150 STOP-MY-PROGRAM. 000160 STOP RUN.

$ 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.

Procedure using same name as the program identifier


The following COBOL source contains a procedure name using the same name as the program identifier:
$ cat tcSameName.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. GREETING. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 PROCEDURE DIVISION. 000070 000080 MY-PARAGRAPH. 000090 PERFORM GREETING. 000100 PERFORM END-PARAGRAPH.

Migrating to IBM COBOL for AIX Mi

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.

Migrating to IBM COBOL for AIX Mi

REPORT SECTION and SCREEN SECTION


When you use IBM COBOL for AIX to compile source code that contains REPORT SECTION and SCREEN SECTION, you receive the messages shown below:
$ cat tcReportScreenSection.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 REPORT SECTION. 000070 01 TYPE IS PAGE HEADING. 000080 01 TYPE IS PAGE FOOTING. 000090 000100 SCREEN SECTION. $ cob2 -o tcReportScreenSection tcReportScreenSection.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 6 IGYDS0148-S "REPORT" is a reserved word related to language not supported by this compiler. The statement was discarded. 6 IGYDS1089-S "REPORT" was invalid. Scanning was resumed at the next area "A" item, level-number, or the start of the next clause. 10 IGYDS0009-E "SCREEN" should not begin in area "A". It was processed as if found in area "B". 10 IGYDS1089-S "SCREEN" 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: 10 4 6 End of compilation 1, program TEST-CASE, highest severity: Severe. Return code 12

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.

OCCURS clause in level 01


When you use IBM COBOL for AIX to compile source code that contains an OCCURS clause in level 01, you receive the messages shown below:
$ cat tcOccursClause.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 WORKING-STORAGE SECTION. 000061 000062 000063 01 EMPLOYEES OCCURS 100 TIMES. 000064 05 FNAME PIC X(10). 000065 05 LNAME PIC X(10). 000066 05 SALARY PIC 9(5). 000067

10

Migrating to IBM COBOL for AIX Mi

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

FNAME(1). LNAME(1). SALARY(1). FNAME(2). LNAME(2). SALARY(2).

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

Migrating to IBM COBOL for AIX Mi

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.

User-defined word as both data name and procedure name


When you use IBM COBOL for AIX to compile source code that contains a user-defined word, for example, GREETING used as both a data name and a procedure name, you receive the messages shown below:
$ cat 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 GREETING. 000120 PERFORM END-PROGRAM. 000130 000140 GREETING. 000150 DISPLAY "HELLO " GREETING. 000160 END-PROGRAM. 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

12

Migrating to IBM COBOL for AIX Mi

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.

Extra and misplaced periods in COBOL source


When you use IBM COBOL for AIX to compile source code that contains extra and misplaced periods, you receive the messages shown below:
$ cat 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. $ cob2 -o tcPeriods tcPeriods.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 8 IGYPS0009-E ". " should not begin in area "A". It was processed as if found in area "B".Same message on line: 13 8 IGYPS0019-W No COBOL statement was found between periods. Messages Total Informational Warning Error Severe Terminating Printed: 3 1 2 End of compilation 1, program TEST-CASE, highest severity: Error. Return code 8

13

Migrating to IBM COBOL for AIX Mi

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.

Undefined symbol errors for C functions being called


When you use IBM COBOL for AIX to compile source code that contains a call to a C function in mixed or lowercase characters, you receive the messages shown below:
$ cat cTest.c void CFunction(){ printf("HELLO FROM C...\n"); } $ cat tcCallCFunction.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 CONFIGURATION SECTION. 000050 DATA DIVISION. 000060 WORKING-STORAGE SECTION. 000070 000080 PROCEDURE DIVISION. 000090 CALL "CFunction" 000100 DISPLAY "HELLO FROM COBOL...". 000110 STOP RUN. $ xlc -c cTest.c $ cob2 -o tcCallCFunction 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. ld: 0711-317 ERROR: Undefined symbol: .CFUNCTION ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.

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

Migrating to IBM COBOL for AIX Mi

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

Migrating to IBM COBOL for AIX Mi

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.

Embedded NULLs replaced by blank characters


When you use IBM COBOL for AIX to compile source code that contains a variable with embedded null characters, COBOL for AIX removes these null characters. See the output of MY-DATA. The null characters are removed.
$ cat tcBlankReplaceNull.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. "TEST-CASE". 000030 ENVIRONMENT DIVISION. 000040 CONFIGURATION SECTION. 000050 DATA DIVISION. 000060 WORKING-STORAGE SECTION. 000080 77 MY-DATA PIC X(5) VALUE X"4F4E00004E". 000120 PROCEDURE DIVISION. 000125 DISPLAY MY-DATA "<-". 000130 STOP RUN. $ cob2 tcBlankReplaceNull.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 ONN<-

BINARY formatted data in an ACCEPT statement


When you use IBM COBOL for AIX to compile source code that contains BINARY formatted data in an ACCEPT statement, you receive the message shown below:
$ cat tcAcceptBinary.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 WORKING-STORAGE SECTION. 000070 01 EMPLOYEE-ID PIC S9(4) COMP-5 VALUE ZERO. 000080 000090 PROCEDURE DIVISION. 000100 MY-PROGRAM. 000110 DISPLAY "PLEASE INSERT EMPLOYEE'S ID NUMBER..". 000120 ACCEPT EMPLOYEE-ID. 000130 000140 STOP RUN. $ cob2 tcAcceptBinary tcAcceptBinary.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text

16

Migrating to IBM COBOL for AIX Mi

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.

Hyphen in an ASSIGN statement


When you use IBM COBOL for AIX to compile source code that contains a hyphen in the ASSIGN statement, you receive the message shown below:
$ cat 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 "SYS-FILENAME" 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.

17

Migrating to IBM COBOL for AIX Mi

$ 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

Migrating to IBM COBOL for AIX Mi

For more information about the ASSIGN clause, see ASSIGN clause in the COBOL for AIX, V3.1 Language Reference.

Format of floating point literals


When you use IBM COBOL for AIX to compile source programs that contain floating point literals not using an E-notation, for example, as 1500.0 and not 1.5E3, you receive the messages shown below:
$ cat tcFloatingFormat.cbl 000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. TEST-CASE. 000300 ENVIRONMENT DIVISION. 000400 DATA DIVISION. 000500 000600 WORKING-STORAGE SECTION. 000700 01 FLOAT1 COMP-1 VALUE 1357.9. 000800 01 FLOAT2 COMP-1 VALUE 2468.0. 000900 001000 PROCEDURE DIVISION. 001100 DISPLAY "FLOAT 1 IS " FLOAT1. 001200 DISPLAY "FLOAT 2 IS " FLOAT2. 001300 STOP RUN. $ cob2 -o tcFloatingFormat tcFloatingFormat.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 7 IGYGR1080-S A "VALUE" clause literal was not compatible with the data category of the subject data item. The "VALUE" clause was discarded. Same message on line: 8 Messages Total Informational Warning Error Severe Terminating Printed: 2 2 End of compilation 1, program TEST-CASE, highest severity: Severe. Return code 12

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

Migrating to IBM COBOL for AIX Mi

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

Migrating to IBM COBOL for AIX Mi

$ 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.

NULL in a CALL statement


When you use IBM COBOL for AIX to compile source code that contains NULL in a CALL statement, you receive the message shown below:
$ cat tcCallNull.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 DATA DIVISION. 000050 000060 WORKING-STORAGE SECTION. 000070 000080 PROCEDURE DIVISION. 000090 CALL "TEST-CASE2" USING NULL VARIABLE. 000100 STOP RUN. $ cob2 -o tcCallNull tcCallNull.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 9 IGYPS2106-S "NULL" was found in the "CALL" statement. It was not allowed in this context. 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

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

Migrating to IBM COBOL for AIX Mi

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

Migrating to IBM COBOL for AIX Mi

RECORD SEQUENTIAL file organization


RECORD SEQUENTIAL file organization is not supported by COBOL for AIX, V3.1.
$cat tcRecordSequential.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000031 000032 INPUT-OUTPUT SECTION. 000033 FILE-CONTROL. 000034 SELECT CONTACTS 000035 ASSIGN TO "MYFILE.DAT" 000036 ORGANIZATION IS RECORD SEQUENTIAL. 000037 000040 DATA DIVISION. 000050 FILE SECTION. 000051 FD CONTACTS 000052 RECORD CONTAINS 80 CHARACTERS. 000053 01 CONTACT-RECORD. 000054 05 FNAME PIC X(10). 000055 05 LNAME PIC X(10). 000073 000090 PROCEDURE DIVISION. 000100 PERFORM OPEN-FILE. 000110 PERFORM INPUT-DATA. 000120 PERFORM SAVE-DATA. 000130 PERFORM CLOSE-FILE. 000140 PERFORM END-PROGRAM. 000150 000160 INPUT-DATA. 000170 DISPLAY "ENTER FIRST NAME.". 000180 ACCEPT FNAME. 000190 DISPLAY "ENTER LAST NAME.". 000200 ACCEPT LNAME. 000210 000220 OPEN-FILE. 000230 OPEN OUTPUT CONTACTS. 000240 000250 SAVE-DATA. 000260 WRITE CONTACT-RECORD. 000270 000280 CLOSE-FILE. 000290 CLOSE CONTACTS. 000300 000310 END-PROGRAM. 000320 STOP RUN. cob2 -o tcRecordSequential tcRecordSequential.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... LineID Message code Message text 9 IGYDS0093-S "RECORD" was found in the "ORGANIZATION" clause. The clause was discarded. 9 IGYDS1335-S Expected a data-name in a "RECORD KEY" clause, but found "SEQUENTIAL". The clause was discarded. 13 IGYGR1216-I A "RECORDING MODE" of "F" was assumed for file "CONTACTS". Messages Total Informational Warning Error Severe Terminating Printed: 3 1 2 End of compilation 1, program TEST-CASE, highest severity: Severe. Return code 12

23

Migrating to IBM COBOL for AIX Mi

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.

You receive these runtime error messages:


$ cob2 -o tcConvert2DisplayType tcConvert2DisplayType.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... End of compilation 1, program TEST-CASE, no statements flagged. $ tcConvert2DisplayType IWZ040S An invalid separate sign was detected. Message routine called from offset 0x48 of routine iwzWriteERRmsg. iwzWriteERRmsg called from offset 0xb4 of routine _iwzcBCD_CONV_ZndTS_To_ZndTO. _iwzcBCD_CONV_ZndTS_To_ZndTO called from offset 0x130 of routine TEST-CASE. IWZ901S Program exits due to severe or critical error. IOT/Abort trap(coredump)

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

Migrating to IBM COBOL for AIX Mi

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.

Output contains a plus sign (+) when displaying positive numbers


When you use IBM COBOL for AIX to compile source code that contains a positive number, the output does not display the plus sign (+):
$ cat tcPlusSign.cbl 000010 IDENTIFICATION DIVISION. 000020 PROGRAM-ID. TEST-CASE. 000030 ENVIRONMENT DIVISION. 000040 000050 INPUT-OUTPUT SECTION. 000060 000070 DATA DIVISION. 000080 WORKING-STORAGE SECTION. 000090 01 POSITIVE-NUM PIC S9(4) COMP-5 VALUE ZERO. 000100 01 NEGATIVE-NUM PIC S9(4) COMP-5 VALUE ZERO. 000110 000120 PROCEDURE DIVISION. 000130 COMPUTE POSITIVE-NUM = 10 - 3. 000140 COMPUTE NEGATIVE-NUM = 3 - 10. 000150 DISPLAY "10 - 3 = " POSITIVE-NUM. 000160 DISPLAY "3 - 10 = " NEGATIVE-NUM. 000170 STOP RUN. $ cob2 -o cat tcPlusSign tcPlusSign.cbl PP 5724-V62 IBM COBOL for AIX 3.1.0 in progress ... End of compilation 1, program TEST-CASE, no statements flagged. $ tcPlusSign 10 - 3 = 00007 3 - 10 = -00007

COBOL for AIX output does not contain a plus sign (+) when displaying positive numbers.

25

Migrating to IBM COBOL for AIX Mi

Redefined data item and OCCURS clause


When you use IBM COBOL for AIX to compile source code that contains a redefined object and the OCCURS clause, you receive the messages shown below:

$ 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

Migrating to IBM COBOL for AIX Mi

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.

Modify boolean PICTURE character string and boolean literal


When you use IBM COBOL for AIX to compile source code that contains a boolean PICTURE character string and a boolean literal in the format shown below, you receive the messages also shown below:

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

Migrating to IBM COBOL for AIX Mi

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

También podría gustarte