Search code examples
cobol

Do all files need to be specified in my JCL?


I am currently working on a program that is used in multiple JCL. I have added a new file, the file control looks like this:

SELECT  FILEA          ASSIGN TO  FILEA
        ; ORGANIZATION SEQUENTIAL         
        ; ACCESS       SEQUENTIAL         
        ; FILE STATUS  FILEA-FILESTATUS  
.    

Because this program is used in multiple JCL, If the file must be present in all JCL, that means I will need to dummy the file out in many places. My hope was to only open the file only certain conditions and not need to dummy it out everywhere.

If I don't perform an open on the file, does it still nee a DD name in my JCL?

EDIT: I am running on an IBM mainframe.


Solution

  • Speaking for IBM's mainframe-COBOL: no, you don't need a DD-statement if you never OPEN the file. You might also try to open it and look at the resulting FILE-STATUS to see if the file is there and take appropriate action if it isn't.

    Somtimes COBOL might even allocate a missing file when it is opened. Under Language Environment the behaviour is determined by the value of the runtime-option CBLQDA: if it is ON COBOL will automatically allocate any file that is opened for output but is not defined in the JCL (and delete it after the program has run thus throwing away all data written to that file).