DSPFD of a LF to an outfile contains the based on PF. You can read the file with SQL or RPG.
DSPFD with TYPE(*ACCPTH) and FILEATR(*LF) will create an outfile row for each related PF.
However, the system catalog LF named QSYS/QADBLDEP already contains rows for your LFs.
But you really ought to query the LF object directly. The Retrieve Database File Description (QDBRTVFD) API looks very ugly, but it works like any other API. It just takes a little more time to locate the item you want and to follow the offsets. Here’s an example that accepts a qualified LF name and extracts the first PF along with the PF library:
pgm ( +
dcl &QDBF *char 20
dcl &FDT_BYTRET *int 4
dcl &FDT_BYTAVL *int 4
dcl &PF *char 10
dcl &PF_LIB *char 10
dcl &FDT_OS_PF *int 4
dcl &FDT_OS *int 4
dcl &FDT *char 736
dcl &FDTLEN *int 4 value( 736 )
dcl &QRFD *char 20
dcl &ERRCODE *char 8 value( x'0000000000000000' )
/* &QDBF is file in bytes 1-10, library in 11-20 */
call QDBRTVFD ( +
'*FIRST ' +
'*LCL ' +
'*EXT ' +
/* File definition template offset to scoping array... */
chgvar &FDT_OS %bin( &FDT 317 4 )
/* Scoping array offset to PF... */
chgvar &FDT_OS_PF ( &FDT_OS + 48 + 1 )
chgvar &PF %sst( &FDT &FDT_OS_PF 10 )
/* Add 10 mores bytes for offset to PF library... */
chgvar &FDT_OS_PF ( &FDT_OS_PF + 10 )
chgvar &PF_LIB %sst( &FDT &FDT_OS_PF 10 )
Example call is:
CALL PGM(mylib/RTVDBFPF) PARM('TESTLF1 mylib ')
Add a parm to return the PF and library if you need it. Note that it is a scoping “array”, so there will be an entry for each PF if the LF refers to more than one. Each entry is 160 bytes in length.