As a first step to resolving your issue insert, just before your FCLOSE
call, a little loop that gets the FFILEINFO information (eg. file name,
but check the manual for all options you might be interested in) for all
file numbers in the range 0-100 and also display the file number you are
passing to that FCLOSE call.
This code essentially gives you a list of all files opened by the
current process :
Move 0 to w-a-counter
Perform 100 times
add 1 to w-a-counter
CALL INTRINSIC "FFILEINFO" USING W-A-COUNTER,
1, DBFI-FILENAME
DISPLAY W-A-COUNTER " " DBFI-FILENAME
END-PERFORM
My guess is that you're somehow forcing the cobol program to close the
file by mixing and matching the Cobol open/read/write verbs with the
lower level HP intrinsics.
Essentially the former (cobol verbs) resolve to the latter - so whenever
you ask HP Cobol to open a file, it calls FOPEN on your behalf and
internally remembers a file-number to be used on all subsequent Cobol
read/write/close calls. Your FCLOSE call could therefore be passing
down to MPE the valid File number of the PAGE012 file by accident.
Also, you could adapt the above code to search the process'es file
number table to check whether the TEMPOUT file is indeed currently open
(another FINFO option I think) and then only issue the FCLOSE command if
necessary.
-----Original Message-----
From: HP-3000 Systems Discussion [mailto:[log in to unmask]] On
Behalf Of Brian Donaldson
Sent: 12 February 2005 18:53
To: [log in to unmask]
Subject: [HP3000-L] Cobol/Intrinsics/MPEiX File System Problem (?)
Interesting little thing I just discovered -- maybe programmer brain
damage, maybe not....... :-)
I have a Cobol program that does read/writes to multiple files.
Code examples here:
SELECT PAGE-012-FILE ASSIGN TO "PAGE012,,,DISC,500000"
ORGANIZATION IS INDEXED
RECORD KEY IS PAGE-012-KEY
WITH DUPLICATES
ALTERNATE RECORD KEY IS PAGE-012-LINE-SEQ-NO-X
WITH DUPLICATES
ACCESS MODE IS RANDOM
FILE STATUS IS WS-STATUS.
FD PAGE-012-FILE.
01 PAGE-012-RECORD.
05 PAGE-012-FILE-NAME PIC X(26).
05 PAGE-012-DATA-RECORD.
10 PAGE-012-KEY.
15 PAGE-012-PAGE-NO PIC 9(05).
15 PAGE-012-LINE-NO-X.
20 PAGE-012-LINE-NO PIC 9(02).
10 PAGE-012-DATA-TABLE.99
15 PAGE-012-LINE-SEQ-NO-X.
20 PAGE-012-LINE-SEQ-NO PIC 9(04).
15 PAGE-012-STREAM-LINE PIC X(256).
The "PAGE012" (temporary) file is accessed with the Cobol READ/WRITE
verbs.
I use the MPEiX intrinsics FOPEN/FWRITE/FCLOSE on another temporary file
named "TEMPOUT".
"PAGE012" is already open when I try to work on the "TEMPOUT" file.
(Opened with the Cobol OPEN I-O verb.)
Before I do the "FOPEN" on the temp file "TEMPOUT" I do an "FCLOSE" on
it with a \4\ disposition (close with delete option). Just a
precautionary measure to make sure the old version of "TEMPOUT" is gone
before FOPENing a new one.
Well, guess what? The "FCLOSE" with the \4\ disposition is closing and
purging the "PAGE012" file !!
My solution to the problem was to remove the "FCLOSE" with the \4\
disposition but therein remains the mystery.
Is this a bug in the file system or an application bug in my program?
(Nah, never -- every programmer writes "perfect" code, right?)
Actually, this reminds me of another "problem" I discovered many eons
ago (pre 5.5) that it was disastrous to use "FOPEN" and "HPFOPEN" in the
same program as they both can return the SAME file number on different
files!!
I don't know if HP ever fixed that probem or not....
PROCEDURE DIVISION.
...
...
*Added as precaution to ensure file is closed and non-existent before
FOPEN
CALL INTRINSIC "FCLOSE" USING WS-FILE-NUM-OUT,
\4\
\0 \.
MOVE "TEMPOUT" TO WS-TEMP-FILE-NAME.
MOVE ZEROES TO ERR-FLAG.
MOVE SPACES TO WS-STOP-FLAG.
CALL INTRINSIC "FOPEN" USING WS-TEMP-FILE-NAME,
\4\ \1\
WS-REC-SIZE,
\\ \\ \\ \\
\\ WS-FLIMIT-SIZE
\\ \\ WS-FILE-CODE-2
GIVING WS-FILE-NUM-OUT
END-CALL.
IF C-C NOT = ZEROES THEN
CALL INTRINSIC "FCHECK" USING WS-FILE-NUM-OUT,
WS-ERROR-CODE
\\ \\ \\
END-CALL
MOVE 10 TO WS-MSGNUM
MOVE 1 TO ERR-FLAG
MOVE "Y" TO WS-STOP-FLAG
GO TO XXXX-EXIT
END-IF.
CALL INTRINSIC "FCLOSE" USING WS-FILE-NUM-OUT,
\%12\ \0\
END-CALL.
Brian Donaldson.
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
The contents of this email are confidential to the intended recipient
and may not be disclosed. Although it is believed that this email and
any attachments are virus free, it is the responsibility of the recipient to confirm this.
Smith & Williamson Corporate Finance Limited - A member of M&A
International Inc. http://www.mergers.net Registered in England No.
4533970. Authorised and regulated by the Financial Services Authority
Smith & Williamson Investment Management Limited, Registered No. 976145. Authorised and regulated by the Financial Services Authority.
Smith & Williamson Pension Consultancy Limited - Independent
Intermediary. Registered No. 3133226. Authorised and regulated by the
Financial Services Authority.
Smith & Williamson Fund Administration Limited, Registered No. 1934644. Authorised and regulated by the Financial Services Authority.
Smith & Williamson Limited - A member of Nexia International.
Registered in England No. 4534022. Regulated by the Institute of
Chartered Accountants in England & Wales for a range of investment
business activities.
Registered Office: No 1 Riding House Street, London W1A 3AS
Telephone: 020 7637 5377 http://www.smith.williamson.co.uk
Nexia Audit Limited - A member of Nexia International. Registered in
England No. 4469576. Registered to carry on audit work and regulated by the Institute of Chartered Accountants in England & Wales for a range of investment business activities.
Registered Office: No 1 Riding House Street, London W1A 3AS
Telephone: 020 7637 5377 http://www.nexiaaudit.co.uk
NCL Investments Limited, Registered No. 1913794.
Member of the London Stock Exchange authorised and regulated by the Financial Services Authority.
Registered Office: Bartlett House, 9-12 Basinghall Street, London EC2V 5NS
Telephone: 020 7600 2801
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|