Question: How do I invoke a JCL from a COBOL program?
Answer: The easiest way to do this is to have your JCL in a file ready to be submitted. If the program needs to create all or part of the JCL then this can be created as 80 character records and written to a file from the program just like you write to any other file. Any static parts of the JCL can be created once in files that can be concatenated to the file dynamically created in the program so as to create the complete JCL.
You then add an extra step following the program that has created the JCL that is to be run. This job step will concatenate the necessary files and copy them to the internal reader (this effectively submits the job). The JCL step to do this is as follows (just substitute your values for the entries in lowercase):
//stepname EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=jclfile,DISP=SHR
//SYSUT2 DD SYSOUT=(class,INTRDR)
//SYSIN DD DUMMY
This method will work regardless of the programming language used to dynamically create the JCL as the program just writes the JCL to an ordinary file.
This article written by Stephen Chapman, Felgall Pty Ltd.