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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write Error 1

Status
Not open for further replies.

Cinthia

Programmer
Feb 11, 2001
2
0
0
US
Hi my name is Cinthia , i am in my first semester of COBOL and in chpt 2 of the Shelly Cashman book Structures COBOL Programming. I am trying to run a report and i get the error message "wrong open mode or access mode for write [error 148].

I have compiled and there are no syntax errors , but when i press run i get that error. Any suggestions? This is very very new to me
 
Cinthia,

i don't know which compiler you use, or on which platform, but finding out what that "Error 148" means is a good start.
Some possible causes: did you OPEN the file you are writing to before the first WRITE ? And if so, did you OPEN for OUTPUT ?
 
I am using Win 98. Dont you open by going to open for execution? Then i click RUN. Maybe i'm doing it all wrong and my instructer wont help at all.
 
Cinthia,

When you say 'Dont you open by going to open for execution?' it looks like you are refering to the actually running of the program and not where your problem is (ie. in your code).
You need to look at (1) the 'Select' statement(s) in your Environment Division and make sure you have the correct file access mode (sequential, dynamic, whatever). Then (2)make sure the 'open' statement(s) for the file(s) are correct (eg. you don't want to open for input when you are going to write to the file). Finally check (3) the file access statements (write, read, whatever) in your procedure division. It looks like you have a mismatch between (1), (2) and (3).
Good Luck
 
Cinthia,

just to add to what kfmason said:

is your program supposed to read from or write to a file?
If it's reading, and suppose your file is called INPUT-FILE (in the source), you should find:

- in the INPUT-OUTPUT SECTION, something like

SELECT INPUT-FILE ASSIGN TO ... (i don't no what that is, but i'm sure you do)

- in the FILE SECTION, somthing like

FD INPUT-FILE
...
01 INPUT-RECORD ...
...

- somewhere in the PROCEDURE DIVISION:

...
OPEN INPUT INPUT-FILE. (This is the OPEN statement i mentioned earlier)
...
READ INPUT-FILE.
...
CLOSE INPUT-FILE.

For output files, that is files you write to, it's basically the same, except the procedure division bit:

...
OPEN OUTPUT OUTPUT-FILE.
...
WRITE OUTPUT-RECORD.
...
CLOSE OUTPUT-FILE.
...

So, in short: you have to use the OPEN statement to actually open the file for use inside the program. If you don't, or not correctly, you'll get the error you mentioned.

Good luck !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top