• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 620
  • Last Modified:

getting printer devd into a physical file

I need some of the parameters from the dspdevd command to output to a physical file so that the info can be used in queries or downloaded to a spreadsheet.  I don't need all of the devd parms, but I do need all *LAN printers.  The rtvcfgsrc command outputs the info to a source file, but I don't know how hard it would be to write a program to output this info to a physical file.  We have over 300 printers here and keeping documentation up to date is diificult.  Is there a way to do this?  Thanks!
0
dhardy95
Asked:
dhardy95
  • 4
  • 3
  • 2
1 Solution
 
_b_hCommented:
Which parameters do you need?
I have the beginnings of a program that I could modify for you.
Barry
0
 
tliottaCommented:
dhardy95:

I'd probably go with a program that:

1. Called the List Configuration Descriptions (QDCLCFGD) API to list Configuration description type '*DEVD' and Object qualifier '*LANPRT' into a user space.

2. Retrieved each entry from the space, and then...

3. INSERTed each entry into a table (or physical file).

I wouldn't be surprised if Barry's program turns out to do something similar.

Tom

0
 
dhardy95Author Commented:
Thanks, Barry!!  The parameters I need are devd, devcls, mfrtypmdl, rmtlocname, and text.  We have so many printers it's a nightmare trying to keep the documentation current on the devices.  
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
_b_hCommented:
Okay, I will dig up my program and post something for you later today.
Barry
0
 
_b_hCommented:
This will get you started. As Tom mentioned, using the list APIs and RPGLE would make for a neater solution. This method is easier to understand if you do not know user spaces or RPGLE.
I may rewrite this, but for now the CL program creates a list of devices, retrieves the attributes of LANPRT devices, the RPG writes them out to the physical file.
To create the objects, add the library that these objects will live in to your library list.
The first step is to create a physical file by putting this source in a QDDSSRC source member named GETPRTPF, type PF, and compiling it:
                R PRTFM                                                          
                  WRITER        10          COLHDG('PRINTER' 'NAME')              
                  CLASS         10          COLHDG('DEVICE' 'CLASS')              
                  MFRTYP        20          COLHDG('MANUFACTURER' 'TYPE/MODEL')  
                  RMTLOC        15          COLHDG('REMOTE' 'LOCATION')          
                  DESC          50          COLHDG('DESCRIPTION')    
We need an RPG program to write the data out to the physical file.            
Then put this source in a QRPGSRC member named GETPRTR, type RPG, and compiling it:
     FGETPRTPFO   E                    DISK                                  
     C           *ENTRY    PLIST                                              
     C                     PARM           WRITER                              
     C                     PARM           CLASS                              
     C                     PARM           MFRTYP                              
     C                     PARM           RMTLOC                              
     C                     PARM           DESC                                
     C                     WRITEPRTFM                                        
     C                     SETON                     LR                      
     C                     RETRN                                              
(For performance reasons, the RPG could return with LR off)
Now the CL program that does the heavy lifting.
Then put this source in a QCLSRC member named GETPRT, type CLP, and compiling it:
PGM                                                                      
/* PARMS FOR RETRIEVE DEVICE DESCRIPTION API */                          
DCL &DDRCVR     *CHAR    1469   /*RECEIVER VARIABLE                  */  
DCL &DDRCVRLEN  *CHAR       4   /*LENGTH OF RECEIVER VARIABLE        */  
DCL &DDRCVRFMT  *CHAR       8   /*FORMAT NAME                        */  
DCL &ERRCDE     *CHAR       8   /* API ERROR CODE PARAMETER          */  
/**/                                                                      
DCL &IPADDR     *CHAR      15   /* IP ADDRESS                        */  
DCL &DEVCLS     *CHAR      10   /* DEVICE CLASS                      */  
DCL &MFRTYP     *CHAR      20   /* MANUFACTURER TYPE AND MODEL       */  
DCL &MSG        *CHAR      80                                            
/**/                                                                      
DCLF       FILE(QADSPOBJ)                                                
/**/                                                                      
             /* CLEAR THE LAST LIST */                                    
             CLRPFM GETPRTPF                                              
             DSPOBJD    OBJ(QSYS/*ALL) OBJTYPE(*DEVD) +                  
                          OUTPUT(*OUTFILE) OUTFILE(QTEMP/QADSPOBJ)        
             OVRDBF QADSPOBJ TOFILE(QTEMP/QADSPOBJ)                      
             CHGVAR  &DDRCVRLEN  X'000005BD'    /* X'05BD' IS 1469 OF DATA */
             CHGVAR  &DDRCVRFMT  'DEVD1100'                                  
NEXTDEVD:                                                                    
             RCVF                                                            
             MONMSG     MSGID(CPF0864) EXEC(DO)                              
             GOTO       CMDLBL(ENDOFFILE)                                    
             ENDDO                                                            
             IF (&ODOBAT *EQ 'PRTLAN  ') THEN(DO)                            
             /*RETRIEVE THE ATTRIBUTES OF THE PRINTER */                      
             CALL QDCRDEVD (&DDRCVR &DDRCVRLEN &DDRCVRFMT &ODOBNM &ERRCDE)    
             CHGVAR &DEVCLS      %SST(&DDRCVR  153 10)                        
             CHGVAR &MFRTYP      %SST(&DDRCVR  573 20)                        
             CHGVAR &IPADDR      %SST(&DDRCVR 1065 15)                        
             CALL GETPRTR (&ODOBNM &DEVCLS &MFRTYP &IPADDR &ODOBTX)          
             SNDPGMMSG (&ODOBNM || &DEVCLS || &MFRTYP || &IPADDR || &ODOBTX)  
             ENDDO                                                            
             GOTO       CMDLBL(NEXTDEVD)                                      
ENDOFFILE:                                                                    
ENDPGM:                                                                      
             ENDPGM                                                          
If you would like the source and compiled objects in a save file, post back and I will send them to you.
Post back any questions!
Barry
0
 
dhardy95Author Commented:
Thanks Barry!  We'll give it a try tomorrow.  
0
 
tliottaCommented:
Barry:

Any reason you couldn't simply use CPYF instead of CALL GETPRTR?

The CPYF could select on ODOBAT *EQ 'PRTLAN  ' via INCREL and also use FMTOPT(*MAP *DROP).

Tom
0
 
_b_hCommented:
How would the attributes retrieved by QDCRDEVD get into the file?
Barry
0
 
tliottaCommented:
Heh, DUH! Yeah, I skipped right over that. End of a long day.

Tom
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now