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!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Which parameters do you need?
I have the beginnings of a program that I could modify for you.

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.


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.  
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Okay, I will dig up my program and post something for you later today.
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:
/* PARMS FOR RETRIEVE DEVICE DESCRIPTION API */                          
DCL &DDRCVR     *CHAR    1469   /*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 &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'                                  
             MONMSG     MSGID(CPF0864) EXEC(DO)                              
             GOTO       CMDLBL(ENDOFFILE)                                    
             IF (&ODOBAT *EQ 'PRTLAN  ') THEN(DO)                            
             /*RETRIEVE THE ATTRIBUTES OF THE PRINTER */                      
             CHGVAR &DEVCLS      %SST(&DDRCVR  153 10)                        
             CHGVAR &MFRTYP      %SST(&DDRCVR  573 20)                        
             CHGVAR &IPADDR      %SST(&DDRCVR 1065 15)                        
             SNDPGMMSG (&ODOBNM || &DEVCLS || &MFRTYP || &IPADDR || &ODOBTX)  
             GOTO       CMDLBL(NEXTDEVD)                                      
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!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dhardy95Author Commented:
Thanks Barry!  We'll give it a try tomorrow.  

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).

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

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.