I wrote a simple COBOL program to read an input file, do some conversions, and to generate an output file from within the Code. However, I recieve an I/O operation failure error and the file is not created. If I manually create a blank physical file before hand with the same name, it becomes populated with the correct data, so the program logic appears to be ok. If I change the ASSIGN TO statement to point to a printer, the spool file also has the correct data. The file status in the job log on the input file is 00, and the output file status is ***? Any ideas? below is the code...any help would be greatly appreciated.
IDENTIFICATION DIVISION.
*===============================================================
PROGRAM-ID. BAC344ASS1.
****************************************************************
* *
* Purpose: This program will read the Old Vendor file, convert*
* Country Codes to names, ignore certain records, *
* and reorganize fields to produce a modified *
* Vendor File. *
* Input: OLDFILE (Vendor File) *
* *
* Output: NEWFILE (Modified Vendor File) *
* *
*--------------------------------------------------------------*
* * *
****************************************************************
*===============================================================
ENVIRONMENT DIVISION.
*===============================================================
INPUT-OUTPUT SECTION.
*---------------------------------------------------------------
FILE-CONTROL.
*---------------------------------------------------------------
SELECT ORIGINAL
ASSIGN TO DISK-OLDFILE
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
SELECT NEWONE
ASSIGN TO DISK-WAZUP
ORGANIZATION IS SEQUENTIAL.
*===============================================================
DATA DIVISION.
*===============================================================
FILE SECTION.
*---------------------------------------------------------------
FD ORIGINAL
RECORD CONTAINS 56 CHARACTERS
DATA RECORD IS OLDFILER.
01 OLDFILER.
05 VENDORCODE PIC X(5).
05 VENDORNAME PIC X(20).
05 CFIRSTNAME PIC X(10).
05 CLASTNAME PIC X(10).
05 CNTRYCODE PIC X(1).
05 PHONENO PIC S9(10).
FD NEWONE
RECORD CONTAINS 72 CHARACTERS
DATA RECORD IS NEWONER.
01 NEWONER.
05 N-VENDORCODE PIC X(5).
05 N-VENDORNAME PIC X(20).
05 N-CLASTNAME PIC X(10).
05 N-CFIRSTNAME PIC X(10).
05 N-CNTRYNAME PIC X(10).
05 N-PHONENO PIC S9(10).
05 FILLER PIC X(7).
*---------------------------------------------------------------
WORKING-STORAGE SECTION.
*---------------------------------------------------------------
01 WORKING-STORAGE-REC.
05 WS-FLAGS-VARIABLES.
10 WS-DEL-REC PIC X(01).
05 WS-FILE-FLAG PIC X(01).
05 WS-COUNTERS-VARIABLES.
10 WS-ERROR PIC S9(2) VALUE ZERO.
05 WS-TEMP-RECORD.
10 NEW-VENDORC PIC X(5).
10 NEW-VENDORN PIC X(20).
10 NEW-LASTN PIC X(10).
10 NEW-FIRSTN PIC X(10).
10 NEW-COUNTRYN PIC X(10).
10 NEW-PHONENO PIC S9(10).
10 FILLER PIC X(7).
*=====================================================
PROCEDURE DIVISION.
*=====================================================
A000-MAIN-LINE.
PERFORM B100-OPEN-FILES.
MOVE "Y" TO WS-FILE-FLAG.
PERFORM C100-READ-FILES.
IF WS-FILE-FLAG = "Y"
PERFORM UNTIL WS-FILE-FLAG = "N"
PERFORM D100-COUNTRY
PERFORM E100-WRITE-FILES
PERFORM C100-READ-FILES
END-PERFORM
END-IF.
PERFORM Z100-END-PROCESS.
*------------------------------------------------------------*
B100-OPEN-FILES.
*------------------------------------------------------------*
OPEN INPUT ORIGINAL
EXTEND NEWONE.
*------------------------------------------------------------*
C100-READ-FILES.
*------------------------------------------------------------*
READ ORIGINAL
AT END
MOVE "N" TO WS-FILE-FLAG
END-READ.
*------------------------------------------------------------*
D100-COUNTRY.
*------------------------------------------------------------*
EVALUATE CNTRYCODE
WHEN 1
MOVE "Canada" TO NEW-COUNTRYN
WHEN 2
MOVE "USA" TO NEW-COUNTRYN
WHEN 3
MOVE "Brazil" TO NEW-COUNTRYN
WHEN 4
MOVE "Mexico" TO NEW-COUNTRYN
WHEN 5
MOVE "Bermuda" TO NEW-COUNTRYN
WHEN 6
MOVE "Spain" TO NEW-COUNTRYN
WHEN 7
MOVE "China" TO NEW-COUNTRYN
WHEN 8
MOVE "Japan" TO NEW-COUNTRYN
WHEN 9
MOVE "Italy" TO NEW-COUNTRYN
WHEN OTHER
MOVE "Not Defined" TO NEW-COUNTRYN
END-EVALUATE.
*------------------------------------------------------------*
E100-WRITE-FILES.
*------------------------------------------------------------*
MOVE VENDORCODE TO N-VENDORCODE.
MOVE VENDORNAME TO N-VENDORNAME.
MOVE CLASTNAME TO N-CLASTNAME.
MOVE CFIRSTNAME TO N-CFIRSTNAME.
MOVE NEW-COUNTRYN TO N-CNTRYNAME.
MOVE PHONENO TO N-PHONENO.
WRITE NEWONER.
*------------------------------------------------------------*
Z100-END-PROCESS.
*------------------------------------------------------------*
CLOSE ORIGINAL
NEWONE.
STOP RUN.
IDENTIFICATION DIVISION.
*===============================================================
PROGRAM-ID. BAC344ASS1.
****************************************************************
* *
* Purpose: This program will read the Old Vendor file, convert*
* Country Codes to names, ignore certain records, *
* and reorganize fields to produce a modified *
* Vendor File. *
* Input: OLDFILE (Vendor File) *
* *
* Output: NEWFILE (Modified Vendor File) *
* *
*--------------------------------------------------------------*
* * *
****************************************************************
*===============================================================
ENVIRONMENT DIVISION.
*===============================================================
INPUT-OUTPUT SECTION.
*---------------------------------------------------------------
FILE-CONTROL.
*---------------------------------------------------------------
SELECT ORIGINAL
ASSIGN TO DISK-OLDFILE
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
SELECT NEWONE
ASSIGN TO DISK-WAZUP
ORGANIZATION IS SEQUENTIAL.
*===============================================================
DATA DIVISION.
*===============================================================
FILE SECTION.
*---------------------------------------------------------------
FD ORIGINAL
RECORD CONTAINS 56 CHARACTERS
DATA RECORD IS OLDFILER.
01 OLDFILER.
05 VENDORCODE PIC X(5).
05 VENDORNAME PIC X(20).
05 CFIRSTNAME PIC X(10).
05 CLASTNAME PIC X(10).
05 CNTRYCODE PIC X(1).
05 PHONENO PIC S9(10).
FD NEWONE
RECORD CONTAINS 72 CHARACTERS
DATA RECORD IS NEWONER.
01 NEWONER.
05 N-VENDORCODE PIC X(5).
05 N-VENDORNAME PIC X(20).
05 N-CLASTNAME PIC X(10).
05 N-CFIRSTNAME PIC X(10).
05 N-CNTRYNAME PIC X(10).
05 N-PHONENO PIC S9(10).
05 FILLER PIC X(7).
*---------------------------------------------------------------
WORKING-STORAGE SECTION.
*---------------------------------------------------------------
01 WORKING-STORAGE-REC.
05 WS-FLAGS-VARIABLES.
10 WS-DEL-REC PIC X(01).
05 WS-FILE-FLAG PIC X(01).
05 WS-COUNTERS-VARIABLES.
10 WS-ERROR PIC S9(2) VALUE ZERO.
05 WS-TEMP-RECORD.
10 NEW-VENDORC PIC X(5).
10 NEW-VENDORN PIC X(20).
10 NEW-LASTN PIC X(10).
10 NEW-FIRSTN PIC X(10).
10 NEW-COUNTRYN PIC X(10).
10 NEW-PHONENO PIC S9(10).
10 FILLER PIC X(7).
*=====================================================
PROCEDURE DIVISION.
*=====================================================
A000-MAIN-LINE.
PERFORM B100-OPEN-FILES.
MOVE "Y" TO WS-FILE-FLAG.
PERFORM C100-READ-FILES.
IF WS-FILE-FLAG = "Y"
PERFORM UNTIL WS-FILE-FLAG = "N"
PERFORM D100-COUNTRY
PERFORM E100-WRITE-FILES
PERFORM C100-READ-FILES
END-PERFORM
END-IF.
PERFORM Z100-END-PROCESS.
*------------------------------------------------------------*
B100-OPEN-FILES.
*------------------------------------------------------------*
OPEN INPUT ORIGINAL
EXTEND NEWONE.
*------------------------------------------------------------*
C100-READ-FILES.
*------------------------------------------------------------*
READ ORIGINAL
AT END
MOVE "N" TO WS-FILE-FLAG
END-READ.
*------------------------------------------------------------*
D100-COUNTRY.
*------------------------------------------------------------*
EVALUATE CNTRYCODE
WHEN 1
MOVE "Canada" TO NEW-COUNTRYN
WHEN 2
MOVE "USA" TO NEW-COUNTRYN
WHEN 3
MOVE "Brazil" TO NEW-COUNTRYN
WHEN 4
MOVE "Mexico" TO NEW-COUNTRYN
WHEN 5
MOVE "Bermuda" TO NEW-COUNTRYN
WHEN 6
MOVE "Spain" TO NEW-COUNTRYN
WHEN 7
MOVE "China" TO NEW-COUNTRYN
WHEN 8
MOVE "Japan" TO NEW-COUNTRYN
WHEN 9
MOVE "Italy" TO NEW-COUNTRYN
WHEN OTHER
MOVE "Not Defined" TO NEW-COUNTRYN
END-EVALUATE.
*------------------------------------------------------------*
E100-WRITE-FILES.
*------------------------------------------------------------*
MOVE VENDORCODE TO N-VENDORCODE.
MOVE VENDORNAME TO N-VENDORNAME.
MOVE CLASTNAME TO N-CLASTNAME.
MOVE CFIRSTNAME TO N-CFIRSTNAME.
MOVE NEW-COUNTRYN TO N-CNTRYNAME.
MOVE PHONENO TO N-PHONENO.
WRITE NEWONER.
*------------------------------------------------------------*
Z100-END-PROCESS.
*------------------------------------------------------------*
CLOSE ORIGINAL
NEWONE.
STOP RUN.