TSO-ISPF JCL COBOL VSAM DB2 CICS IMS-DB Tools Articles Forum Quiz Interview Q&A

JCL - Input and Output


Any batch program executed through a JCL requires input data, which is processed and output will be created. There are different ways of passing input data to the program and writing into output. In batch mode, there is no user interaction required but input and output dataset or devices and required organisation are defined in JCL.

Data Input in a JCL

There are different methods passing input data to a program using JCL and these methods have been explained below:


INSTREAM DATA:

Instream data(also called inline data sets) to a program can be specified using a SYSIN DD statement. SYSIN statement used to start an instream data set.

Data can be accepted in the program through ACCEPT statement.

One row in the SYSIN will be equal to one ACCEPT in the program.

In-stream data sets begin with a DD * or DD DATA statement.

/* known as delimiter and by using /* we can end the instream data.Delimiter (/*) is mandatory with SYSIN. Delimiter (/*) always starts at column1 and ends at column2.

Example 1:

//JOBIBMKS  JOB (123),'IBMMAINFRAMER',CLASS=C,MSGCLASS=S,MSGLEVEL=(1,1),
//       NOTIFY=&SYSUID
//*
//STEP01 EXEC PGM=MYPROG
//IN1    DD DSN=userid.TEST.INPUT1,DISP=SHR
//OUT1   DD DSN=userid.TEST.OUTPUT1,DISP=(,CATLG,DELETE),
//       LRECL=50,RECFM=FB
//SYSIN  DD *
KALAI  1000
SRINI  2000
/*

Explanation:

In this example, input to MYPROG is passed through SYSIN. The data is provided within the JCL. Two records of data are passed to the program. Please note that /* marks the end of instream SYSIN data.

"KALAI 1000" is record1 and "SRINI 2000" is record2. End of data condition is met when the symbol /* is encountered while reading the data.


Example 2: Let us see an example to send a data in instream and display in COBOL.

JCL:

//JOBIBMKS  JOB (123),'IBMMAINFRAMER',CLASS=C,MSGCLASS=S,MSGLEVEL=(1,1),
//       NOTIFY=&SYSUID
//*
//JOBLIB   DD  DSN=userid.IBMMF.MY.LOADLIB,DISP=SHR
//*
//STEP01   EXEC PGM=MYPROGRM
//STEPLIB  DD  DSN=userid.IBMMF.LOADLIB,DISP=SHR
//SYSIN    DD  *
IBMMAINFRAMER TUTORIAL
/*
//OUTFILE  DD  DSN=userid.IBMMF.OUTPUT,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=(SYSDA,20),
//             SPACE=(CYL,(50,25)),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,BUFNO=2)
//*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT   DD SYSOUT=*

COBOL Program:

IDENTIFICATION DIVISION.
PROGRAM-ID. MYPROGRM.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.

01 INPUT-DATA   PIC X(30) VALUE SPACES.

PROCEDURE DIVISION.
0000-MAINLINE-PARA.

    ACCEPT  INPUT-DATA.

    DISPLAY 'INSTREAM DATA : ' INPUT-DATA.

    STOP RUN.

Example 3:

//JOBIBMKS  JOB (123),'IBMMAINFRAMER',CLASS=C,MSGCLASS=S,MSGLEVEL=(1,1),
//       NOTIFY=&SYSUID
//*
//STEP01 EXEC PGM=MYPROG
//OUT1   DD DSN=userid.TEST.OUTPUT2,DISP=(,CATLG,DELETE),
//       LRECL=50,RECFM=FB
//SYSIN  DD DSN=userid.SYSIN.DATA,DISP=SHR    

Explanation:

In this example, the SYSIN data is held within a dataset, where userid.SYSIN.DATA is a PS file, which can hold one or more records of data.


Data Output in a JCL

The output in a JCL can be cataloged into a dataset or passed to the SYSOUT. As mentioned in DD statements chapter, SYSOUT=* redirects the output to the same class as that mentioned in the MSGCLASS parameter of the JOB statement.

Saving Job Logs:

Specifying MSGCLASS=Y saves the job log in the JMR (Joblog Management and Retrieval). The entire JOB log can be redirected to the SPOOL and can be saved to a dataset by giving the XDC command against the job name in the SPOOL. When the XDC command is given in the SPOOL, a dataset creation screen is opened up. The job log can then be saved by giving appropriate PS or PDS definition.

Job logs can also be saved into a dataset by mentioning an already created dataset for SYSOUT and SYSPRINT. But the entire job log cannot be captured through this way (i.e., JESMSG will not be cataloged) as done in JMR or XDC.

In below example, SYSOUT is cataloged in userid.IBMMF.SYSOUT and SYSPRINT in userid.IBMMF.SYSPRINT.

//JOBIBMKS  JOB (123),'IBMMAINFRAMER',CLASS=C,MSGCLASS=Y,MSGLEVEL=(1,1),
//       NOTIFY=&SYSUID
//STEP1    EXEC PGM=MYPROG
//IN1      DD DSN=userid.IBMMF.INPUT,DISP=SHR
//OUT1     DD SYSOUT=*
//SYSOUT   DD DSN=userid.IBMMF.SYSOUT,DISP=SHR
//SYSPRINT DD DSN=userid.IBMMF.SYSPRINT,DISP=SHR
//*


If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal