Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Cobol report giving problem in MF 5

Cobol report giving problem in MF 5

Cobol report giving problem in MF 5


We have a routine which generates a report. This routine is called from another routine. The routine which generates the report is called first to open and initiate the report.

Next time it is called to write a record to the report. But when it tries to do a generate statement, it gets the following error

231 GENERATE encountered before corresponding INITIATE in report

I debugged the routines and found that initiate was in fact being done. Only thing was it was not being done in the same call where generate statement was executed. Instead it was being done in another call. But I dont think that shud cause a problem.

One more important thing - the same report is working in a previous version of Cobol. We recently upgraded to MF Cobol 5 and this stuff is not working here. Also we are facing the problem with all the reports in our application but only with new version of cobol.
The previous verison of our application is in old version of cobol and it runs fine. Appreciate any hints/insight/suggestions/ inputs

RE: Cobol report giving problem in MF 5

IMHO, if it worked in previous version of MF COBOL and it don't work in the current version contact the MF support.
Was your previous COBOL version from MF too?

The error you write is probably only a message from your program.

>The routine which generates the report is called first to open and initiate the report...
I don't understand why you call the routine from a main program first-time to open a report and then second time to write into.
And what is your report?: Is it a table or a textfile or a printer file?
IMHO, if it is something of above (a table, a file,..) it need to be opened in the same program which writes into - maybe I'm wrong, but I do it ecerytime so.

RE: Cobol report giving problem in MF 5

Thanks for the reply mikro.. i already contacted microfocus support for the same..

see the report is getting created in a big application which does many other things other than create the report.

Take it like this. A main routine is reading records from file. For each record, there is a lot of processing being done. If something goes wrong, a message needs to be written into the report.

So, since its a big file we are reading. The standard way we do it is first call the report routine for initialize purposes. It opens the report and also initiates it in this call. An input parameter to the routine controls the flow i.e. whether to open/initiate or write or close report file. The report routine has different flows based on this input parameter

Then it starts processing the records and if error found, it calls the report routine again using an input parameter of Write records. It is here in this call that we get the message.

The application/report works perfectly fine in previous version of Cobol. Could have to do something with the way microfocus cobol 5 handles reports vis a vis to previous versions.

The report is a text file. Its created using the report section (RD) entry in the routine

Let me try contacting the support. Meanwhile Any other suggestion/idea is welcome..

RE: Cobol report giving problem in MF 5

Another small information

The upgrade was done from MF 2.2 to v5.0.  

RE: Cobol report giving problem in MF 5

I thing when the called subprogram opens the file in the first separate call, then the file will be automatically closed, when the subprogram ends. And the next time if it try to write a record into the file, the file is closed and that's the problem.

I would try to fix that by coding to open the file for appending second time before writing records.
If it is a text file you can open it every time, then write (i.e. append) the record and close it and then next time the same: open file - append a record - and close.

But I know it's simply to say, but not so simply to do - i.e. to modify an old big program, that was running for years without error.
But when this worked in the previous version, then maybe look at any compiler (or linker) switches, to compile and link the programs so, that their behaviour is as in the previous compiler version.

Is that MF COBOL for Windows? Are you upgraded the MF COBOL from windows native aplications (i.e. EXE) to managed .NET ? If so, try to create instead of managed .NET app the windows native app -i.e EXE.

RE: Cobol report giving problem in MF 5

Make sure the "IS INITIAL" option is not on, either explicitly or by default.

RE: Cobol report giving problem in MF 5


I debugged the problem and just before the generate gave a initiate statement only for the first record.

The report ran fine for 3-4 records but again gave the same problem. So, it does not seems the problem is anything to do with open/close files. It seems more like the indicator which cobol stores to indicate that the file has been initiated is getting overridden somehow.

Since the report works for a few records and again gives this problem it makes me feel that another file i/o being done in between is causing the switch to get overridden somehow.

So you initiate the report. You do some file i/o with other file, the switch gets overridden. you again initiate it and than it works fine until the time you do another file i/o. And again the switch gets overridden,

Also you cannot initiate the report again and again because that means creating the report header multiple times..

Webrabbit, dint get which option you were talkin abt? I searched my routine and there seems to be nothing of that sorts defined in the routine. Please elaborate.

Mikron, we are using cobol on unix and no we dint upgrade it from exe to net. I also feel it could be some compiler option causing this but cudnt fathom what. Still trying..lemme know if u can find something

RE: Cobol report giving problem in MF 5

The syntax for PROGRAM-ID includes the IS INITIAL PROGRAM option.  With this option, the program is in its initial state every time it starts or is called.  For some dialects of COBOL, this is the default option and must be overridden.

RE: Cobol report giving problem in MF 5

Hi webrabbit,

Thanks for the valuable input but no the is initial option is not set and all variables are keeping the values between calls...

Now here is the line of thinking we are trying to go

Cobol must be storing the information that the report has been initialized somewhere internally. If we get to know where and be able to read the memory map between various calls, we might be able to pin point what exactly is overriding the particular value...

Btw, another problem we facing with MF 5 is related to indexed files. We have a big indexed file with multiple alternate keys. The program crashes after some time in such a case. If the alternate keys are removed the program works. This also is happening only in the upgraded version and not in the previous version....
Might be something to do with how cobol 5 handles the memory etc...

Appreciate Any tools/clues/hints that might help resolving the issue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close