Microsoft KB Archive/45445

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

PIC S9(5) COMP with Certain Directives Gives Bad Values

PSS ID Number: Q45445 Article last modified on 04-20-1993

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

The information in this article applies to:
- Microsoft COBOL for MS-DOS and OS/2, versions 3.0 and 3.0a

Summary: In COBOL versions 3.0 or 3.0a, using all of the following directives together with a program containing PIC S9(5) COMP fields gives incorrect values: NOBOUND SIGN“EBCDIC” NOTRUNC MS“2” To work around this problem, use COMP-4 or a smaller field such as PIC S9(2). Microsoft has confirmed this to be a problem with versions 3.0 and 3.0a. This problem is corrected in Microsoft COBOL Professional Development System version 4.0 for MS-DOS and MS OS/2.

More Information: The following program does not increment the COUNTER and transfer data between LETTER-ARRAY-1 and LETTER-ARRAY-2. If you remove any of the directives, or change COUNTER to a PIC S9(5) COMP-4 or PIC S9(2) COMP, the program runs correctly. $SET NOBOUND $SET NOTRUNC $SET SIGN“EBCDIC” $SET MS“2” IDENTIFICATION DIVISION. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. DATA DIVISION. WORKING-STORAGE SECTION. 01 ALPHA PIC X(26) VALUE “ABCDEFGHIJKLMNOPQRSTUVWXYZ”. 01 LETTER-ARRAY-1 REDEFINES ALPHA. 05 A-LETTER-1 PIC X OCCURS 26 TIMES. 01 LETTER-ARRAY-2. 05 A-LETTER-2 PIC X OCCURS 26 TIMES. 01 COUNTER PIC S9(5) COMP. SCREEN SECTION. 01 BLANK-SCREEN. 03 BLANK SCREEN. PROCEDURE DIVISION. DISPLAY BLANK-SCREEN. MOVE 0 TO COUNTER PERFORM LOOP-PROCEDURE UNTIL COUNTER = 26 DISPLAY LETTER-ARRAY-2. STOP RUN. LOOP-PROCEDURE. COMPUTE COUNTER = COUNTER + 1 MOVE A-LETTER-1 (COUNTER) TO A-LETTER-2 (COUNTER)

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.