Retrieve Source Code

Article ID: 54224

Q: I've accidentally deleted the source code to my ILE program. How can I retrieve it? What about Cobol or C source?

Q: OPM CL source code can be retrieved with RTVCLSRC. Is there an equivalent for ILE CL?

A: Before I answer your question, I feel obligated to say this: Your source code is valuable. It costs a lot of money to develop programs. It should have an important place in your backup strategy so that you can always retrieve an archived copy of the code, and you never have to try to retrieve it from the object. Think of the cost of paying you and other developers to write and maintain your code, and you'll see what I mean.

Now that that's off my chest, I'll get off of the soapbox and tell you how to retrieve the source code for any ILE programming language.

When the Source Is in the Object

The OPM CL compiler stored everything it needed to recreate the source code into the *PGM object — that's why the RTVCLSRC command was able to retrieve the code.

All ILE compilers provide an equivalent capability. All you have to do is specify DBGVIEW(*LIST) or DBGVIEW(*ALL) on the compile command when you compile the object. This stores the source code into the object itself where you can retrieve it later. I recommend that you always use DBGVIEW(*LIST) when you compile an ILE program in any language. It makes debugging easier and makes it possible to retrieve the source code later. It does require a little extra disk space, but frankly, on a modern system you'll never notice it.

If you've used DBGVIEW(*LIST), the source code is embedded in the program object and can be retrieved with free utilities.

  1. The RTVSRC utility from the article "Retrieve Source from ILE Modules," by Chris Stead (System iNEWS, September 1997):
    http://www.systeminetwork.com/article.cfm?id=2097

    Note: If you're an Associate member, you won't be able to download Chris Stead's source code from the System iNEWS code facility, so I've put it at the following link:
    http://www.pentontech.com/IBMContent/Documents/article/54224_179_RtvSrc.zip

  2. The RTVILESRC utility from Alex Nubla:
    http://www.geocities.com/~alex_nubla/tips.htm

When the Source Isn't in the Object

The last resort when you don't have a backup and haven't compiled the source code into the object is to use a tool that will try to regenerate the source code by looking at what the compiled code does.

As far as I know, there's no free tool to reverse engineer your code this way. There is, however, a company that makes a commercial product. Here's a link to its website:
http://www.juggersoft.com

These types tools can typically figure out which operations your program performs, but they can't retrieve the original comments, and they usually have no way of knowing what the original variable names were. But if you really need them, they can be a lifesaver.

ProVIP Sponsors

ProVIP Sponsors