Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 6: Procedure Division


ACCEPT verb

  • ACCEPT verb is used to fetch input data from user’s terminal or system-date related information and move it into the specified identifier
  • There is no editing or error checking done on incoming data
  • Basic syntax:-
    Format 1:-

    ACCEPT identifier.

    • Using this format one can obtain identifier’s data value from user’s terminal
    • Data entered in terminal will be left justified in identifier
    • If there is no in-stream data from JCL then Job ABENDS
    Format 2:-

    ACCEPT identifier FROM system-reserved-identifier.

    • Using this format one can obtain identifier’s data value from the system reserved data items
    • When using this format, make sure to specify correct PIC clause for identifier which can match the value it receives from system variables
    • system-reserved-identifier can be one of the following
      System-reserved-identifier Info returns
      DATE YYMMDD [PIC 9(6)]
      DATE YYYYMMDD YYYYMMDD [PIC 9(8)]
      DAY YYDDD [PIC 9(5)]
      DAY YYYYDDD YYYYDDD [PIC 9(7)]
      DAY-OF-WEEK N [PIC 9(1)] (value 1-7 for Mon-Sun)
      TIME HHMMSSTT [PIC 9(8)]
  • Examples 1:-
  • In PROCEDURE DIVISION,

    ACCPET EMP-ID

    This will prompt user to input EMP-ID, once provided it will be stored in EMP-ID
  • Examples 2:-
  • In DATA DIVISION,

    01 TODAY-DATE. 05 YY PIC 99. 05 MM PIC 99. 05 DD PIC 99.

    In PROCEDURE DIVISION,

    ACCEPT TODAY-DATE FROM DATE.

    After execution of ACCEPT statement, TODAY-DATE will have six digit current date in the form of YYMMDD where YY, MM, DD stands for the year, month and year respectively.

ACCEPT & DISPLAY Example

COBOL program:-

000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. ACPTDISP. 000300 ENVIRONMENT DIVISION. 000400 DATA DIVISION. 000500 WORKING-STORAGE SECTION. 000600 01 USER-NAME PIC X(15). 000700 01 TODAY-DATE. 000800 05 YY PIC 99. 000900 05 MM PIC 99. 001000 05 DD PIC 99. 001100 PROCEDURE DIVISION. 001200 PARA-A. 001300 ACCEPT USER-NAME. 001400 ACCEPT TODAY-DATE FROM DATE. 001500 DISPLAY 'WELCOME ' USER-NAME. 001600 DISPLAY 'TODAY, DATE(MM/DD/YY) IS: ' MM '/' DD '/' YY. 001700 STOP RUN.

Mainframe Job step:-

//STEP01 EXEC PGM=ACPTDISP //STEPLIB DD DSN=USERID.TEST.LOADLIB,DISP=SHR //SYSOUT DD SYSOUT=A //SYSIN DD * RUDRA /*

Output (SYSOUT):-

WELCOME RUDRA TODAY, DATE(MM/DD/YY) IS: 07/11/19






© copyright mainframebug.com
Privacy Policy