Subroutines (INLCUDE Stmt)
Subroutines (INLCUDE Stmt) Example
Scenario - Including ACCINPUT (PROCEDURE DIVISION copybook) in the COBOL Program.
Code -
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. COBINC.
AUTHOR. MTH.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-VAR.
05 WS-NAME PIC X(20).
05 WS-GENDER PIC X(01).
PROCEDURE DIVISION.
++INCLUDE ACCINPUT.
DISPLAY 'RECEIVED NAME: ' WS-NAME.
DISPLAY 'RECEIVED GENDER: ' WS-GENDER.
STOP RUN.
ACCINPUT code copybook -
1000-RECEIVE-INPUTS.
ACCEPT WS-NAME.
ACCEPT WS-GENDER.
Run JCL -
//MATEPKRJ JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID
//*
//STEP01 EXEC PGM=COBINC
//STEPLIB DD DSN=MATEPK.COBOL.LOADLIB,DISP=SHR
//SYSIN DD *
SRINIVAS
M
/*
//SYSOUT DD SYSOUT=*
Output -
RECEIVED NAME: SRINIVAS RECEIVED GENDER: M
Explaining Example -
In the above example:
- ACCINPUT is the cobol copybook which has the COBOL executable statements that are common in more than one program.
- INCLUDE statement is replaced by the statements during the compilation of the program.