On 17-Oct-2011 07:55 , Patrick Tonnerre wrote:
> Le 12/10/2011 22:02, JTF a écrit :
>> On 10-Oct-2011 07:42 , Patrick Tonnerre wrote:
>>>
>>> my goal is to identify the LAN printers which do not have an
>>> internet name in RMTLOCNAME parameter into their device
>>> description.
>>>
>>> For that, I need to produce a file (or a list) containing the
>>> device name and its RMTLOCNAME parameter
>>>
>>> All the lan printers name start with P, so the list will look
>>> like that:
>>>
>>> PSGJGG 192.168.10.55
>>> PKHKHKJ 192.168.10.75
>>> PGDGDGD PDNSNAM01
>>>
>>> I've tried a lot of thing :  <<SNIP>>
>>>
>>> I do not succeed in getting that file/list. <<SNIP>>
> an IP address instead of a DNS name.
>
   A "Remote location name type" of *IP, as provided by the Retrieve 
Device Description (QDCRDEVD) API, will presumably give the desired 
value for review.
   Combining the above DSPOBJD with a SQL UDF, a SQL query report could 
list the name, attribute, and Remote Location Name.  A very rough and 
limited example of what could be performed and an example of possible 
output follows.  Since data from the API can not generally be mapped 
directly from raw data to typed data, a more prudent means instead, 
would be to use an object list API combined with the device description 
API to produce an external UDTF, producing a TABLE [function result] of 
only printer device descriptions and perhaps only those with RMTLOCNAME 
data.  The following example might be functional [no IPV6 support as 
coded] for the original intent without any modifications.
<code>
    /* create callable interface to the API from SQL */
    create procedure dcrdevd
    ( inout char(1800) for bit data, in int, in char(8)
    , in char(10) , inout char(08) for bit data )
    language CL parameter style general
    external name qsys/qdcrdevd
    /* create a UDF to return the specific DCRDEVD detail */
    create function prtdrmtloc (devdnm char(10) ccsid 37)
    returns char(255)
    language sql not deterministic modifies sql data
    returns null on null input
    set option dbgview=*LIST
    begin
     declare rcvvar char(1800) for bit data not null default '';
     declare rcvlen int not null default 1800;
     declare apifmt char(08) not null default 'DEVD1100';
     declare errcde char(08) for bit data not null
                                 default x'0000000000000000';
     declare devctg char(10) not null default '';
     declare loctyp char(10) not null default '';
     call dcrdevd ( rcvvar, rcvlen, apifmt, devdnm, errcde );
     set devctg = substr(rcvvar, 32, 10);
     set loctyp = substr(rcvvar, 1331, 10);
     return case when (devctg='*PRT' and loctyp='*IP')
                 then substr( rcvvar, 1065, 255)
            end;
    end
    /* generate a list of device descriptions; includes *PRT */
    dspobjd *all *devd *full output(*outfile) outfile(qtemp/pd)
    /* generate a report of devices with a "printer" attribute */
    select odobnm,odobat,prtdrmtloc(odobnm)
    from qtemp/pd
    where odobat like '%PRT%'
    ....+....1....+....2....+....3....+....4 ...
    Object      Object      PRTDRMTLOC
                Attribute
    PRT01       PRTLCL      -
    PRT02       PRTVRT      -
    RPRT01      PRTLAN      192.168.10.100
    RPRT02      PRTLAN      192.168.10.110
    SA77        PRTVRT      -
</code>
Regards, Chuck