Hello World COBOL Program and JCL

1.2k views Asked by At

I have a simple COBOL program that prints Hello World:

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
     DISPLAY "Hello World!"
     STOP RUN.

This is in the following dataset: INSTPS1.COBOL(HELLO).

But I can’t seem to figure out the JCL to run it. This is the script:

//INSTPS1X   JOB  30000000,'MVS1 JOB CAR  ',MSGLEVEL=(1,1),CLASS=A,MSGCLASS=Q,NOTIFY=&SYSUID,TIME=1440,REGION=0M
//COMPILE  EXEC  IGYWCL,
PARM=(OFFSET,NOLIST,ADV),
PGMLIB='INSTPS1.COBOL.LOADLIB',GOPGM=HELLO
COBOL.SYSIN  DD  DSN=INSTPS1.COBOL(HELLO),DISP=SHR
COBOL.SYSLIB  DD DSN=INSTPS1.COBOL.LOADLIB,DISP=SHR

I get the following error:
“ENDED AT ESSMVSI MAXCC=0008 CN(INTERNAL)”

What am I doing wrong?

2

There are 2 answers

0
cschneid On

Your JCL has a number of syntax errors. Each statement must begin with two slashes, cannot extend beyond column 71, a continued statement ends with a comma, the continued part of the statement also begins with two slashes and at least one space.

//INSTPS1X   JOB  30000000,'MVS1 JOB CAR  ',MSGLEVEL=(1,1),
//           CLASS=A,
//           MSGCLASS=Q,
//           NOTIFY=&SYSUID,
//           TIME=1440,
//           REGION=0M
//COMPILE  EXEC  IGYWCL,
//         PARM=(OFFSET,NOLIST,ADV),
//         PGMLIB='INSTPS1.COBOL.LOADLIB',GOPGM=HELLO
//COBOL.SYSIN   DD DSN=INSTPS1.COBOL(HELLO),DISP=SHR
//COBOL.SYSLIB  DD DSN=INSTPS1.COBOL.LOADLIB,DISP=SHR
0
phunsoft On

Analysis of your JCL

Firstly, I doubt the JCL as posted is the JCL that was actually run. If this JCL was submitted it would yield in a "continuation not recevied" type of error message, and the "ENDED AT" message would say "JCL ERROR".

Secondly, the JCL procedure IGYWCL does a compile and bind (link edit), only. It does not run the program just compiled and bound. You need to use IGYWCLG, which will execute the program, provided the compiler and binder steps had not errors. (This is true if the both procedures have not been loclly modified.)

Thirdly, not sure where you got the information from that you need a PGMLIB symbolic parameter. There is no such in neither procedure.

Fourthly, all comments that cschneid has made in his answer regarding correct formatting apply.

Try the following JCL:

//INSTPS1X   JOB  30000000,'MVS1 JOB CAR  ',MSGLEVEL=(1,1),
//           CLASS=A,
//           MSGCLASS=Q,
//           NOTIFY=&SYSUID,
//           TIME=1440,
//           REGION=0M
//COMPILE  EXEC  IGYWCLG,
//         PARM.COBOL=(OFFSET,NOLIST,ADV)
//COBOL.SYSIN DD DSN=INSTPS1.COBOL(HELLO),DISP=SHR

Notes

  • The PARM you specified are actually parameters for the compiler, so you need write PARM.COBOL=....
  • The compile step, i.e. the compiler, does not know a SYSLIN DD. This belongs to the binder (linkage editor). But you don't need to specify any at all; the procedure has all you need for this case.
  • The procedure passes the compiler output, i.e. the object deck, in a temporary data set to the binder. No need to do anything.
  • The procedure passes the binder output, i.e. the program, in a temporary data set to the execution step GO. Again, no need to do anything.

Analysis of procedure IGYWCLG

Here are some comments about the compile, link, and go procedure. I'm posting only the statements I want to comment on.

//IGYWCLG PROC LNGPRFX='IGY630',LIBPRFX='CEE',GOPGM=GO 
//********************************************************************* 
//*  IBM Enterprise COBOL for z/OS                                    * 
//*               Version 6 Release 3 Modification 0                  * 
//********************************************************************* 

This is the start of the procedure. It defines three symbolic parameters:

  • LNGPRFX=
  • LIBPRFX=
  • GOPGM=

All are assigned default values.

//COBOL   EXEC PGM=IGYCRCTL,REGION=0M

This starts the compiler in step COBOL. The parameters specified via PARM.COBOL= are sent to the compiler.

//SYSIN    DD  DSNAME=&SYSUID..CBL(&SRC),DISP=SHR                       
...
//SYSLIN   DD  DSNAME=&&LOADSET,UNIT=SYSALLDA,                          
//             DISP=(MOD,PASS),SPACE=(CYL,(1,1)),VOL=(,,,1)             

These are the interesting DD statements in the compile step.

  • //SYSIN DD defines the place, i.e data set, from which the comiler reads the program source.
  • //SYSLIN DD defines a new, temporary data set into which the compiler writes the object deck, i.e. the compiled version of the program. This is the input for the bind (linkage editor).
//********************************************************************* 
//SUCCESS IF RC < 8 THEN                                                
//********************************************************************* 
//LKED    EXEC PGM=IEWBLINK,REGION=0M                                   

When the compiler ends with a return code lower than 8, it has written the object deck into SYSLIN, so there is something for the binder to work on. The binder is only started in this case.

//SYSLIN   DD  DSNAME=&&LOADSET,DISP=(OLD,DELETE)                       
//         DD  DDNAME=SYSIN                                             
...
//SYSLMOD  DD  DSNAME=&&GOSET(&GOPGM),SPACE=(CYL,(1,1,1)),   
//             UNIT=SYSALLDA,DISP=(MOD,PASS),DSNTYPE=LIBRARY ```

These are the interesting DD statements in the bind step.

  • //SYSLIN DD. The binder reads the object deck from this DD, which points to the temporary data set created in the compile step.
  • //SYSLMOD DD defines a new, temporary data set into which the binder writes the load module, i.e. the executable version program.
//GOODMOD  IF RC < 8 THEN                                               
//********************************************************************* 
//GO      EXEC PGM=*.LKED.SYSLMOD,REGION=0M                             

Finally, the GO step. It is run when both the compiler, and the binder ended with a return code lower than 8, i.e. successfully. The PGM= parameter refers back to the //SYSLMOD DD statement in the LKED step, i.e. it refers back to the temporary load library.

Note that the statements shown, and my comments apply to the unmodified version of this procedure, as distributed with the compiler. Your installation might have adjusted the procedure.