A: This might work for you. Do a Display Object Description (DSPOBJD) to an outfile to capture the names of all the queries on your system. Next, with a CL, read through the outfile and do a Retrieve Query Management Query (RTVQMQRY) on each query. This will retrieve the source of the query into the source file of your choice. Once your source file is built, you can use the scanning capabilities of PDM to scan the source members for the field names you're looking for. Unfortunately, the RTVQMQRY doesn't include what kind of output the query generated. But you can do a Display File Field Description (DSPFFD) on the file in question, get the field names, and then search the members created by the RTVQMQRY.
Figure 1 below shows how I did my DSPOBJD.
Figure 1: Use DSPOBJD to an outfile to find all your queries
Once you have your outfile created, I suggest that you create a special source file to contain the retrieved source. I created a source file called QQRYSRC with a record length of 150 and put it into my programming "test" library.
To retrieve the source for each query, use the code in Figure 2.
Figure 2: Use this code to retrieve the source for queries on your system.
Figure 3: Work with the members in your QQRYSRC file via PDM.
On my system, I know that I have a file that's created by a query. The name of this file is WEBQTYF1. One of the fields in my file is @ITITM#. So I'll scan all the source members for this field name and see if I can find the query.
To initiate the scan, put a '25' in the first option field, and then press F13 to repeat the option to the end of the list. Your screen should look like Figure 4.
Figure 4: Use Option #25 to scan source members in PDM
When ENTER is pressed, you'll be prompted for the search string, as shown in Figure 5:
Figure 5: Enter the search text, and set the search options.
There are a couple of parameters to watch out for. Be sure that the "Kind of match" is set to the proper case search; I always ignore case. And for our purposes here, you probably want to use option #5 (browse) instead of option #2 (edit). Using edit requires you to press F3 and then Enter to exit a source member, whereas browse requires only that you press Enter to exit a source member.
So, I've keyed in the field that I want to search for, and I've pressed Enter. When the search finds my entered text, the source member is brought up in browse mode. See Figure 6.
Figure 6: Use the PDM "Find String" option to browse or edit source members containing specific text.
In my case, I'm done searching; by comparing the fields that are selected in this query vs. the fields in my file, I can see that this is indeed the query that created my file, and using this method was a lot easier than trying to examine every query via the WRKQRY command!