View previous topic :: View next topic
|
Author |
Message |
CuriousMainframer
New User
Joined: 28 Feb 2012 Posts: 9 Location: India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
the info posted is not enough to provide a reasonable answer |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
That happens all the time to me, when there are only 3 records in the file. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
If you don't mind can you paste the code for us?? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Peter said -
Quote: |
That happens all the time to me, when there are only 3 records in the file. |
Now that's funny.... |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
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.... |
Well Bill, when i posted that i had a LOL too. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Peter cobolskolan
Active User
Joined: 06 Feb 2012 Posts: 104 Location: Sweden
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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!
And "what was edited", I already read that in the morning. That was rather intresting and eye catching! |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
And yes, Thanks for keeping me 'in the order', Craq! |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Anuj,
glad you were able to resolve your problem..... |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
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
I like the other forum where there is a section titled "Stupid Questions"
but probably over here it would be overcrowded |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
and the soc4 was is relation to input file.
why all this discussion of output file? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|