View previous topic :: View next topic
|
Author |
Message |
tvinodkumar7
New User
Joined: 06 Jan 2015 Posts: 19 Location: Hyderabad, INDIA
|
|
|
|
Can we do reset browse in COBOL batch program just like RESETBR in CICS ?
My Scenario :
As per my requirement I have to do multiple dynamic reads on a single file.
In that process if I receive any END OF FILE, I am closing and reopening the file for not to get abend.
If we get same in CICS, we use RESETBR.
Can anyone suggest how to do in a batch program ?
TIA.[/u] |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You're going to have to show some of your code. What abend? Presumably you are aware of START ... KEY IS ... or READ ... KEY IS ...? Opening an closing a file more than once in a program is never necessary. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Replying to a topic more than 9 years old, and starting a new, totally unrelated thread in the topic, is something you should not be doing. I've split the new thread from the old topic. |
|
Back to top |
|
|
tvinodkumar7
New User
Joined: 06 Jan 2015 Posts: 19 Location: Hyderabad, INDIA
|
|
|
|
@Bill Woodger
Thank you for your reply.
I am getting file status 46 (expected) as I am trying to read the same file after getting file status - 10.
Can we have any alternative to Closing and opening a file multiple times in the cobol batch program ?
@Robert Sample
I believe this will give added knowledge. Anyways thank you for creating a new thread.
TIA |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
After you get the file status 10, before you attempt another READ NEXT, you MUST do a START to reset the key location. Your 46 file status indicates you are not doing this.
There is NEVER a need to close and re-open a file in a COBOL program. Sometimes people code their programs to do this, but it is due to lack of understanding of logic and COBOL that causes this.
You need to add the START logic to your program and your file status 46 will go away. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
In your SELECT statement, ACCESS must be DYNAMIC (not SEQUENTIAL nor RANDOM), because you're jumping all over the file (simulating a CICS RESETBR).
HTH.... |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
I believe there can be another method instead of opening and closing file multiple times in a program. If your file is small, then you can populate it in an array and use SEARCH to get the records you want.
If the file is being used in other programs in the similar manner then you can write a subprogram that reads the file, populate the array (when called for the first time from main module) and search (when called subsequent times from the main module).
. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
RahulG31 wrote: |
If the file is being used in other programs in the similar manner then you can write a subprogram that reads the file, populate the array (when called for the first time from main module) and search (when called subsequent times from the main module).
|
Actually, a sub-program would not be necessary. Just define an ODO table/array in LINKAGE, with a very high-maximum and have a previous step pass the number of records in the flat-file. If this is a VSAM file, then yes, a sub-program would be necessary which issues a SHOWCB macro.
After obtaining the number of records, multiply this number by the LRECL and add 4 (ODO Fullword). Then, call LE Callable Service routine "CEEGTST" and obtain the amount of storage you need and set your Fullword appropriately. After that, read the file into the table/array and that will be that.
By using the ODO with a high-maximum in LINKAGE, you're only allocating enough storage for the size of the file, which could vary from one run to another.
If the table/array was defined to WS with a very high-maximum, the amount of storage allocated is always the maximum size of the ODO, so it would be a waste of resources.
IMHO.... |
|
Back to top |
|
|
tvinodkumar7
New User
Joined: 06 Jan 2015 Posts: 19 Location: Hyderabad, INDIA
|
|
|
|
@Robert Sample
Thank you for your solution. It is working great.
Thanks everyone for your responses.... |
|
Back to top |
|
|
|