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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol Return Code In MFCobol

Status
Not open for further replies.

klophockey

Programmer
May 25, 2016
41
0
0
US
I would appreciate your expert knowledge on an issue I am encountering but cannot find documentation that puts the issue to rest.

I am using the MFCobol compiler and runtime for this Cobol program.

The issue occurs on AIX, Solaris Sparc and Linux machines.

The file being written to is defined as using a Record Key with duplicates.

I am receiving a return status code of "02" when I write a duplicate record to the file.

When coding the program, I assumed that writing a duplicate record to the file would return a file status of "00"


My questions are
- Is the "02" files status an informational status code or is it actually indicating an error condition?
- Should I expect the file status return code to be "00" or a combination of "00" or "02"?


My file definition and layout is shown below.
Thank you very much for taking time to share your knowledge with me.


SELECT MYFIL3A ASSIGN TO "MYFIL3A"
ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
RECORD KEY IS MYF3A-KEY With Duplicates
FILE STATUS IS STAT3A.


FD MYFIL3A.
01 MYFIL3A-REC.
05 MYF3A-KEY Pic 9(9).
05 MYF3A-TEXT-DATA Pic X(58).
05 MYF3A-ALPHA Pic X(10).
05 MYF3A-ALPHANUMERIC Pic X(20).
05 MYF3A-NUMERIC Pic 9(5).
05 MYF3A-SPACES Pic X(2966).
05 MYF3A-ZEROS Pic 9(31).
05 MYF3A-ZEROS-IN-SPACES Pic X(2000).
*COMP-1
05 MYF3A-C1-1 Comp-1 PIC 9.
05 MYF3A-C1-1S Comp-1 Pic S9.
05 MYF3A-C1-2 Comp-1 Pic 9(4).
05 MYF3A-C1-2S Comp-1 Pic S9(4).
*COMP-2
05 MYF3A-C2-1 Comp-2 Pic 99v99.
05 MYF3A-C2-1S Comp-2 Pic S99v99.
*COMP-3
05 MYF3A-C3-1 Comp-3 Pic 9.
05 MYF3A-C3-1S Comp-3 Pic S9.
05 MYF3A-C3-2 Comp-3 Pic 9(9).
05 MYF3A-C3-2S Comp-3 Pic S9(9).
05 MYF3A-C3-3 Comp-3 Pic 9(3)v99.
05 MYF3A-C3-3S Comp-3 Pic S9(3)v99.
*COMP-4
05 MYF3A-C4-1 Comp-4 Pic 9.
05 MYF3A-C4-1S Comp-4 Pic S9.
05 MYF3A-C4-2 Comp-4 Pic 9(4).
05 MYF3A-C4-2S Comp-4 Pic S9(4).
05 MYF3A-C4-3 Comp-4 Pic 9(7).
05 MYF3A-C4-3S Comp-4 Pic S9(7).
05 MYF3A-C4-4 Comp-4 Pic 9(9)v99.
05 MYF3A-C4-4S Comp-4 Pic S9(9)v99.
*COMP-5
05 MYF3A-C5-1 Comp-5 Pic 9(9).
05 MYF3A-C5-1S Comp-5 Pic S9(9).
*COMP-6
05 MYF3A-C6-1 Comp-6 Pic 9(3).
05 MYF3A-C6-2 Comp-6 Pic 9(4).
05 MYF3A-C6-3 Comp-6 Pic 9(4)v99.
*COMP-X
05 MYF3A-CX-2 Comp-X Pic 9(9).
*COMP-N
05 MYF3A-CN-2 Comp-N Pic 9(9).



Write MYFILA-REC.
Write MYFIL3A-REC.
If STAT3A = '00'
Continue
Else
DISPLAY ' Write MYFILA Record 1 Fail ' STAT3A
End-If.



 
Not being an acknowledged expert on COBOL, allow me to pass on what I have observed in other languages:

I would expect that you will get a "00" when writing a completely new key, and something different when "I added this key, but it's a duplicate". A "02", maybe?

There has to be a manual somewhere that details what each response to a given action means. Such manuals rarely change radically, and the version from 2002 (or 1982) is probably entirely adequate for such things. You should have that manual and its sisters downloaded as PDFs where you can get to them quickly in such times.

Frank Clarke
--America's source for adverse opinions since 1943.
 
Frank....Thank you for your input. I think you have nailed it when you said "I added this key, but it's a duplicate". That is what an '02' means but I haven't found the documentation that explicitly says "An 02 status code will be returned instead of a 00 since your are writing a duplicate key". A mystery that I will continue to see if I can find that specific answer. I know how to fix the Cobol code....just check for a 00 or 02 status code. But that does not explain (document) WHY I am getting the 02. It may seem trivial but I want to put documentation in with the 'fix' code so that nobody else has to research it. Again, thank you. AND....if anyone else has something to share, I would greatly appreciate it.
 
This looks to be an MFCOBOL manual...

[URL unfurl="true"]https://www.microfocus.com/documentation/rm-cobol/1214/RMC-UG.pdf[/url]

Are you sure the duplicate record was written to the file? If not, then the "02" is probably an error code. If the record was written to the file, then the "02" is probably a "duplicate record written" return code. THESE ARE ASSUMPTIONS though.

This page looks to have the return codes you're looking for: [URL unfurl="true"]https://www.microfocus.com/documentation/visual-cobol/vc60/DevHub/HRFLRHFSTA01.html[/url]

From that, "02" means;

Indexed files only. One of two possibilities: For a READ statement, the key value for the current key is equal to the value of that same key in the next record in the current key of reference. For a WRITE or REWRITE statement, the record just written created a duplicate key value for at least one alternate record key for which duplicates are allowed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top