EJECT Statement
EJECT Statement Example
Scenario1 - Coding EJECT statement in COBOL program.
Copybook - MATEPK.COBOL.COPYLIB(EMPREC)
----+----1----+----2----+----3----+----4----+
05 EMP-NUM PIC 9(05).
05 EMP-NAME PIC X(10).
05 EMP-DESG PIC X(15).
05 EMP-SALARY PIC 9(10).
Code -
----+----1----+----2----+----3----+----4----+
01 EMP-REC.
COPY EMPREC.
EJECT.
01 WS-VAR.
05 WS-INPUT1 PIC X(10).
Explaining Example -
- The EJECT statement won't display in the program listing.
- The EJECT statement skips the current page listing, and WS-VAR starts displaying as the next page's first line of the program listing.
Scenario2 - Two EJECT statements in the COBOL program.
Copybook - MATEPK.COBOL.COPYLIB(EMPREC)
----+----1----+----2----+----3----+----4----+
05 :EMP:-NUM PIC 9(05).
05 :EMP:-NAME PIC X(10).
05 :EMP:-DESG PIC X(15).
05 :EMP:-SALARY PIC 9(10).
Code -
----+----1----+----2----+----3----+----4----+
01 EMP-INPUT-REC.
COPY EMPREC REPLACING "==:EMP:==" BY "==EMP-INPUT==".
EJECT.
01 EMP-OUTPUT-REC.
COPY EMPREC REPLACING "==:EMP:==" BY "==EMP-OUTPUT==".
EJECT.
01 WS-VAR.
05 WS-INPUT1 PIC X(10).
Explaining Example -
In the above example:
- The EJECT statement won't display in the program listing.
- The first EJECT statement skips the current page display and EMP-OUTPUT-REC, WS-VAR starts displaying as the next page's first line of the program listing.
- The second EJECT statement skips the EMP-OUTPUT-REC current page listing, and WS-VAR starts displaying as the next page's first line of the program listing.