How to find sub-procedure usage in RPG on IBM i?

Viewed 399

If I have a service program with a single module which contains three sub-procedures. Is there a way to programmatically find the usages of the individual sub-procedures within a library/file?

So something like this:

MYLIB/MYSRVPGM  <-- My service program object
  PROC1  <-- My first sub-procedure
  PROC2  <-- My second sub-procedure
  PROC3  <-- My third sub-procedure

Then I have an ILE program which uses PROC1 and PROC3 but not PROC2.

MYLIB/MYPGM  <-- My ILE program object which uses PROC1 and PROC3

I'm looking for a way to search for PROC1 or PROC3 and see the result of MYLIB/MYPGM returned. However a search for PROC2 should not return a result.

So far, I've tried using DSPPGMREF, but that only returns the overall object (IE: MYLIB/MYSRVPGM), not the individual sub-procedures used.

Another route I've ventured was using FNDSTRPDM but that's just scanning the source for the string PROC1. It could be in a comment and return a false positive.

I know third-party tools exist for this, but they are not viable options at the moment due to cost. Free or relatively cheap ones may be an option though (I'm just not aware of any). Am I out of luck?

3 Answers

The only thing I know of that might work from existing *PGM / *SRVPGM objects would be to build something around the debug APIs

You said that third-party tools are not an option, I assume you mean the commercial ones you'd pay a pretty penny for.

What about open source? Take a look at the Easy/400 Program library check up

I use the iSphere plugin within RDi to do this. If you are not using RDi, then you are already behind the eight-ball when it comes to development for IBM i. iSphere doesn't have the direct ability to find imports, but it does have a source search facility that I like better than FNDSTRPDM. You can search a member, a source file, all the source files in a library, or even everything in an RDi filter for a given string.

Yes it is a source search, but, it is relatively easy to tell if something is a comment or not.

Related