Microsoft KB Archive/33625

Moving Many Literals to Data Item Can Produce Incorrect Result

PSS ID Number: Q33625 Article last modified on 04-21-1993

2.20 MS-DOS

Summary: When moving several literals to a data item (using the MOVE statement), the data item that the literal is MOVEd into contains incorrect contents when written to a file. Microsoft has confirmed this to be a problem in version 2.2. This problem was corrected in version 3.0 of the Microsoft COBOL Compiler.

More Information: A source code example of the problem can be found in the Software/Data Library in a file named SHOWERR. SHOWERR can be found in the Software/Data Library Library by searching on SHOWERR, the Q number of this article, or S12009. SHOWERR was archived using the PKware file-conversion utility. The following is the output from the COBOL program SHOWERR.COB: LITERAL NUMBER 1………………………….. LITERAL NUMBER 2………………………….. LITERAL NUMBER 3………………………….. LITERAL NUMBER 4………………………….. LITERAL NUMBER 5………………………….. . . . LITERAL NUMBER 40…………………………. LITERAL NUMBER 41…………………………. ……………………….LITERAL NUMBER 40… ……………………….LITERAL NUMBER 41… ……………………….LITERAL NUMBER 42… ……………………….LITERAL NUMBER 43… The last four lines of the output file are incorrect. They should read as follows: LITERAL NUMBER 42…………………………. LITERAL NUMBER 43…………………………. LITERAL NUMBER 44…………………………. LITERAL NUMBER 45…………………………. When moving “LITERAL NUMBER 42…………………….” to a data item, the literal “…………………..LITERAL NUMBER 40…” is MOVEd there instead, which is not the expected result. The following are workarounds for this problem: 1. Instead of using literals, use data items in the WORKING-STORAGE SECTION to MOVE the value to the data item. Using this method produces the correct results, as in the following example: WORKING STORAGE contains the following: 01 A-DATA-ITEM. 05 FILLER PIC X(50) VALUE “LITERAL NUMBER 1…………………………..”. PROCEDURE DIVISION contains the following: MOVE A-DATA-ITEM TO SHOWERR-RECORD. WRITE SHOWERR-RECORD. Instead of the following: MOVE “LITERAL NUMBER 1…………………………..”’ TO SHOWERR-RECORD. WRITE SHOWERR-RECORD. -or- 2. Put more paragraph names in the program where MOVEment of many literals occurs.

Additional reference words: 2.20 Copyright Microsoft Corporation 1993.