Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User logic error

Status
Not open for further replies.

lbzh

Programmer
Aug 7, 2004
25
US
I am trying to write a cobol program to read a file and increment the contents and write back to the same file, I am
trying to increment the first 4 bytes and write back the 4 bytes and the filler of 76.
Here is the code:

SPECIAL-NAMES.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT DATE-FILE ASSIGN TO DISDATE.
DATA DIVISION.
FILE SECTION.
FD DATE-FILE
LABEL RECORDS ARE STANDARD
RECORDING MODE IS F
BLOCK CONTAINS 0 RECORDS.
01 DATE-REC PIC X(80).
WORKING-STORAGE SECTION.
01 DATE-RECORD.
05 GWD-WEEK PIC 9(4).
05 FILLER PIC X(76).
01 HOLD-AREA.
05 END-READ-FLAG PIC X(03) VALUE 'YES'.
05 LINES-CTR PIC 9(09) VALUE ZEROES.

PROCEDURE DIVISION.

0001-MAIN.
OPEN I-O DATE-FILE.
PERFORM 3000-READ-DATE UNTIL
END-READ-FLAG = 'NO '.
CLOSE DATE-FILE.
DISPLAY 'ALL RECORDS = ' , LINES-CTR
STOP RUN.
3000-READ-DATE.
READ DATE-FILE INTO DATE-RECORD
AT END MOVE 'NO ' TO END-READ-FLAG
END-READ.
IF END-READ-FLAG = 'YES'
PERFORM 3000-INCREMENT-DATE
END-IF.
3000-INCREMENT-DATE.
INITIALIZE DATE-RECORD.
ADD +1 TO GWD-WEEK.
WRITE DATE-REC FROM DATE-RECORD.

The following error occurs when trying to run:

+IGZ020I A user logic error occurred. Neither FILE STATUS nor a
+ declarative was specified for file 'DISDATE' in program 'ADD1'
+ at relative location X'0308'. The I-O status code was '48'.

Note:DISDATE is allocated in my proc as the 80 character file with the date in the first 4 positions.

Thanks
 
Looks like a standard sequential file.
Try 'REWRITE' instead of 'WRITE'.

WRITE is used for OPEN EXTEND (adding records)
or OPEN OUTPUT (new file).

See also the discussion in post:
(check the end of this post where the various sequential access methods are discussed!).


Regards, Wim Ahlers.
 
The execution of a WRITE statement was attempted on a file not open in the I-O, output, or extend mode.

Open DATE-RECORD?
 
I tried the REWRITE and it worked correctly.
Another error I had in my original code I was initializing the record after reading it which set it to 0.

Eliminating that and inserting the REWRITE, it now works like a charm.

Thanks All.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top