I am trying to code a very simple cobol program which reads records from a sequential file and writes into working-storage variable. The sequential file that i have created has 2 records. Inspite of mentioning the file in DD name of JCL and also invoking it in cobol, im getting File Status 35 error. Please help.
Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. READSQ.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT STUDENT ASSIGN TO INFILE
ORGANIZATION IS SEQUENTIAL
FILE STATUS IS WS-FS01.
DATA DIVISION.
FILE SECTION.
FD STUDENT
RECORDING MODE IS F
RECORD CONTAINS 80 CHARACTERS.
01 STUDENT-FILE.
05 STUDENT-ID PIC 9(5).
05 STUDENT-NAME PIC X(20).
05 FILLER PIC X(55).
*
WORKING-STORAGE SECTION.
01 WS-STUDENT.
05 WS-STUDENT-ID PIC 9(5).
05 WS-NAME PIC X(20).
05 FILLER PIC X(55).
*
77 WS-EOF PIC X(1) VALUE 'N'.
77 WS-FS01 PIC 9(02).
77 N PIC 9(01) VALUE 2.
PROCEDURE DIVISION.
DISPLAY 'PROGRAM STARTS'.
OPEN INPUT STUDENT.
DISPLAY ' FILE STATUS AFTER OPEN IS: ', WS-FS01.
DISPLAY 'FILE OPEN'.
PERFORM READ-PARA N TIMES.
DISPLAY 'SUCCESSFUL READ'.
CLOSE STUDENT.
STOP RUN.
*
READ-PARA.
DISPLAY 'FILE READ'.
READ STUDENT INTO WS-STUDENT.
DISPLAY ' FILE STATUS AFTER READ IS: ', WS-FS01.
DISPLAY 'STUDENT ID=', WS-STUDENT-ID.
DISPLAY 'STUDENT NAME=', WS-NAME.
VIEW ATXSCLM.ATSUNPA.STUDENT Columns 00001 00072
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
000100 12345ABCDE
000200 67890YYYYY
****** **************************** Bottom of Data ****************************
File Layout
Code:
Data Set Information
Command ===>
Data Set Name . . . . : ATXSCLM.ATSUNPA.STUDENT
General Data Current Allocation
Management class . . : UM2B5ND Allocated blocks . : 39
Storage class . . . : SNMN Allocated extents . : 1
Volume serial . . . : TSO010
Device type . . . . : 3390
Data class . . . . . : **None**
Organization . . . : PS Current Utilization
Record format . . . : FB Used blocks . . . . : 1
Record length . . . : 80 Used extents . . . : 1
Block size . . . . : 800
1st extent blocks . : 39
Secondary blocks . : 10 Dates
Data set name type : Creation date . . . : 2015/03/31
SMS Compressible. . : NO Referenced date . . : 2015/04/01
Expiration date . . : ***None***
Sysout
Code:
*********************************
PROGRAM STARTS
FILE STATUS AFTER OPEN IS: 35
FILE OPEN
FILE READ
FILE STATUS AFTER READ IS: 47
STUDENT ID=
STUDENT NAME=
FILE READ
FILE STATUS AFTER READ IS: 47
STUDENT ID=
STUDENT NAME=
SUCCESSFUL READ
********************************
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
You need to look the second spool dataset for your JOB. It will show you where you have put INFILE, which is not where you think you have put it. You will need to use an override for the stepname in the PROC to get it where you want.
And you don't write to WORKING-STORAGE. You only WRITE records, and those records will be associated with a file.
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
If the load library was not being created, your program would not execute. HOWEVER, it is a temporary data set and hence is deleted at the end of the job.
For the same job/proc that i have pasted above, i need to include my sub-program..I have compiled my sub-program separately. Now, i need to run my main-program. Im getting return-code 8 while doing this.
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
This is a forum for professionals. You need to move to Beginner's and Students Forum because the problems you are posting here are beginner problems and you're not going to get a lot of support for them here.
When using a subprogram, you MUST compile it into a load library. That load library has to be available when you link edit / bind your program (via your compile JCL) if the subprogram is statically called, or the load library has to be available at execution time (via the STEPLIB DD statement) if the subprogram is dynamically called.
It appears that you are attempting to statically link your subprogram into your main program load module. To do this, you need //LKED.SUBLIB DD DISP=SHR,DSN=<load.library.name> in your compile JCL. LKED.SYSIN should have
Code:
INCLUDE SUBLIB(SUBPGM)
ENTRY READSQ
NAME READSQ(R)
Putting the source code for the subprogram into your LKED.SYSIN does not work, as you found out.