View previous topic :: View next topic
|
Author |
Message |
A.S
New User
.jpg)
Joined: 24 Apr 2022 Posts: 4
|
|
|
|
hello friends.
I want to open a file with a cobol program and read it, but my compiler does not do that, what is your suggestion?
my jcl:
//abcdef JOB CLASS=A,MSGLEVEL=(1,1),MSGCLASS=T
//STEPLIB EXEC IGYWCLG
//SYSIN DD DSN=dsn-name(member-name),DISP=SHR
//MFILE DD DSN=dsn-name,disp=shr
//SYSPRINT DD SYSOUT=*
my cobol:
IDENTIFICATION DIVISION.
PROGRAM-ID. myprog.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT FILE1 ASSIGN TO MFILE
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS WS-FS.
DATA DIVISION.
FILE SECTION.
FD FILE1 IS GLOBAL
RECORD CONTAINS 80 CHARACTERS
BLOCK CONTAINS 80 CHARACTERS
RECORDING MODE IS F
DATA RECORD IS WS-OUT.
01 WS-OUT.
02 HELLO PIC X(05).
02 FILLER PIC X(75).
WORKING-STORAGE SECTION.
77 WS-FS PIC 9(02).
01 WS-EOF PIC X(01) VALUE 'N'.
88 EOF-SW VALUE 'Y'.
88 NOT-EOF-SW VALUE 'N'.
PROCEDURE DIVISION.
OPEN INPUT FILE1.
READ FILE1
DISPLAY 'WS-OUT:' WS-OUT
CLOSE FILE1.
DISPLAY 'ES-FS:' WS-FS.
STOP RUN.
result:
ws-out: "0" "0"0" 0" "0"
ws-fs:42 |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2159 Location: USA
|
|
|
|
The first thing you must do: using appropriate format for your samples.
Otherwise no response can be expected.
your JCL:
Code: |
//abcdef JOB CLASS=A,MSGLEVEL=(1,1),MSGCLASS=T
//STEPLIB EXEC IGYWCLG
//SYSIN DD DSN=dsn-name(member-name),DISP=SHR
//MFILE DD DSN=dsn-name,disp=shr
//SYSPRINT DD SYSOUT=*
|
Your COBOL code:
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. myprog.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT FILE1 ASSIGN TO MFILE
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS WS-FS.
DATA DIVISION.
FILE SECTION.
FD FILE1 IS GLOBAL
RECORD CONTAINS 80 CHARACTERS
BLOCK CONTAINS 80 CHARACTERS
RECORDING MODE IS F
DATA RECORD IS WS-OUT.
01 WS-OUT.
02 HELLO PIC X(05).
02 FILLER PIC X(75).
WORKING-STORAGE SECTION.
77 WS-FS PIC 9(02).
01 WS-EOF PIC X(01) VALUE 'N'.
88 EOF-SW VALUE 'Y'.
88 NOT-EOF-SW VALUE 'N'.
PROCEDURE DIVISION.
OPEN INPUT FILE1.
READ FILE1
DISPLAY 'WS-OUT:' WS-OUT
CLOSE FILE1.
DISPLAY 'ES-FS:' WS-FS.
STOP RUN.
|
Your result:
Code: |
ws-out: "0" "0"0" 0" "0"
ws-fs:42 |
Where is the real sample of your input data? |
|
Back to top |
|
 |
A.S
New User
.jpg)
Joined: 24 Apr 2022 Posts: 4
|
|
|
|
dear sergeyken Thank you for your reply
my input data is a dataset with a text:
and my dd card that define input dataset:
Code: |
//MFILE DD DSN=dsn-name,DISP=SHR
|
|
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2159 Location: USA
|
|
|
|
You presented some fake results.
The statement
under no circumstances can produce the result
Try to display the single field: HELLO OF WS-OUT. How it looks like? |
|
Back to top |
|
 |
dneufarth
Active User

Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
File Status — 42 A CLOSE operation has been tried on file already closed or never opened.
Check it after after every file/dataset operation. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2159 Location: USA
|
|
|
|
I am pretty sure there are other error messages somewhere in SDSF output.
The TS does not plan neither to look for them by himself, nor to present them to the forum. |
|
Back to top |
|
 |
A.S
New User
.jpg)
Joined: 24 Apr 2022 Posts: 4
|
|
|
|
dear sergeyken
I wrote above that my input dataset is a sequential file with a simple content:'hello', but I do not know why you do not believe or do not want to believe !, the only thing I did not write is the name of the datasets and the name of the program, which I think Basically does not have my question.
and max-rc=0. |
|
Back to top |
|
 |
A.S
New User
.jpg)
Joined: 24 Apr 2022 Posts: 4
|
|
|
|
Dear dneufarth
Yes,errors are diffrent.
if i put:
Code: |
DISPLAY 'ES-FS:' WS-FS.
|
after
error is:
it means the file is not open but why?! |
|
Back to top |
|
 |
dneufarth
Active User

Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
Your STEPLIB executes a PROC. It typically specifies a load library.
Do not know what’s in your PROC.
COBOL SELECT connects dataset to DD DSN. This connection does not appear to happen. Make sure DD stmt is correct.
Sadly, 20+ years since my last hands on efforts with COBOL and mainframe. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2159 Location: USA
|
|
|
|
1. The statement
Code: |
DISPLAY "ES-FS:" ... |
under NO CIRCUMSTANCES can give you the result
So, you have presented here some fake data created manually by yourself, instead of the EXACT COPY of your output.
2. After your statement
you MUST immediately verify your WS-FS value, and if it is not OK, then never try to print something related to your input data.
3. Whenever operations like OPEN INPUT FILE failed, you have two options:
- try to find from COBOL manuals what the WS-FS=35 stands for?
or
- try to analyze the whole output of you job run, in SDSF log: there are usually messages generated by zOS itself, with explanation - what exactly went wrong during the attempt to open your file?
Besides of this, when looking carefully into the SDSF output you might understand better: what actually the JCL procedure named IGYWCLG is doing inside of it, and how it is done?
We do not plan guessing: what exactly might go wrong in your unknown code mainly hidden by you from the forum?
(A secret hint: you may discover that your DD statement for your input data is misplaced, because you hardly understand the basics of JCL itself) |
|
Back to top |
|
 |
|