How do you retrieve the IFS file name from within a RPGLE program?

1.3k Views Asked by At

In the CL program, I am overriding my print file to a folder on the IFS; however, I am not specifying the file name, just that it will be a PDF file. Thus when the PDF is created the system will assign it a unique file name.

In the RPGLE program, I am using user control to open and close the file; however, I need the unique file name created on the IFS.

I thought using INFDS I could get this info, but I do not see where I can get this info.

If I am posting in the wrong area or I shouldn’t be on this board, please let me know.

Tom

CL program –

PGM 

 OVRPRTF FILE(*PRTF) DEVTYPE(*AFPDS) PAGESIZE(11 8.5 + 
    *UOM) FRONTMGN(0 .25) PAGRTT(0) + 
     PRTTXT(*BLANK) UOM(*INCH) + 
     TOSTMF('/TN/') WSCST(*PDF) 

 CALL PGM(IF010R) 

 DLTOVR FILE(*PRTF) 

 ENDPGM

RPGLE program –

fqsysprt   o    f  132        printer oflind(*inof) usropn                     
 *                                                                             
c                   z-add     1             x                 1 0              
c     x             dowle     5                                                
 *                                                                             
c                   open      qsysprt                                          
c                   except    prtdtl                                           
c                   close     qsysprt                                          
 *                                                                             
c                   add       1             x                                  
c                   enddo                                                      
 *                                                                             
c                   move      *on           *inlr                              
 *                                                                             
 **********************************************************************        
 *                                                                             
oqsysprt   e            prtdtl         1 10                                    
o                                           10 'Test:'                         
o                       x             j     15                                 
2

There are 2 best solutions below

0
On

Think you'll need to use the Retrieve Referenced Objects (QP0LRRO) API

To retrieve the IFS objects currently opened by the job as discussed in this article: Display File Usage Information

0
On

The name of the IFS file isn't available in the INFDS for the file, but it is available in the formatted dump. If you didn't want to use the API that Charles mentioned, you could do a DUMP(A) opcode, and then read through the QPPGMDMP listing to first find the section about your file and then find the "Spool File" line in that section.

 ...
 ILE RPG FORMATTED DUMP
 INFDS FILE FEEDBACK
 File . . . . . . . . . . . :   QPRINT
 File Open  . . . . . . . . :   YES
 File at EOF  . . . . . . . :   NO
 ...
 OPEN FEEDBACK
 ODP type . . . . . . . . . :   ST
 File Name  . . . . . . . . :   QPRINT
    Library . . . . . . . . :   QGPL
 Member . . . . . . . . . . :
                                '00000000000000000000'X
 Spool File . . . . . . . . :   /home/mydir/QPRINTrQpJ$7.pdf