On 11/30/2019 10:29 AM,
[email protected] wrote:
On Friday, November 29, 2019 at 1:51:16 PM UTC-5, Jonathan Ball wrote:
I have scoured the API section of the IBM i Knowledge Center, and I can't
find an API that returns the program references for OPM programs. The
QBNLMODI API apparently does for modules, but only ones that are bound into >> ILE programs. This omission seems so unbelievable, I have to think I'm
just missing it - possibly hidden in plain sight.
Does anyone have any ideas?
I could have sworn there was an API equivalent but I'm danged if I can find it either. Any reason you can't use DSPPGMREF? At least you could use SQL against the results.
I can, but I prefer not to have to run DSPPGMREF to an outfile before
querying. If there were an API, I could create a table function that
returns the program references dynamically, something like:
select *
from table(mylib.get_pgm_ref ('PGMNAM','PGMLIB')) r
In fact, I was able to create a table function anyway, in which the RPGLE service program for the table function executes DSPPGMREF internally into
an outfile in QTEMP, then return the results in a SQL script window. A potential problem is that DSPPGMREF is "not safe" for a multithreaded job.
However, I get the same overall results if I do either of these:
Scenario 1:
_Step 1_
call qcmdexc ('dsppgmref pgmlib1/*all output(*outfile) objtype(*all)
outfile(qtemp/refs) outmbr(*first *replace)');
_Step 2_
call qcmdexc ('dsppgmref pgmlib2/*all output(*outfile) objtype(*all)
outfile(qtemp/refs) outmbr(*first *add)');
_Step 3_
select whpnam,whlib,whfnam,whlnam
from qtemp.refs
where whotyp = '*FILE';
Scenario 2:
_Step-only_
select o.objname,s.schema_name,r.ref_obj_nam,r.ref_obj_lib
from qsys2.sysschemas s
cross join lateral
(select * from table(object_statistics (s.schema_name,'PGM,SRVPGM')) o) o
cross join lateral
(select * from table(mylib.get_pgm_ref (o.objname,s.schema_name)) r) r
where schema_name in ('PGMLIB1','PGMLIB2')
and r.ref_obj_typ = '*FILE';
I have written numerous table functions that retrieve various kinds of data
via calls to APIs, typically for data items for which IBM hasn't (yet)
supplied a view or UDTF in QSYS2. One example is a table function to
return all the journal receivers in a journal's current receiver chain.
This allows me to summarize the receivers information by detach date. Over time, IBM has made some of the functions I've developed obsolete by
including a new view or UDTF in a technology refresh. Another example is I earlier wrote a UDTF similar to OBJECT_STATISTICS, because prior to 7.3,
IBM's function doesn't return any journaling info on the objects.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)