• No DSPPGMREF API

    From Jonathan Ball@jonball52@gmail.com to comp.sys.ibm.as400.misc on Fri Nov 29 10:51:13 2019
    From Newsgroup: comp.sys.ibm.as400.misc

    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?
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From jonboy49@jonboy49@partner400.com to comp.sys.ibm.as400.misc on Sat Nov 30 10:29:14 2019
    From Newsgroup: comp.sys.ibm.as400.misc

    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.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Jonathan Ball@jonball52@gmail.com to comp.sys.ibm.as400.misc on Sat Nov 30 11:37:43 2019
    From Newsgroup: comp.sys.ibm.as400.misc

    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.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From jonboy49@jonboy49@partner400.com to comp.sys.ibm.as400.misc on Sat Nov 30 11:53:45 2019
    From Newsgroup: comp.sys.ibm.as400.misc

    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.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Obelix@obelix.it@gmail.com to comp.sys.ibm.as400.misc on Sun Dec 1 12:20:42 2019
    From Newsgroup: comp.sys.ibm.as400.misc

    Il 30/11/2019 20:37, Jonathan Ball ha scritto:
    call qcmdexc ('dsppgmref pgmlib1/*all output(*outfile) objtype(*all)
    -a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a 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.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From poc@poc@pocnet.net to comp.sys.ibm.as400.misc on Tue Dec 3 21:54:29 2019
    From Newsgroup: comp.sys.ibm.as400.misc

    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

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From jonboy49@jonboy49@partner400.com to comp.sys.ibm.as400.misc on Tue Dec 3 15:31:04 2019
    From Newsgroup: comp.sys.ibm.as400.misc

    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.
    --- Synchronet 3.21d-Linux NewsLink 1.2