We are reading in a report file for additional processing. Some numeric fields were printed out with leading spaces but when we try to process them with Micro Focus we are getting an 'invalid numeric data in numeric field' error. The runtime error is a RTS163. Our program is moving a field read in from a file into another field defined as a PIC Z type variable to suppress the leading Zeros to SPACES for our final results. We have tried various options but cannot get this to be accepted as an actual numeric data item.
Although IBM and Micro Focus say one should use valid data in processing any Cobol arithmetic statements, Micro Focus will also flag invalid data found in a MOVE statement. We have cut down your program to the following sample.
Since we could not get the sample to pass an IF NUMERIC test, we needed to restore the leading Zeros to our field. The sample simulates data read in from a file by moving hexadecimal values to a numeric field. We have omitted the data processing steps and coded only the final MOVE prior to the new report output being created. DISPLAY statements were added as additional verification that we were seeing the expected results.
Identification Division. Program-Id. LORINCE. * When READing in a report file that contains suppressed * leading Zeros, we need to change the Spaces back to Zero * prior to any data processing Environment Division. Data Division. Working-Storage Section. 1 . 2 ReportInputQ2Sales Pic 9(8).99. 2 RptInQ2SalesR Redefines ReportInputQ2Sales. 3 Pic X(11). 2 FinalQ2Sales Pic Z(8).ZZ. Procedure Division. P1. Move x'4040404040F8F1F14BF9F0' to RptInQ2SalesR * Move x'20202020203831312E3930' to RptInQ2SalesR Display 'Before MOVE Statement' Display ' ReportInputQ2Sales= ' ReportInputQ2Sales Display ' FinalQ2Sales= ' FinalQ2Sales Inspect ReportInputQ2Sales Replacing All x'40' By x'F0' * Inspect ReportInputQ2Sales * Replacing All x'20' By x'30' Move ReportInputQ2Sales to FinalQ2Sales Display 'After MOVE Statement' Display ' ReportInputQ2Sales= ' ReportInputQ2Sales Display ' FinalQ2Sales= ' FinalQ2Sales Goback.
The program can be used with either EBCDIC or ASCII by uncommenting and commenting the appropriate lines. We always see this output regardless of which character set is used: Before MOVE Statement ReportInputQ2Sales= 811.90 FinalQ2Sales= After MOVE Statement ReportInputQ2Sales= 00000811.90 FinalQ2Sales= 811.90