Reputation: 2527
Is there a way to capture all called programs in a program including parameters (name, type and length) for each called program
DSPPGMREF to outfile gets me half-way there...
DSPPGMREF PGM(MYLIB/*ALL) OUTPUT(*OUTFILE) OUTFILE(QTEMP/MYFILE)
Upvotes: 0
Views: 1260
Reputation: 3664
If you compile the programs with PGMINFO(*PCML:*MODULE), either as a command parameter or in the H spec, the program will contain the Program Call Markup Language describing the parameters.
You can retrieve the PCML from the program using the QBNRPII API. This article has a commmand that just displays the PCML http://ibm.biz/see_pcml_embedded_in_pgm_or_srvpgm, but you could modify it to use XML-INTO or XML-SAX to get the information in a usable way. (XML-INTO might not work very well if the parameters might be complex data structures.)
For a program with the following PI:
dcl-pi *n;
name char(25) const;
salary packed(9:2);
end-pi;
Here's an example of the PCML
<pcml version="6.0">
<!-- RPG program: PCMLTEST -->
<!-- created: 2018-04-18-08.01.17 -->
<!-- source: BMORRIS/QRPGLESRC(PCMLTEST) -->
<!-- 1 -->
<program name="PCMLTEST" path="/QSYS.LIB/BMORRIS.LIB/PCMLTEST.PGM">
<data name="NAME" type="char" length="25" usage="input" />
<data name="SALARY" type="packed" length="9" precision="2" usage="inputoutput" />
</program>
</pcml>
To get it in this nice format, I compiled my program with PGMINFO(*PCML:*STMF) INFOSTMF('PCMLTEST.pcml'). The PCML that gets generated into a module (and then placed in a program) doesn't have any newline characters or extra spacing.
Here's what the RPG Cafe command shows for this same program:
Printing PCML info
Object: BMORRIS/PCMLTEST *PGM
Module: *ALLBNDMOD
Length of information: 320
Length of data: 227
0: <pcml version="6.0"> <program name="PCMLTEST" entr
50: ypoint="PCMLTEST"> <data name="NAME" type="char" l
100: ength="25" usage="input" /> <data name="SALARY" ty
150: pe="packed" length="9" precision="2" usage="inputo
200: utput" /> </program></pcml>
Upvotes: 3
Reputation: 1605
Judging from the context of the question, I assume you want to do this from analysis of the source or objects and not at runtime.
As far as I know, there is no simple way to do this with the built-in IBM i tools short of building your own cross-reference tool. There are plenty of third party cross-reference tools that will do this for you however I know of none that are free on the IBM i. An unexhaustive list that only includes the ones I've personally used are Hawkeye Pathfinder, MDCMS, or Fresche X-Analysis.
Upvotes: 2