ibm-midrangerpglerpg

How to query a file created in qtemp by a submitted job


There is a job that gets submitted. That job calls a program which creates a temporary file in its qtemp. Can someone tell me how to query that file in the qtemp of the job?


Solution

  • The objects within the QTEMP library for a submitted job are not viewable from outside of the job. If you want to actually review the data created within the job by your program, you will need to copy it out to either a work library or library such as "QGPL". So something like the following code snippet would need to be done.

    PGM
    
    /* A temporary file is created in QTEMP*/
    
        CRTPF QTEMP/DATA
        
    /* A program is run that populates the file */  
    
        CALL PGM(PGM1)
        
    . . . /* Job continues */
    
        CPYF FROMFILE(QTEMP/DATA) TOFILE(QGPL/DATA)     /* Save a copy that can be evaluated */
        
    ENDPGM  /* The file and library QTEMP for this job is gone*/
    

    Probably the optimal way would be to create an analysis library and then have the batch job copy the file (or files there). Then the files can be removed when no longer needed.