• No DSPPGMREF API

    From Jonathan Ball@21:1/5 to All on Fri Nov 29 10:51:13 2019
    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?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jonboy49@partner400.com@21:1/5 to Jonathan Ball on Sat Nov 30 10:29:14 2019
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jonboy49@partner400.com@21:1/5 to Jonathan Ball on Sat Nov 30 11:53:45 2019
    On Saturday, November 30, 2019 at 2:37:46 PM UTC-5, Jonathan Ball wrote:
    <snip>

    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.

    You really should hang out on one of the more active lists like midrange.com or even code400.com.

    You're wasting your talents over here in no mans land. There are very few posts here and few people even following.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jonathan Ball@21:1/5 to jonboy49@partner400.com on Sat Nov 30 11:37:43 2019
    On 11/30/2019 10:29 AM, jonboy49@partner400.com 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)
  • From Obelix@21:1/5 to All on Sun Dec 1 12:20:42 2019
    Il 30/11/2019 20:37, Jonathan Ball ha scritto:
    call qcmdexc ('dsppgmref pgmlib1/*all output(*outfile) objtype(*all)
                      outfile(qtemp/refs) outmbr(*first *replace)');
    For such a function, i would call tmpnam() to get a temporary file name
    for the output file, so you can run several concurrent extraction
    without overlapping them.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From poc@pocnet.net@21:1/5 to Jonathan Ball on Tue Dec 3 21:54:29 2019
    Jonathan Ball <jonball52@gmail.com> 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?

    Is this even possible? AFAIK OPM programs can't be linked in but just called. And OPM certainly knows only about calls but not about binding.

    :wq! PoC

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From jonboy49@partner400.com@21:1/5 to p...@pocnet.net on Tue Dec 3 15:31:04 2019
    On Tuesday, December 3, 2019 at 3:54:31 PM UTC-6, p...@pocnet.net wrote:

    Is this even possible? AFAIK OPM programs can't be linked in but just called. And OPM certainly knows only about calls but not about binding.


    Good point - I misread the original post and was looking for the files etc. that the program referenced.

    All calls in OPM are fundamentally dynamic so the system does not keep a record of who calls what.

    Normally tools like Hawkeye or Arcad etc. are used for this kind of stuff.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)