Skip to main content

Read file in COBOL

  • April 14, 2015
  • 21 replies
  • 0 views

Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

21 replies

  • April 14, 2015

Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

You need to tell it what medium your file is on:

SELECT F1 ASSIGN TO DISK "TEST.DAT".


Fano Razafinimanana

Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

Hello Thomas,

I don't see anything wrong with the whole SELECT clause. Do you get the error when you compile or run the application? Can you attach a screenprint showing the error please.

Regards,


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

I see two thing you may want to change, first remove the word DISK and change the double quits to single ones.


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

One more thing, you may want to add       organization is line sequential.      following the file name.


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

One more thing, you may want to add       organization is line sequential.      following the file name.


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

The whole program: puu.sh/.../07672df381.png

Compile-time error: puu.sh/.../493416ff0c.png

Whenever I get the file reading correct I can start to refine the program...

I did change from " to ' but I got the same error

- Thomas


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

The whole program: puu.sh/.../07672df381.png

Compile-time error: puu.sh/.../493416ff0c.png

Whenever I get the file reading correct I can start to refine the program...

I did change from " to ' but I got the same error

- Thomas


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

Hello,

I didn't read all the replies... here's with the DISK clause included:

puu.sh/.../ef499ac98f.png

I tried with the whole file path but i got the same error

- Thomas


Fano Razafinimanana

Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

Hello Thomas,

Thanks for providing the screenprints, but I still don't see anything that would cause this compiler error. I don't even see COBCH1588 in the documentation.

Attached is a very similar to your sample program. Can you please see if you can recreate the problem or not?

0181.ASSIGNissue.zip

Regards,


  • April 14, 2015

Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

It looks like you're getting a file status of 35, which is a file not found.  If the file does not exist or if the ID that the program is running under doesn't have access to that file, when you open the file for INPUT you'll get this error.

Make sure the file exists.


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

I copied the contents of NewData.cbl into a new source file in a new project and it compiled without errors. However, will "hello" be written into that file? I opened it after the program had executed and there was nothing there. The code in the screenshots above was written in COBOL for OS/390, which means that there's probably a syntax error. I stick to Visual COBOL for now... I compiled your program using Visual COBOL, but i still got unexpected resultat. Thanks in advance.

- Thomas


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

I copied the contents of NewData.cbl into a new source file in a new project and it compiled without errors. However, will "hello" be written into that file? I opened it after the program had executed and there was nothing there. The code in the screenshots above was written in COBOL for OS/390, which means that there's probably a syntax error. I stick to Visual COBOL for now... I compiled your program using Visual COBOL, but i still got unexpected resultat. Thanks in advance.

- Thomas


Blair McDonald

Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

From the error message you are getting (as shown in your latest screen shot), it appears you may not have the environment set up correctly. Are you trying to execute the program at the command prompt?


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

I did this: New project > empty project. Then new > file > program in Visual Studios.

I build it and run it from the IDE. Have I missed something very fundamental?


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

I did this: New project > empty project. Then new > file > program in Visual Studios.

I build it and run it from the IDE. Have I missed something very fundamental?


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

thomasbn94

This will work for a flat file for INPUT, for OUTPUT and also for EXTEND

          SELECT FILEA

              ASSIGN TO 'C:\\MyFolder\\FILEA.txt'

              ORGANIZATION IS LINE SEQUENTIAL

              ACCESS IS SEQUENTIAL.

BTW, the use of quotes or apostrophes don't make any difference so long as you use them in pairs

You can have both in the one program no problem

VALUE 'ONE' and VALUE "ONE" means the same thing to the compiler

For an indexed file (some call it ISAM - Indexed Sequential Access Method) look in the documentation and vary the above sample code a little (lines 3 & 4)


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

I also have this error, and none of these fine suggestions actually work.

As far as I can tell, Visual COBOL simply does not take strings for file selection... not that it would on the mainframe anyway, I'm just bashing rocks together with this trial version to see if it's nicer than ELIPS.


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

I also have this error, and none of these fine suggestions actually work.

As far as I can tell, Visual COBOL simply does not take strings for file selection... not that it would on the mainframe anyway, I'm just bashing rocks together with this trial version to see if it's nicer than ELIPS.


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

As far as I can see, error 1588 is only produced when the COBOL 370 dialect is in effect.

Could you check the COBOL dialect drop-down under properties/COBOL and see what it's set to?

Regards,

Robert.


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

Oh, I did change the dialect to match that of the mainframe. That makes perfect sense then. Thanks!..  I'm a derp.

Feature request: syntax validation, when describing an error, lets you know if something is supported in another dialect.


Hello,

I got this: 

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT F1 ASSIGN TO "test.dat".

I get this error at the last line: "Invalid ASSIGN name" which is "test.dat". I've also tried the whole file path but it still doesn't work. The file is in the same directory as the program file. Anything on this?

- Thomas


#File
#Assign
#COBOLFILE

Oh, I did change the dialect to match that of the mainframe. That makes perfect sense then. Thanks!..  I'm a derp.

Feature request: syntax validation, when describing an error, lets you know if something is supported in another dialect.