Search code examples
ibm-midrange

CL: How can I traverse thru all physical files in a Library?


I want to create a CL that displays latest version names of all Physical Files in a library. Using library name as input parameter, how can I display the names of all Physical Files? Once I get the names, I can proceed with versions but I am stuck on this. Please suggest.

Thanks in Advance :)


Solution

  • Old school answer

    The Display Object Description (DSPOBJD) command has an output parm that accepts *OUTFILE. You simply use the model file, QADSPOBJ, in your DCLF statment and use OVRDBF to override to your actual output file prior to using the RCVF command to read the first record.

    Problems with that is that the format of the output file could change with a new version or even with the application of a PTF.

    Generic Modern answer
    Use ILE CL and the List Objects (QUSLOBJ) API. The returned data is dumped into a user space. You can use the user space APIs to access it inside your ILE CL program.

    Table (PF) specific modern answer
    (Taken from an answer by jmarkmurphy)
    You can also try using SQL as referenced by John Y. Here is a Query that will return all the physical files in a library:

    select * 
    from qsys2.systables
    where table_type in ('P', 'T')
      and table_schema = 'MYLIB'
      and file_type = 'D'