Microsoft KB Archive/49261

ACCEPT PIC $9.99 BLANK WHEN ZERO Hangs When ADIS Option 13 = 3

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

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

Summary: In Microsoft COBOL versions 3.00 and 3.00a, a program can hang when all of the following conditions are met: 1. The program is executing an ACCEPT WITH UPDATE. 2. The program accepts a numeric edited field that uses the $ editing character. 3. The data item is defined with the BLANK WHEN ZERO clause. 4. In ADISCF, F6=Choose is used to select Microsoft V2 Compatibility. This sets up a specific set of ADIS options. 5. The ADIS individual option 13, “Accepts into numeric edited fields,” is set to option 3 or 4. 6. When the program is executed, any series of numbers except the digit 9 is entered. Microsoft has confirmed this to be a problem with Microsoft COBOL versions 3.00 and 3.00a for MS-DOS and MS OS/2. This problem has been corrected in Microsoft COBOL Professional Development System version 4.00 for MS-DOS and MS OS/2.

More Information: The program does not hang when ADIS individual option 13 is set to options 1 or 2 or when the UPDATE clause is omitted on the ACCEPT. However, the easiest workaround for this problem is to remove the BLANK WHEN ZERO clause from the WORKING-STORAGE SECTION data definition. In place of the $ PICTURE character, you can use the Z PICTURE character to cause the accept to be BLANK WHEN ZERO. For example, in the program below, the data item could have a PIC $Z(6)9.99 clause.

Code Example
The following code sample hangs when the field is overrun: Compile line: COBOL test.cob; Link line: LINK test.obj; Program: WORKING-STORAGE SECTION. 01 TEST-DATA PIC $(7)9.99 BLANK WHEN ZERO. PROCEDURE DIVISION. MAIN. ACCEPT TEST-DATA WITH UPDATE. STOP RUN. This problem occurs only when you enter a number without a 9 in it. If a number with a 9 is entered, the overflow will go on to the decimal portion, but there is another side effect. On passing the decimal, the first 9 is replaced with the first digit in the number entered. When the ACCEPT terminates, the digit is instantly changed back to a 9. To duplicate the problem with the above program, take the following series of steps: 1. Enter 12934567 (at this point, the decimal is passed). The number now appears as 2134567.00 (9 replaced with 1). 2. The cursor is now on the first 0 past the decimal. Complete the accept (press ENTER key). The number now appears as 2934567.00 (1 replaced with 9).

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