*PICK A FIELD FROM PS, MATCH WITH KSDS KEY,
*REWRITE ANOTHER FIELD OF PS IN KSDS*
IDENTIFICATION DIVISION.
PROGRAM-ID. REPLAC.
AUTHOR. SRIBLOG.
DATE-WRITTEN. NOV/28/2013.
DATE-COMPILED. NOV/28/2013.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT BI001 ASSIGN TO DD1
ORGANIZATION IS SEQUENTIAL
ACCESS IS SEQUENTIAL
FILE STATUS IS WS-BI001.
SELECT BI002 ASSIGN TO DD2
ORGANIZATION IS INDEXED
ACCESS IS SEQUENTIAL
RECORD KEY BI002-REGNO
FILE STATUS IS WS-BI002.
DATA DIVISION.
FILE SECTION.
FD BI001.
01 BI001-INPUT-REC.
02 BI001-REGNO PIC 9(4).
02 FILLER PIC X.
02 BI001-STATE PIC X(13).
02 FILLER PIC X(62).
FD BI002.
01 BI002-OUTPUT-REC.
02 BI002-REGNO PIC 9(4).
02 FILLER PIC X.
02 BI002-NAME PIC X(17).
02 FILLER PIC X(2).
02 BI002-COUNTRY PIC X(5).
02 FILLER PIC X.
02 BI002-STATE PIC X(13).
02 FILLER PIC X(2).
02 BI002-SALARY PIC 9(4).
02 FILLER PIC X(31).
WORKING-STORAGE SECTION.
01 VARIABLES.
05 WS-BI001 PIC 9(2).
88 BI001-SUCCESS VALUE 00.
88 BI001-EOF VALUE 10.
05 WS-BI002 PIC 9(2).
88 BI002-SUCCESS VALUE 00.
88 BI002-EOF VALUE 10.
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
UNTIL BI001-EOF
PERFORM 2101-CLOSE-PARA
THRU 2101-CLOSE-PARA-EXIT
PERFORM 2102-CLOSE-PARA
THRU 2102-CLOSE-PARA-EXIT
.
2000-PROCESS-PARA-EXIT.
EXIT
.
2100-OPEN-PARA.
OPEN INPUT BI001
EVALUATE TRUE
WHEN BI001-SUCCESS
CONTINUE
WHEN OTHER
DISPLAY WS-BI001
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
OPEN I-O BI002
EVALUATE TRUE
WHEN BI002-SUCCESS
CONTINUE
WHEN OTHER
DISPLAY WS-BI002
PERFORM 2101-CLOSE-PARA
THRU 2101-CLOSE-PARA-EXIT
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
.
2100-OPEN-PARA-EXIT.
EXIT
.
2101-CLOSE-PARA.
CLOSE BI001
EVALUATE TRUE
WHEN BI001-SUCCESS
DISPLAY 'CLOSED SUCCESS'
WHEN OTHER
DISPLAY WS-BI001
END-EVALUATE
.
2101-CLOSE-PARA-EXIT.
EXIT
.
2102-CLOSE-PARA.
CLOSE BI002
EVALUATE TRUE
WHEN BI002-SUCCESS
DISPLAY 'CLOSED SUCCESS'
WHEN OTHER
DISPLAY WS-BI002
END-EVALUATE
.
2102-CLOSE-PARA-EXIT.
EXIT
.
2100-READ-PARA.
READ BI001
EVALUATE TRUE
WHEN BI001-SUCCESS
PERFORM 3000-MOVE-PARA
THRU 3000-MOVE-PARA-EXIT
* WHEN BI001-EOF
* PERFORM 2101-CLOSE-PARA
* THRU 2101-CLOSE-PARA-EXIT
* PERFORM 2102-CLOSE-PARA
* THRU 2102-CLOSE-PARA-EXIT
* PERFORM 9000-TERMINATION-PARA
* THRU 9000-TERMINATION-PARA-EXIT
WHEN OTHER
* DISPLAY WS-BI001
PERFORM 2101-CLOSE-PARA
THRU 2101-CLOSE-PARA-EXIT
PERFORM 2102-CLOSE-PARA
THRU 2102-CLOSE-PARA-EXIT
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
.
2100-READ-PARA-EXIT.
EXIT
.
9000-TERMINATION-PARA.
STOP RUN
.
9000-TERMINATION-PARA-EXIT.
EXIT
.
3000-MOVE-PARA.
MOVE BI001-REGNO TO BI002-REGNO
READ BI002
DISPLAY BI002-OUTPUT-REC
MOVE BI001-STATE TO BI002-STATE
REWRITE BI002-OUTPUT-REC
DISPLAY BI002-OUTPUT-REC
.
3000-MOVE-PARA-EXIT.
EXIT
.
*REWRITE ANOTHER FIELD OF PS IN KSDS*
IDENTIFICATION DIVISION.
PROGRAM-ID. REPLAC.
AUTHOR. SRIBLOG.
DATE-WRITTEN. NOV/28/2013.
DATE-COMPILED. NOV/28/2013.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT BI001 ASSIGN TO DD1
ORGANIZATION IS SEQUENTIAL
ACCESS IS SEQUENTIAL
FILE STATUS IS WS-BI001.
SELECT BI002 ASSIGN TO DD2
ORGANIZATION IS INDEXED
ACCESS IS SEQUENTIAL
RECORD KEY BI002-REGNO
FILE STATUS IS WS-BI002.
DATA DIVISION.
FILE SECTION.
FD BI001.
01 BI001-INPUT-REC.
02 BI001-REGNO PIC 9(4).
02 FILLER PIC X.
02 BI001-STATE PIC X(13).
02 FILLER PIC X(62).
FD BI002.
01 BI002-OUTPUT-REC.
02 BI002-REGNO PIC 9(4).
02 FILLER PIC X.
02 BI002-NAME PIC X(17).
02 FILLER PIC X(2).
02 BI002-COUNTRY PIC X(5).
02 FILLER PIC X.
02 BI002-STATE PIC X(13).
02 FILLER PIC X(2).
02 BI002-SALARY PIC 9(4).
02 FILLER PIC X(31).
WORKING-STORAGE SECTION.
01 VARIABLES.
05 WS-BI001 PIC 9(2).
88 BI001-SUCCESS VALUE 00.
88 BI001-EOF VALUE 10.
05 WS-BI002 PIC 9(2).
88 BI002-SUCCESS VALUE 00.
88 BI002-EOF VALUE 10.
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
UNTIL BI001-EOF
PERFORM 2101-CLOSE-PARA
THRU 2101-CLOSE-PARA-EXIT
PERFORM 2102-CLOSE-PARA
THRU 2102-CLOSE-PARA-EXIT
.
2000-PROCESS-PARA-EXIT.
EXIT
.
2100-OPEN-PARA.
OPEN INPUT BI001
EVALUATE TRUE
WHEN BI001-SUCCESS
CONTINUE
WHEN OTHER
DISPLAY WS-BI001
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
OPEN I-O BI002
EVALUATE TRUE
WHEN BI002-SUCCESS
CONTINUE
WHEN OTHER
DISPLAY WS-BI002
PERFORM 2101-CLOSE-PARA
THRU 2101-CLOSE-PARA-EXIT
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
.
2100-OPEN-PARA-EXIT.
EXIT
.
2101-CLOSE-PARA.
CLOSE BI001
EVALUATE TRUE
WHEN BI001-SUCCESS
DISPLAY 'CLOSED SUCCESS'
WHEN OTHER
DISPLAY WS-BI001
END-EVALUATE
.
2101-CLOSE-PARA-EXIT.
EXIT
.
2102-CLOSE-PARA.
CLOSE BI002
EVALUATE TRUE
WHEN BI002-SUCCESS
DISPLAY 'CLOSED SUCCESS'
WHEN OTHER
DISPLAY WS-BI002
END-EVALUATE
.
2102-CLOSE-PARA-EXIT.
EXIT
.
2100-READ-PARA.
READ BI001
EVALUATE TRUE
WHEN BI001-SUCCESS
PERFORM 3000-MOVE-PARA
THRU 3000-MOVE-PARA-EXIT
* WHEN BI001-EOF
* PERFORM 2101-CLOSE-PARA
* THRU 2101-CLOSE-PARA-EXIT
* PERFORM 2102-CLOSE-PARA
* THRU 2102-CLOSE-PARA-EXIT
* PERFORM 9000-TERMINATION-PARA
* THRU 9000-TERMINATION-PARA-EXIT
WHEN OTHER
* DISPLAY WS-BI001
PERFORM 2101-CLOSE-PARA
THRU 2101-CLOSE-PARA-EXIT
PERFORM 2102-CLOSE-PARA
THRU 2102-CLOSE-PARA-EXIT
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
.
2100-READ-PARA-EXIT.
EXIT
.
9000-TERMINATION-PARA.
STOP RUN
.
9000-TERMINATION-PARA-EXIT.
EXIT
.
3000-MOVE-PARA.
MOVE BI001-REGNO TO BI002-REGNO
READ BI002
DISPLAY BI002-OUTPUT-REC
MOVE BI001-STATE TO BI002-STATE
REWRITE BI002-OUTPUT-REC
DISPLAY BI002-OUTPUT-REC
.
3000-MOVE-PARA-EXIT.
EXIT
.