120 pts.
 Retrieve AS/400 Printer definition
I would like to let my users override the printed output to a printer of their choice but I need to protect them from themselves. Is there a way that I can determine if the name they enter is a valid print device? I would like to be able to do this in an RPG program on an AS400 running V5R4.

Software/Hardware used:
AS400 V5R4
ASKED: November 8, 2010  8:28 PM
UPDATED: November 9, 2010  1:31 AM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

One possible beginning direction would be:

DSPOBJD OBJ(*ALL) OBJTYPE(*DEVD) OUTPUT(*OUTFILE) OUTFILE(QTEMP/DEVD)

With QTEMP/DEVD populated, you’d perhaps be interested only in the devices that satisfied this condition:

SELECT * FROM qtemp/devd WHERE ODOBAT like '%PRT%'

It’s not required to use SQL to limit the rows only to “printer” devices. A CL program could use RCVF to read each row to see if the device name matched what was requested and if that device attribute indicated that it was a form of printer device. Any HLL could do the processing.

Or you could simply run:

CHGDEVPRT DEVD( <devicename> )

If you execute CHGDEVPRT with no parms other than DEVD(), the only things that happen are verification that such a device exists and that it’s actually a printer. If either condition is false, an *ESCAPE message is returned.

There are more definite solutions if you want to use system configuration APIs. I can’t tell how far you want to go with this. Keep in mind that elements such as a user’s authority to a device or to an *OUTQ might be involved. Also, a “printer” device might not actually exist — it might only be a “remote output queue”.

Tom

 107,735 pts.