Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Not able to read all records in a file
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
CuriousMainframer

New User


Joined: 28 Feb 2012
Posts: 5
Location: India

PostPosted: Wed Aug 22, 2012 11:13 am    Post subject: Not able to read all records in a file
Reply with quote

Hi ,

I am reading a sequential file in my cobol program.
I do a perform until EOF.
The program is reading only the 1st 3 records from the file and sets the EOF flag.
When I move the first 3 records to the end, it is reading only the last 3 records in my program.

In case some one has faced a similar issue can you let me know how u resolved it.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Aug 22, 2012 11:44 am    Post subject: Reply to: Not able to read all records in a file
Reply with quote

the info posted is not enough to provide a reasonable answer
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Aug 22, 2012 12:15 pm    Post subject:
Reply with quote

That happens all the time to me, when there are only 3 records in the file.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Aug 22, 2012 12:43 pm    Post subject: Reply to: Not able to read all records in a file
Reply with quote

You have some code which is ignoring the other records. I think, somewhere between lines 131 and 160 of your program, but I can't be certain.

If you can't spot it, you're going to have to post the relevant parts of your code. You'll probably spot it whilst doing that.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Aug 22, 2012 1:01 pm    Post subject:
Reply with quote

If you don't mind can you paste the code for us??
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Aug 22, 2012 2:44 pm    Post subject:
Reply with quote

Where do you set EOF? As others have siad, show us the code to get better replies.

Have fun:
Code:
.
.
DATA DIVISION.
FILE SECTION.
FD  CuriousMainframerFile.
01 CMFile.
.
.
OPEN INPUT CuriousMainframerFile

   READ CuriousMainframerFile
      AT END MOVE HIGH-VALUES TO CMFile
   END-READ
   PERFORM UNTIL CMFile = HIGH-VALUES
      DISPLAY 'You're here :D'
      READ CuriousMainframerFile
         AT END MOVE HIGH-VALUES TO CMFile
      END-READ
   END-PERFORM
   CLOSE CuriousMainframerFile
   GOBACK
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Aug 22, 2012 7:03 pm    Post subject: Reply to: Not able to read all records in a file
Reply with quote

Peter said -
Quote:
That happens all the time to me, when there are only 3 records in the file.

Now that's funny.... icon_lol.gif
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Aug 22, 2012 10:03 pm    Post subject: Re: Reply to: Not able to read all records in a file
Reply with quote

Bill O'Boyle wrote:
Peter said -
Quote:
That happens all the time to me, when there are only 3 records in the file.

Now that's funny.... icon_lol.gif


Well Bill, when i posted that i had a LOL too. icon_biggrin.gif
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Aug 23, 2012 6:27 am    Post subject:
Reply with quote

Code:

 FD  CuriousMainframerFile.
 01 CMFile.
 

     AT END MOVE HIGH-VALUES TO CMFile




That doesn't look like a very good idea, 'AT END' CMFILE isn't pointing at anything and I think you would get an abend. Does this even run on a mainframe?
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Aug 23, 2012 10:56 am    Post subject:
Reply with quote

Hi Craq,

The intention was to know if the OP is handling 'end-of-file' correctly as he said, "I do a perform until EOF.", it's ambiguous to follow.

OTOH, code was rather a pseudo-code, not a complete one. First, level-01 is symbolic, so if the code is used as is, because of missing PIC, it'll give an error. If that is ignored, the code was a working example which had been compiled and tested using Microfocus NetExpress, however, that should work on any COBOL-85 complient compiler with very few changes. Having said that, with IBM Enterprise COBOL for z/OS 3.4.1 on z/OS 01.11.00 this code
Code:
.
.
INPUT-OUTPUT SECTION.                                   
FILE-CONTROL.                                           
         SELECT CURIOUSMAINFRAMERFILE ASSIGN TO INFILE.
.
.
DATA DIVISION.                         
FILE SECTION.                           
FD CURIOUSMAINFRAMERFILE.               
01 INREC                      PIC X(80).
.
.
PROCEDURE DIVISION.                           
      OPEN INPUT CURIOUSMAINFRAMERFILE         
         READ CURIOUSMAINFRAMERFILE           
            AT END MOVE HIGH-VALUES TO INREC   
         END-READ                             
         PERFORM UNTIL INREC  = HIGH-VALUES   
            DISPLAY 'YOU ARE HERE :D'         
            READ CURIOUSMAINFRAMERFILE         
               AT END MOVE HIGH-VALUES TO INREC
            DISPLAY 'AT END :'INREC           
            END-READ                           
         END-PERFORM                           
         CLOSE CURIOUSMAINFRAMERFILE           

Produces this (input file had only one record):
Code:
********************************* TOP OF DATA **********************************
                                                                               
                                                                               
 ------------------------------------------------------------------------------
YOU ARE HERE :D                                                                 
EDE4CDC4CCDC47C44444444444444444444444444444444444444444444444444444444444444444
8640195085950A400000000000000000000000000000000000000000000000000000000000000000
 ------------------------------------------------------------------------------
AT END :                                                                       
CE4CDC47FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
1305540AFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
 ------------------------------------------------------------------------------
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 23, 2012 4:15 pm    Post subject:
Reply with quote

what Craq said is valid and should be observed.

you are playing fast, rough, loose and other stuff, around in the record buffer
and an E-O-F situation will not always guarantee a valid record address and will result in a SoC4,
depending upon number of records, block size, number of buffers.

which is why you should always use the work-area option and
never address the buffer (FD record) directly.

eventually, it will bite you in the butt.
Back to top
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Thu Aug 23, 2012 7:06 pm    Post subject: Reply to: Not able to read all records in a file
Reply with quote

Why not just skip the ancient high-value style!
Code:
77  MyIndicators    Pic 9 Value 0.
    88 MyEOF              Value 1.
    . . .

    Perform Until MyEOF
       Read MyFile . . . . . .
          At End
              Set MyEOF to True
          Not At End
              Perform UseMyRecord
       End-Read
    End-Perform
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 23, 2012 7:12 pm    Post subject:
Reply with quote

Quote:
Why not just skip the ancient high-value style!


only thing i can think of Peter,

and I have seen it a lot, which is ok,
because i have earned many an easy dollar/euro
debugging/re-writing this kind of garbage

is that it would require an extra compare (gotta save them bytes!)
to first insure that a file had an active record.

and Anuj's example
(and then caught in a trap of his own making)
was just attempting to help the TS
who has problems reading a file/dataset.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Aug 23, 2012 7:24 pm    Post subject:
Reply with quote

This is what happens when you try to "feed" someone using some "readymade solution" instead of writing a new one. I recall, I put it in here when I was "teaching" an example program that reads a sequential file and displays the records without using the "condition-codes" and this version does not use level 88's to signal when the end of the file has been reached.

My usual style of coding such things is to use "flags", condition names (level 88) "EndOfFile", to signal when the end of the file has been reached. And this is what I wanted TS to invetigate in and 'am not sure where TS has gone!

Yes, you're correct this should have given the S0C4 but surprigingly it did not; I'll try to create one.

Enough for today! icon_smile.gif

And "what was edited", I already read that in the morning. That was rather intresting and eye catching! icon_wink.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Aug 23, 2012 7:28 pm    Post subject:
Reply with quote

And yes, Thanks for keeping me 'in the order', Craq! icon_redface.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Thu Aug 23, 2012 7:37 pm    Post subject: Reply to: Not able to read all records in a file
Reply with quote

Why not stick to the "ancient" style of the "priming read" (so you can deal with a header or an "empty" file)?

Why not the "ancient" style of the read being the last thing in the "loop" to avoid having to avoid it?

Why bother with an "ancient" 77? Why bother with the "ancient" style of giving an unnecessary name rather than FILLER (or "nothing" perhaps?)?

Anuj, don't mess about with putting stuff in the record-area after EOF. It'll work most of the time, but that is not good enough for computers (there is a way to get it to work all the time, but it has consequences - are you using compiler option AWO?).
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 23, 2012 7:42 pm    Post subject:
Reply with quote

Quote:
Yes, you're correct this should have given the S0C4 but surprigingly it did not


well that is not true, as i stated, it depends on many things
and IBM states the results can result in a protection exception

Quote:
I'll try to create one.


don"t waste your time.
the problem is, that it works most of the time
(except late at night when you don't want to deal with a production problem).

I have seen programs run for years
and not encounter the necessary configuration number of buffers/records
to cause a problem.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Aug 23, 2012 7:45 pm    Post subject:
Reply with quote

Hi Bill - I'm not sure if yo missed the last reply from me. Yes, I'm using AWO (and BUFSIZE(32760)).

Well, I know it's not the way of doing it AND can we stop this <adjective> discussion which just came in as a trap...grin
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 23, 2012 7:54 pm    Post subject:
Reply with quote

Anuj,
glad you were able to resolve your problem.....
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Thu Aug 23, 2012 7:58 pm    Post subject: Reply to: Not able to read all records in a file
Reply with quote

OK, if you have the AWO compile option and if you have at least one VB QSAM output file, then you'll never get the S0C4. Never. Never. Not even at 3am on New Year's Day.

Without the output file, I'm not certain - I'd have to check.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 7 Fri Dec 09, 2016 4:40 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us