Hey guys I've been scratching my head over this all day to no avail. I'm running a COBOl program that should take input from one file and output it to another if it meets some conditions.
This is the PROCEDURE DIVISION.
PROCEDURE DIVISION.
*
A000-START.
OPEN INPUT CUST-RECS.
OPEN OUTPUT ACCT-RPT.
PERFORM A000-WRITE-FIRST.
PERFORM READ-NEXT-RECORD.
* PERFORM WRITE-RECORD.
CLOSE ACCT-RPT.
CLOSE CUST-RECS.
STOP RUN.
*
A000-WRITE-FIRST.
DISPLAY "WRITE-FIRST".
MOVE 2 TO REC-COUNT.
WRITE PRT-REP-DONE FROM HEADER-1.
WRITE PRT-REP-DONE FROM HEADER-2.
WRITE PRT-REP-DONE FROM HEADER-3.
WRITE PRT-REP-DONE FROM HEADER-4.
*
READ-NEXT-RECORD.
PERFORM READ-RECORD
PERFORM UNTIL LASTREC = 'Y'
PERFORM WRITE-RECORD
PERFORM READ-RECORD
END-PERFORM.
*
WRITE-RECORD.
DISPLAY "WRITE-RECORD called" FIRST-NAME.
MOVE SPACES TO PRT-REP-DONE.
MOVE REC-COUNT TO PRT-RECS.
MOVE FIRST-NAME TO PRT-NAME-FST.
MOVE LAST-NAME TO PRT-NAME-LST.
MOVE BALANCE TO PRT-BALANCE.
WRITE PRT-REP-DONE.
CLOSE ACCT-RPT.
READ-RECORD.
READ CUST-RECS
AT END MOVE 'Y' TO LASTREC
IF (FUNCTION NUMVAL-C(BALANCE) IS > 8500000)
THEN
DISPLAY "BALANCE: " BALANCE
ADD 1 TO REC-COUNT
PERFORM WRITE-RECORD
END-IF
END-READ.
In my output file I just get 1 blank line. And a ABEND code of SB14. I was able to get some output before but now nothing.
SB14 is an issue with close. SB14 can be found here This abend indicates there is the accompanying messace IEC217I
With regard to the code, it looks like you're closing the output file ACCT-RPT
WRITE-RECORD
which is probably your output file.
WRITE-RECORD. DISPLAY "WRITE-RECORD called" FIRST-NAME. MOVE SPACES TO PRT-REP-DONE. MOVE REC-COUNT TO PRT-RECS. MOVE FIRST-NAME TO PRT-NAME-FST. MOVE LAST-NAME TO PRT-NAME-LST. MOVE BALANCE TO PRT-BALANCE. WRITE PRT-REP-DONE. CLOSE ACCT-RPT.
My guess is its whining about closing
the file twice.