IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

File Handling


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
A.S

New User


Joined: 24 Apr 2022
Posts: 4

PostPosted: Sun Apr 24, 2022 6:53 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Sun Apr 24, 2022 8:34 pm
Reply with quote

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
View user's profile Send private message
A.S

New User


Joined: 24 Apr 2022
Posts: 4

PostPosted: Sun Apr 24, 2022 9:05 pm
Reply with quote

dear sergeyken Thank you for your reply

my input data is a dataset with a text:

Code:


00001 hello



and my dd card that define input dataset:

Code:


//MFILE DD DSN=dsn-name,DISP=SHR

Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Sun Apr 24, 2022 9:12 pm
Reply with quote

You presented some fake results.
The statement
Code:
DISPLAY “WS-OUT:”

under no circumstances can produce the result
Code:
ws-out:


Try to display the single field: HELLO OF WS-OUT. How it looks like?
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 387
Location: Inside the SPEW (Cincinnati OH USA)

PostPosted: Sun Apr 24, 2022 9:37 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Sun Apr 24, 2022 10:10 pm
Reply with quote

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
View user's profile Send private message
A.S

New User


Joined: 24 Apr 2022
Posts: 4

PostPosted: Mon Apr 25, 2022 12:13 am
Reply with quote

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
View user's profile Send private message
A.S

New User


Joined: 24 Apr 2022
Posts: 4

PostPosted: Mon Apr 25, 2022 12:20 am
Reply with quote

Dear dneufarth

Yes,errors are diffrent.
if i put:

Code:

DISPLAY 'ES-FS:' WS-FS.


after

Code:

OPEN INPUT FILE1.


error is:

Code:

ws-fs:35


it means the file is not open but why?!
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 387
Location: Inside the SPEW (Cincinnati OH USA)

PostPosted: Mon Apr 25, 2022 1:06 am
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Mon Apr 25, 2022 6:18 pm
Reply with quote

1. The statement
Code:
DISPLAY "ES-FS:" ...
under NO CIRCUMSTANCES can give you the result
Code:
ws-fs: ...

So, you have presented here some fake data created manually by yourself, instead of the EXACT COPY of your output.


2. After your statement
Code:
OPEN INPUT FILE1.
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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Selecting the max value from a file. DFSORT/ICETOOL 3
No new posts Change history of vsam file. JCL & VSAM 3
No new posts Split large FB file based on Key coun... DFSORT/ICETOOL 4
No new posts EMPTY file check scenario JCL & VSAM 6
No new posts SORT deletes the SORTOUT file DFSORT/ICETOOL 8
Search our Forums:

Back to Top