We help IT Professionals succeed at work.

getting printer devd into a physical file

dhardy95
dhardy95 asked
on
Medium Priority
688 Views
Last Modified: 2012-06-21
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!
Comment
Watch Question

Barry HarperConsultant
CERTIFIED EXPERT

Commented:
Which parameters do you need?
I have the beginnings of a program that I could modify for you.
Barry
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

Author

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.  
Barry HarperConsultant
CERTIFIED EXPERT

Commented:
Okay, I will dig up my program and post something for you later today.
Barry
Consultant
CERTIFIED EXPERT
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks Barry!  We'll give it a try tomorrow.  
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
Barry HarperConsultant
CERTIFIED EXPERT

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

Tom
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.