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

File access error

Status
Not open for further replies.

adityai

Programmer
Aug 8, 2004
10
US
I am using Fujitsu Cobol 3.0. I am having trouble with file access. I think it has everything to do with the FILE-CONTROL section. The error message displayed during execution is as follows:

JMP0311I-U MISSING ALLOCATION. FILE=SYSOUT. PGM=SAMPLE1 ADR=004011D1

As far as I remember, the implementor name (SYSOUT) varies from one flavor of COBOL to another. Can someone please suggest a solution?

The source code:


IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE1.
AUTHOR. ADITYA.
*
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT DATAFILE
ASSIGN TO SYSOUT
ORGANIZATION IS LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD DATAFILE.
01 INPUT-RECORD.
05 PERSON-RECORD.
10 INPUTNAME PIC X(6).
10 PIC X.
10 INPUTAGE PIC 9(2).
10 PIC X.

WORKING-STORAGE SECTION.
01 WORD-INDEX PIC 9(3).
01 INPUT-PERSON.
05 INPUT-NAME PIC X(6).
05 PIC X VALUE SPACES.
05 INPUT-AGE PIC 9(2).
05 PIC X VALUE SPACES.


01 REQUEST-MESSAGE PIC X(42)
VALUE "ENTER YOUR NAME: ".

*
PROCEDURE DIVISION.
DATA-INPUT SECTION.
**(1)DISPLAY THE ABOVE MESSAGE
DISPLAY REQUEST-MESSAGE.
**(2)ACCEPT THE INPUT CHARACTER
ACCEPT INPUT-NAME.

DISPLAY "ENTER YOUR AGE: " WITH NO ADVANCING.
ACCEPT INPUT-AGE.

IF INPUT-AGE < 18 THEN
DISPLAY "UNDER 18".

OPEN OUTPUT DATAFILE.
* MOVE INPUT-PERSON TO INPUT-RECORD.
WRITE INPUT-RECORD.
CLOSE DATAFILE.

*
**(4) THE RESULTING WORD MATCH IS DISPLAYED
* DISPLAY "NAME: " & INPUT-NAME.
* DISPLAY "AGE: " & INPUT-AGE.
*
EXIT PROGRAM.
END PROGRAM SAMPLE1.
 
I looked up one of the other file access related question and saw that the implementor name is DISK. I tried it and it worked.

I would like to know if I can write to a file with a file name of my choice.
 
[tt]Yes, you can select a filename in several manners like;[/tt]
Code:
           SELECT DETAIL-FILE ASSIGN TO 'AFILE.TXT' 
            ACCESS MODE IS SEQUENTIAL
            ORGANIZATION IS LINE SEQUENTIAL.
[tt] if in the same location as the executable, or;[/tt]
Code:
           SELECT DETAIL-FILE ASSIGN TO 
            'C:\ADIRECTORY\AFILE.TXT'
            ACCESS MODE IS SEQUENTIAL
            ORGANIZATION IS LINE SEQUENTIAL.
[tt]ect. to determine the path. You can also use a field to internally name files like;[/tt]
Code:
           SELECT IN-FILE ASSIGN TO MY-FILE
            ACCESS MODE IS SEQUENTIAL
            ORGANIZATION IS LINE SEQUENTIAL.

        WORKING-STORAGE.
        01 FILE-NAMES.
            02 MY-FILE       PIC X(100).

        PROCEDURE DIVISION.
        INIT-RTN.
            MOVE SPACES TO MY-FILE
            MOVE 'C:\ADIRECTORY\AFILE.TXT'
             TO MY-FILE  
            OPEN INPUT IN-FILE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top