Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol report giving problem in MF 5 1

Status
Not open for further replies.

kaps121

Programmer
Dec 23, 2008
5
US
Hi,

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
 
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.
 
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..
 
Another small information

The upgrade was done from MF 2.2 to v5.0.
 
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.
 
Make sure the "IS INITIAL" option is not on, either explicitly or by default.
 
Updates:

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
 
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.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top