I have one COBOL pgm A which is calling another COBOL pgm B. In pgm B I need one file.How can I write JCL so that I would be able to access this file in pgm B? I have written select clause and FD entry for this file in B.
You must include a DD statement in the JCL for the step that executes Program A.
If the file exists, that's quite easy.
//ABCDEFGH DD DISP=SHR,DSN=your.file.name.here
Where ABCDEFGH is the name you uses in your SELECT statement in Program B.
If you are creating a new file, you must take into account the estimated space your file will use and where you want to place it.
//ABCDEFGH DD DISP=(NEW,CATLG,DELETE),
// DSN=your.file.name.here,
// AVGREC=K,
// RECFM=FB,
// LRECL=your-lrecl-here,
// MGMTCLAS=your-management-class-here,
// SPACE=(your-lrecl-here,(primary-number-of-records,secondary),RLSE)
This is just freehand, you really should look at the JCL Reference and JCL User's Guide.