Contact US

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!

*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 Return Code In MFCobol

Cobol Return Code In MFCobol

Cobol Return Code In MFCobol

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.


05 MYF3A-KEY Pic 9(9).
05 MYF3A-TEXT-DATA Pic X(58).
05 MYF3A-ALPHA Pic X(10).
05 MYF3A-NUMERIC Pic 9(5).
05 MYF3A-SPACES Pic X(2966).
05 MYF3A-ZEROS Pic 9(31).
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).
05 MYF3A-C2-1 Comp-2 Pic 99v99.
05 MYF3A-C2-1S Comp-2 Pic S99v99.
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.
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.
05 MYF3A-C5-1 Comp-5 Pic 9(9).
05 MYF3A-C5-1S Comp-5 Pic S9(9).
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.
05 MYF3A-CX-2 Comp-X Pic 9(9).
05 MYF3A-CN-2 Comp-N Pic 9(9).

If STAT3A = '00'
DISPLAY ' Write MYFILA Record 1 Fail ' STAT3A

RE: Cobol Return Code In MFCobol

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.

RE: Cobol Return Code In MFCobol

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.

RE: Cobol Return Code In MFCobol

This looks to be an MFCOBOL manual...


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: https://www.microfocus.com/documentation/visual-cobol/vc60/DevHub/HRFLRHFSTA01.html

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.

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