*DYNAMIC KSDS READ AND DISPLAY IN SPOOL*
IDENTIFICATION DIVISION.
PROGRAM-ID. DYNAMI.
AUTHOR. SRIBLOG.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT KSDS ASSIGN TO DD1
ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
FILE STATUS IS WS-KSDS
RECORD KEY KSDS-REG.
DATA DIVISION.
FILE SECTION.
FD KSDS.
01 KSDS-REC.
05 KSDS-REG PIC 9(4).
05 FILLER PIC X.
05 KSDS-NAME PIC X(17).
05 FILLER PIC X(2).
05 KSDS-COUNTRY PIC X(5).
05 FILLER PIC X.
05 KSDS-STATE PIC X(13).
05 FILLER PIC X(2).
05 KSDS-SALARY PIC 9(4).
05 FILLER PIC X(31).
WORKING-STORAGE SECTION.
01 VARIABLES.
05 WS-KSDS PIC 9(2).
88 SUCCESS-KSDS VALUE 00.
88 EOF-KSDS VALUE 10.
88 KNF-KSDS VALUE 23.
05 STARTING PIC 9(4) VALUE 1001.
05 ENDKO PIC 9(4) VALUE 1003.
PROCEDURE DIVISION.
0000-MAIN-PARA.
PERFORM 1000-INITIALIZATION-PARA
THRU 1000-INITIALIZATION-PARA-EXIT
PERFORM 2000-PROCESS-PARA
THRU 2000-PROCESS-PARA-EXIT
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
.
0000-MAIN-PARA-EXIT.
EXIT
.
1000-INITIALIZATION-PARA.
.
1000-INITIALIZATION-PARA-EXIT.
EXIT
.
2000-PROCESS-PARA.
PERFORM 2100-OPEN-PARA
THRU 2100-OPEN-PARA-EXIT
PERFORM 2100-READ-PARA
THRU 2100-READ-PARA-EXIT
PERFORM 2100-CLOSE-PARA
THRU 2100-CLOSE-PARA-EXIT
.
2000-PROCESS-PARA-EXIT.
EXIT
.
2100-OPEN-PARA.
OPEN INPUT KSDS
EVALUATE TRUE
WHEN SUCCESS-KSDS
CONTINUE
WHEN OTHER
DISPLAY 'OPEN ERROR' WS-KSDS
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
.
2100-OPEN-PARA-EXIT.
EXIT
.
2100-READ-PARA.
MOVE STARTING TO KSDS-REG
START KSDS
EVALUATE TRUE
WHEN SUCCESS-KSDS
PERFORM 2200-WRITE-PARA
THRU 2200-WRITE-PARA-EXIT
UNTIL KSDS-REG=ENDKO
WHEN KNF-KSDS
DISPLAY 'KNF'
WHEN OTHER
DISPLAY 'WRITE ERROR' WS-KSDS
END-EVALUATE
.
2100-READ-PARA-EXIT.
EXIT
.
2100-CLOSE-PARA.
CLOSE KSDS
.
2100-CLOSE-PARA-EXIT.
EXIT
.
9000-TERMINATION-PARA.
STOP RUN
.
9000-TERMINATION-PARA-EXIT.
EXIT
.
2200-WRITE-PARA.
READ KSDS NEXT RECORD
DISPLAY KSDS-REC
.
2200-WRITE-PARA-EXIT.
EXIT
.
IDENTIFICATION DIVISION.
PROGRAM-ID. DYNAMI.
AUTHOR. SRIBLOG.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT KSDS ASSIGN TO DD1
ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
FILE STATUS IS WS-KSDS
RECORD KEY KSDS-REG.
DATA DIVISION.
FILE SECTION.
FD KSDS.
01 KSDS-REC.
05 KSDS-REG PIC 9(4).
05 FILLER PIC X.
05 KSDS-NAME PIC X(17).
05 FILLER PIC X(2).
05 KSDS-COUNTRY PIC X(5).
05 FILLER PIC X.
05 KSDS-STATE PIC X(13).
05 FILLER PIC X(2).
05 KSDS-SALARY PIC 9(4).
05 FILLER PIC X(31).
WORKING-STORAGE SECTION.
01 VARIABLES.
05 WS-KSDS PIC 9(2).
88 SUCCESS-KSDS VALUE 00.
88 EOF-KSDS VALUE 10.
88 KNF-KSDS VALUE 23.
05 STARTING PIC 9(4) VALUE 1001.
05 ENDKO PIC 9(4) VALUE 1003.
PROCEDURE DIVISION.
0000-MAIN-PARA.
PERFORM 1000-INITIALIZATION-PARA
THRU 1000-INITIALIZATION-PARA-EXIT
PERFORM 2000-PROCESS-PARA
THRU 2000-PROCESS-PARA-EXIT
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
.
0000-MAIN-PARA-EXIT.
EXIT
.
1000-INITIALIZATION-PARA.
.
1000-INITIALIZATION-PARA-EXIT.
EXIT
.
2000-PROCESS-PARA.
PERFORM 2100-OPEN-PARA
THRU 2100-OPEN-PARA-EXIT
PERFORM 2100-READ-PARA
THRU 2100-READ-PARA-EXIT
PERFORM 2100-CLOSE-PARA
THRU 2100-CLOSE-PARA-EXIT
.
2000-PROCESS-PARA-EXIT.
EXIT
.
2100-OPEN-PARA.
OPEN INPUT KSDS
EVALUATE TRUE
WHEN SUCCESS-KSDS
CONTINUE
WHEN OTHER
DISPLAY 'OPEN ERROR' WS-KSDS
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
.
2100-OPEN-PARA-EXIT.
EXIT
.
2100-READ-PARA.
MOVE STARTING TO KSDS-REG
START KSDS
EVALUATE TRUE
WHEN SUCCESS-KSDS
PERFORM 2200-WRITE-PARA
THRU 2200-WRITE-PARA-EXIT
UNTIL KSDS-REG=ENDKO
WHEN KNF-KSDS
DISPLAY 'KNF'
WHEN OTHER
DISPLAY 'WRITE ERROR' WS-KSDS
END-EVALUATE
.
2100-READ-PARA-EXIT.
EXIT
.
2100-CLOSE-PARA.
CLOSE KSDS
.
2100-CLOSE-PARA-EXIT.
EXIT
.
9000-TERMINATION-PARA.
STOP RUN
.
9000-TERMINATION-PARA-EXIT.
EXIT
.
2200-WRITE-PARA.
READ KSDS NEXT RECORD
DISPLAY KSDS-REC
.
2200-WRITE-PARA-EXIT.
EXIT
.