AS400 Retrieve QUERY Print Definitions inside of CL procedure.

50 pts.
Tags:
AS/400 Query
CL Procedure
WRKQRY
Inside of a CL procedure, I want to retrieve the printer name being used by the designated query. I need to do this without any prompting, therefore using WRKQRY, option 6 to print definitions will NOT work. What is the alternative. I simply need to know the printer name used in all of the queries in the house without manually opening up each query using WRKQRY.

Software/Hardware used:
AS400 I-Series

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 12  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    I'm not aware of any way to extract info from a WRKQRY query definition other than by using MI functions, in CL or any other language. It can only be done interactively. That's another reason to get away from the old query functions. Tom
    125,585 pointsBadges:
    report
  • DanTheDane
    Pls clarify; - why do you need the printername from your queries ? For what purpose? Do you need it for queries run interactively or via the RUNQRY command? DanF
    2,555 pointsBadges:
    report
  • MeAndCL
    Dan, we are in the process of changing all of the printer names to a different naming convention. Because most of the queries send the output to a specific printer, we will need to know which queries are affected by the printer name change. These queries will need to be modified to point to the new printer names. Ray
    50 pointsBadges:
    report
  • MeAndCL
    Danf, We are needing to change all current printer names to confirm with a new naming convention. Many of our queries generate printer output to printers. Therefore, all queries that use the current printer names need to be identified so that they can be modified later when the printer name change goes into effect. Currently, I generate a list showing the library, query name, and printer name by reading the print definition spool file(s) created by using WRKQRY option 6 (which is a manual chore, I prefer the operator NOT perform). I simply want my program to accomplish this task without operator intervention. I may be overlooking something... is there any other source that I can access that will show the output device used in a designated query? If so, this would most likely eliminate the use of WRKQRY so that my procedure will be fully automated. Ray.
    50 pointsBadges:
    report
  • John Andersen
    @Ray Unfortunately there is not a good solution for this... RTVQMQRY gets the SQL out of the query definition but misses the other stuff like outfile and printer. -John Andersen
    195 pointsBadges:
    report
  • Splat
    Are your queries directing the output to printer devices or output queues?  If the latter, wouldn't it make sense to keep the old output queues and monitor them for new output - you could then make the necessary adjustments to the query definitions on an as needed basis (something that will need be done manually in any event)
    7,055 pointsBadges:
    report
  • ToddN2000
    You may be able to do it with some work. You might be able to dump all the definitions to print, copy the spool files to a flat file with an *add option then read the file. You could select the records that contain the query name and the one with the printer for the output. It's still a lot of work to go through and you still have to manually fix each one that has a new printer. If possible convert them to the new QMQRY. Then you can change the definitions programmatically in the future.
    9,700 pointsBadges:
    report
  • TomLiotta
    If possible convert them to the new QMQRY.   New?? They've been available (no extra cost) on all AS/400s and successors since V2. The (very useful) user interface does cost, though it comes as an integrated part of the SQL Dev Kit. But you can create *QMQRYs without the user interface. You can even use WRKQRY as a basic user interface if you already paid for that.   Tom
    125,585 pointsBadges:
    report
  • WoodEngineer
    Printers are associated with output queues, which are typically the same name as the printer.  However, that is not required.  You could point existing output queues to your new printer names.  The queries should continue to run and print.  Then you could tackle changing the queries over time. By the way, the system allows multiple output queues to point to the same printer.  We use this feature occassionally.
    6,435 pointsBadges:
    report
  • ToddN2000
    We have Lots and I mean LOTS of the old WRKQRY ones (1500+). The issue we have is that a lot of our users ( not the IT department ) created them. To roll out the QMQRY for them would involve the IT staff trying to train some of users who still cannot write their own currently. The only people here who have ever written/seen a SQL statement is a select few in the IT staff, so users would be dumbfounded. I know QMQRY has been out for a while but I see old habits die hard, as many here still prefer the the WRKQRY as their comfort zone. 
    9,700 pointsBadges:
    report
  • TomLiotta
    The only people here who have ever written/seen a SQL statement is a select few in the IT staff, so users would be dumbfounded.   Knowledge of SQL is not required for QM queries. A user need not see a SQL statement to create/change/run a QM query if the user interface is installed (or if WRKQRY is used as the user interface for creation). That's a major point of the user interface, to insulate users from the SQL that executes when the query runs.   Tom
    125,585 pointsBadges:
    report
  • ToddN2000
    A lot of our query users cannot do more than a simple one. no more than 3 files and a few select record statements.. They often get confused when using the "OR". They do not realize it a whole new condition and they should probably use a LIST or NLIST. It's always been trying to formulate the selection criteria that causes call to the helpdesk for support. It's been a while since I've been in QMQRY and I no longer have access due to my new position in the company.  For the users in question I do not see this being an easier for them and they always fight change. 
    9,700 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following