Two legacy COBOL problems that look the same in a program list, and how to tell whether a CA 2E model still owns the logic
In I Stopped Converting COBOL to RPGLE Free I made the case for wrapping stable hand-written COBOL instead of porting it to RPGLE line by line. In my CA 2E compile reference I covered what goes wrong when a CA 2E model generates RPG and the compile fails.
This post sits between those two. There's a kind of "legacy COBOL" that is neither: COBOL that a CA 2E model generated, where the model still exists, and where nobody ever switched the function's target language to RPG. In a program list it looks exactly like hand-written COBOL. It isn't, and the difference changes how you'd convert it safely.
If the terms model, function and action diagram are new to you, the CA 2E glossary covers them. As with the rest of this series, none of the library, model, function or field names here are real.
CA 2E can generate COBOL, and plenty of models still do
CA 2E generates either RPG or COBOL. The target language is set for each function, with a model-wide default, and a model that has been in production for decades can have functions whose target was set once and never looked at again. Nobody necessarily decided to keep COBOL. The setting just never changed, because the function kept working and nobody had a reason to open it.
From outside the model, the program that comes out is hard to tell apart from hand-written COBOL. It's the same object type and the same general shape, with no RPG anywhere. The only reliable way to tell is to check whether a function in some model still claims it: whether the model's function list has an entry whose generated program name matches the object you're looking at.
Do that check before you pick a conversion approach, because the two cases need opposite strategies. If you're still working out which programs matter at all, finding out which ones anyone still runs comes first.
Why the difference matters so much
Hand-written COBOL with no model behind it is the situation the wrap-versus-rewrite post describes. The COBOL text is the only place the business rule is written down. Converting it means reading that text and re-implementing it, and every implicit behavior has to be rediscovered by reading code: key order standing in for FIFO, a status code that means two things depending on context, a journal side effect nobody documented. Nothing else records them.
Model-generated COBOL is different in one important way. The rule isn't only in the COBOL. It's also in the action diagram, the model's own statement of the logic, which doesn't depend on the target language. The COBOL is one rendering of that statement.
So if the model is intact and nobody has drifted away from it (more on that below), converting the function to RPG isn't a port of COBOL syntax at all. It's a regeneration. You change the function's target language, generate again, and get RPG produced fresh from the same design the COBOL came from. It's a second rendering of the same source, not a translation of the first one.
That avoids a whole category of conversion bugs. A regeneration doesn't hand-map COBOL indicators to RPG indicators, doesn't hand-translate a picture clause, and doesn't turn a PERFORM … THRU range into a subroutine that quietly skips a paragraph in the middle. Those bugs come from a person reading COBOL and writing RPG. The generator never reads the COBOL, so it can't make them.
What regeneration doesn't make safer
Three things carry over no matter which language the function targets.
Access-path field coverage. If a function reads through an access path that doesn't carry every field the logic needs, that's a fact about the data layer. You get the same "field doesn't exist" failure whether the function generates COBOL or RPG, because the generator can only use what the access path exposes. Changing the target language doesn't add a field that was never on the format. Check this before you regenerate. It's the same check that matters when you're troubleshooting an ordinary RPG compile.
User source written in COBOL. CA 2E lets you embed hand-written code in a model through Execute User Source functions, and that code is in the target language. If a COBOL function calls user source, that source is COBOL, and changing the target language doesn't translate it. It has to be rewritten in RPG by hand, and it carries all the risks of a hand port. Find these before you regenerate, because they're the parts of the "regeneration" that aren't really regenerated.
Anything patched directly into the generated source. This is the one that matters most, and it's easy to miss because nothing about it produces an error. Sometimes a generated COBOL member gets edited directly: a shortcut because the model was slow to change, or a fix made under time pressure with a plan to "put it back in the model later" that never happened. That edit exists only in the source member and the compiled object. The model knows nothing about it.
Regenerate under a new target language and the patch is gone. Nothing warns you and nothing logs it. The new RPG source reflects what the action diagram says, and that may no longer match what production has been doing for years.
That's the real risk in treating "switch the target language and regenerate" as a shortcut around the wrap-versus-rewrite decision. It can be lower risk than a hand port, but only if the model and the running object have stayed in step. If they haven't, regenerating doesn't keep the drift. It erases it, and nothing in the regeneration itself tells you that happened. Fix It in the Model or Fix It in the Source? covers how drift like this starts and how to stop it happening again.
How to find drift before you regenerate
There are three checks, from quickest to most reliable.
See what the object was compiled from. DSPOBJD with DETAIL(*SERVICE) shows the source file and member a program was created from, and the date the source had when it was compiled. If that points somewhere other than the model's generation library, or to a member that isn't the generated one, someone built the object from a copy.
Compare dates. If the source member in the generation library was changed after the function was last generated, something edited it outside the model. Dates are a signal, not proof. A change date can move for reasons that have nothing to do with the code.
Regenerate and compare. The check you can rely on is to generate the function again, still targeting COBOL, in a copy of the model, and compare the result with the production source member using CMPPFM or any diff tool. If the two match, apart from generation timestamps and comments, the model is a faithful statement of what production runs. If they don't, the differences are your drift, written out line by line.
If there's drift, treat the program like hand-written COBOL with no model behind it, because in practice that's what it has become. Work out what the object actually does in production first. Then decide whether to put the patches back into the model before regenerating, or to wrap it and leave it alone.
A short checklist
- Confirm a live function owns the object. A program that looks Synon-generated isn't the same as one a current model claims. Check the model's function list, not just the naming convention.
- Look for user source. Any Execute User Source function the program uses is COBOL written by hand, and it won't regenerate as RPG. Plan to rewrite it.
-
Check for drift before you change the target language. Use
DSPOBJD DETAIL(*SERVICE), the dates, and a fresh generation compared against the production member. - With no drift, regeneration is a legitimate conversion path. It's a fresh rendering from the same design, and it avoids the bugs that come from translating COBOL syntax by hand.
- With drift, treat it like hand-written COBOL. Characterize what the object does in production first. The model's version is no longer a reliable statement of current behavior.
- Check access-path field coverage separately. It applies whatever the target language, whether you're fixing a COBOL compile, an RPG compile, or deciding whether to regenerate at all.
- Give the regenerated RPG the same care as any CA 2E generation, then test it. The right libraries and access paths still have to be in place, and a clean compile still isn't proof the program does the same thing. Run the old COBOL object and the new RPG object side by side on the same data before you switch over.
Jaya Krushna Mohapatra is a Warehouse Management Systems Architect focused on enterprise integrations, IBM i modernization, and scalable backend systems.
Top comments (0)