ACCEPT User Input Example


Scenario - Receiving user input from Run JCL.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       IDENTIFICATION DIVISION.
       PROGRAM-ID. ACCPTINP.
       AUTHOR. MTH.	   

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-VAR.
          05 WS-NAME          PIC X(20).

       PROCEDURE DIVISION.
      * Receiving Input from RUN JCL 
           ACCEPT WS-NAME.

           DISPLAY 'RECEIVED NAME:  ' WS-NAME.

           STOP RUN.

JCL -

//MATEPKRJ JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID
//**
//STEP01  EXEC PGM=ACCPTST
//STEPLIB  DD  DSN=MATEPK.COBOL.LOADLIB,DISP=SHR
//SYSIN    DD  *
PAWAN KUMAR Y S
/* 

Output -RECEIVED NAME: PAWAN KUMAR Y S

   

Explaining Example -

In the above example:

  • PAWAN KUMAR Y S received from JCL SYSIN DD statement and stores in WS-NAME variable for processing.