How to check that how a file is being used in different programs in AS/400

35 pts.
Tags:
AS 400
Hi,
Could someone help me with the below query.
Is there any command or way to check that how a file is being used in different programs? Like DSPPGMREF will show that what are the files used in a given program. In the same way do we have any command or process to check what are the different programs are using given file.
Thanks,
Satish

Answer Wiki

Thanks. We'll let you know when a new response is added.

Run the command

DSPPGMREF PGM(MYLIB/*ALL) OUTPUT(*OUTFILE) OUTFILE(QTEMP/PGMREF)
When done, query the file looking for your file name and then the type
WHFUDG = File usage values
1=I,2=O,3=I/O,4=U,5=I/U,6=O/U,7=I/O/U,8=N/S,0=N/A

Discuss This Question: 9  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.
  • TheRealRaven
    The DSPPGMREF command works because programs have to know what files they use. Therefore the references can be queried in each individual program object.

    But files can be accessed ad hoc at any time in many different ways. There's no way that a file object can know from one minute to the next which objects might access it. The only real possibility is to create your own database of references for all user programs in the system and to query it for the files that you want. DSPPGMREF can be run for each program to add entries.

    Bear in mind that files may be referenced by programs that are in numerous other libraries. You might schedule a nightly or even weekly run over programs in all user libraries. A risk would be that the references database could be out of date by a few hours or a few days.
    27,060 pointsBadges:
    report
  • ToddN2000
    There used to be some 3rd party programs that did the process of maintain cross reference databases that did just that. Hawkeye / Pathfinder is one I have used in the past. Nice utility for large development systems.
    109,850 pointsBadges:
    report
  • azohawk
    DSPPGMREF will not pick up files in an imbedded SQL statement.
    3,645 pointsBadges:
    report
  • Splat
    azohawk, it will if you use OBJTYPE(*ALL).
    12,600 pointsBadges:
    report
  • TheRealRaven
    There are various cases where files won't be picked up. An obvious example is a dynamic SQL statement constructed at run-time. A native I/O request where the file name is supplied via variable can be another.

    But in such cases, examination of source is always needed no matter what. These are examples of reasons why file I/O references should be isolated to dedicated modules.
    27,060 pointsBadges:
    report
  • ToddN2000
    I agree with Raven. There are a number of ways to get close but you still have to SCAN the source, both RPG and CL, to increase you odds of finding them all. I have see some creative programmers in my days putting names in a table at the bottom of a program then doing a manual OVRDBF and open close to process multiple files through the same code. Even still; nothing can be a guaranteed 100 % success if unusual coding methods have been used.
    109,850 pointsBadges:
    report
  • HimanshuS

    I face this problem regularly. Some of my earlier companies used Hawkeye's Pathfinder for this purpose. Now I have to use DSPPGMREF PGM(*ALLUSR/*ALL)           
              OUTPUT(*OUTFILE)            
              OBJTYPE(*ALL)               
              OUTFILE(HIMANSHUS/PGMREF), import it into an Excel, and then search or filter. But this does often overload MS Excel and slows down the system.

    You could also use QUERY for this. It also helps if the coding follows some standards.

    This will miss cases where the filenames appear in a program variable, Query Definitions, or SQL. To be thorough, I have to scan sources and look into code. There is no easy way out.

    65 pointsBadges:
    report
  • TheRealRaven
    I do similar to @HimanshuS but I query right on the system rather than exporting to Excel or elsewhere. Since it runs only when developers are not making changes and I run it daily, the resulting table is essentially never more than a few hours out of date.

    There can always be exceptions. QM queries and other uses can always reference files that may be missed.

    27,060 pointsBadges:
    report
  • ToddN2000
    I suppose you could dump the QM QUERY source to a file and then scan that for the file names as well. Use the RTVQMQRY command.
    109,850 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.

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

Following

Share this item with your network: