SYSIN Statement Example


Scenario1 - SYSIN statement with a dataset.

Code -

----+----1----+----2----+----3----+----4----+----5----+
//SYSIN  DD  DSN=input.data.set,DISP=SHR

Scenario2 - The below example shows how the SYSIN data is accepted in the program.

Run JCL -

----+----1----+----2---+---3---+---4---+---5---+
//MTHUSERJ JOB (META007),'PAWAN Y',CLASS=A,MSGCLASS=L,MSGLEVEL=(1,1),
//             TIME=1440,NOTIFY=&SYSUID 
//*
//JOBLIB   DD  DSN=MTHUSER.MY.LOADLIB,DISP=SHR
//*
//STEP01   EXEC PGM=DATECONV
//STEPLIB  DD  DSN=MTHUSER.TEST.LOADLIB,DISP=SHR
//SYSIN    DD  *
20230101
/*
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*

COBOL Program -

----+----1----+----2---+---3---+---4---+---5---+
       IDENTIFICATION DIVISION.
       PROGRAM-ID. DATECONV.
       ENVIRONMENT DIVISION.                                     
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-DT-INP       PIC 9(08).
       01 WS-DT-OP1       PIC 9(07).
       01 WS-DT-OP2       PIC 9(08).
       PROCEDURE DIVISION.
           ACCEPT  WS-DT-INP.
           COMPUTE WS-DT-OP1 = FUNCTION DAY-OF-INTEGER (FUNCTION 
                    INTEGER-OF-DATE (WS-DT-INP) - 1)
           COMPUTE WS-DT-OP2 = FUNCTION DATE-OF-INTEGER (FUNCTION  
                 INTEGER-OF-DATE (WS-DT-INP) - 1)
           DISPLAY 'DATE OUTPUT1      : ' WS-DT-OP1. 
           DISPLAY 'DATE OUTPUT2      : ' WS-DT-OP2. 
           STOP RUN.