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

Not able to read all records in a file


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

New User


Joined: 28 Feb 2012
Posts: 9
Location: India

PostPosted: Wed Aug 22, 2012 11:13 am
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Aug 22, 2012 11:44 am
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed Aug 22, 2012 12:15 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Aug 22, 2012 12:43 pm
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

Global Moderator


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

PostPosted: Wed Aug 22, 2012 1:01 pm
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

Superior Member


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

PostPosted: Wed Aug 22, 2012 2:44 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Aug 22, 2012 7:03 pm
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed Aug 22, 2012 10:03 pm
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
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

Superior Member


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

PostPosted: Thu Aug 23, 2012 10:56 am
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
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
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
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

Superior Member


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

PostPosted: Thu Aug 23, 2012 7:24 pm
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

Superior Member


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

PostPosted: Thu Aug 23, 2012 7:28 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 23, 2012 7:37 pm
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
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

Superior Member


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

PostPosted: Thu Aug 23, 2012 7:45 pm
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
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 23, 2012 7:58 pm
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
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Aug 23, 2012 7:59 pm
Reply with quote

has anybody noticed that the TS has disappeared,
it was clear to me that he/she was supposed to post the failing code..
but for some obscure reason he/she preferred to drop the issue.

if it was for me I would save lots of resources by banning such posters and deleting all their posts

but probably somebody might remark that I am overreacting icon_cool.gif

I like the other forum where there is a section titled "Stupid Questions"

but probably over here it would be overcrowded
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 23, 2012 8:15 pm
Reply with quote

Yes, it would likely be such a trivial thing that TS would find it once they got over the idea that it must be something "funny" going on.

However, not a total loss, the thread. As long as someone stuffs in a bit of code somewhere along the way, we're quite happy to comment and improve.

Anuj has suffered on this one - don't use compiler option AWO (my personal command), instad use APPLY WRITE ONLY for each QSAM VB output file.

Yes, I know what IBM says in the performance document :-)
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 10:08 pm
Reply with quote

and the soc4 was is relation to input file.
why all this discussion of output file?
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 10:21 pm
Reply with quote

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.


Hmmmm? accessing the Record within the FD
before opening or after closing??
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 23, 2012 10:49 pm
Reply with quote

Yep :-)

OK, I'm talking specifically about after EOF, Anuj's example in question.

Compiler option AWO is nuts (if you search, you'll see some discussion from last year). AWO is nuts because it affects input QSAM VB files as well as output. So, instead of the FD addressing the buffer, with the possibility of being outside of your allowed storage at the end of the final buffer, it instead is a "record-area", with the data from the buffer MOVEd to it. Same for the WRITE. So, since it is a record-area, within the Cobol run-time.

Before the file is OPEN and after the file is CLOSED I don't know, not tried. But in Anuj's example it will never get a S0C4.

Without the compile option AWO, the code would behave in the "usual" way and occasionally blow up.
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top