*****************ARRAYS****************
IDENTIFICATION DIVISION.
' PROGRAM-ID. ARRA.
AUTHOR. SRIBLOG.
DATE-WRITTEN. 4/12/13.
DATE-COMPILED. 4/12/13.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PS ASSIGN TO DD1
ORGANIZATION SEQUENTIAL
ACCESS SEQUENTIAL
FILE STATUS IS WS-PS.
SELECT ESDS ASSIGN TO AS-DD2
ORGANIZATION SEQUENTIAL
ACCESS SEQUENTIAL
FILE STATUS IS WS-ESDS.
DATA DIVISION.
FILE SECTION.
FD PS.
01 PS-REC.
02 PS-REGNO PIC 9(4).
02 FILLER PIC X.
02 PS-NAME PIC X(17).
02 FILLER PIC X(2).
02 PS-COUNTRY PIC X(5).
02 FILLER PIC X.
02 PS-STATE PIC X(13).
02 FILLER PIC X(2).
02 PS-SALARY PIC 9(6).
02 FILLER PIC X(29).
FD ESDS.
01 ESDS-REC.
02 ESDS-REGNO PIC 9(4).
02 FILLER PIC X.
02 ESDS-NAME PIC X(17).
02 FILLER PIC X(2).
02 ESDS-COUNTRY PIC X(5).
02 FILLER PIC X.
02 ESDS-STATE PIC X(13).
02 FILLER PIC X(2).
02 ESDS-SALARY PIC 9(6).
02 FILLER PIC X(29).
WORKING-STORAGE SECTION.
01 VARIABLES.
05 WS-PS PIC 9(2).
88 PS-SUCCESS VALUE 00.
88 PS-EOF VALUE 10.
88 PS-KNF VALUE 23.
05 WS-ESDS PIC 9(2).
88 ESDS-SUCCESS VALUE 00.
88 ESDS-EOF VALUE 10.
88 ESDS-KNF VALUE 23.
05 ARRAY OCCURS 15 TIMES INDEXED BY IDX .
06 ARRAY-REGNO PIC 9(4).
06 ARRAY-NAME PIC X(17).
06 ARRAY-COUNTRY PIC X(5).
06 ARRAY-STATE PIC X(13).
06 ARRAY-SALARY PIC 9(6).
05 ARR PIC 9(2)
VALUE 00.
PROCEDURE DIVISION.
0000-MAIN-PARA.
PERFORM 1000-INITIALIZATION-PARA
THRU 1000-INITIALIZATION-PARA-EXIT
PERFORM 2000-OPEN-PARA
THRU 2000-OPEN-PARA-EXIT
PERFORM 2100-READ-PARA
THRU 2100-READ-PARA-EXIT
UNTIL ESDS-EOF
PERFORM 2200-SEARCH-PARA
THRU 2200-SEARCH-PARA-EXIT
UNTIL PS-EOF
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
.
0000-MAIN-PARA-EXIT.
EXIT
.
1000-INITIALIZATION-PARA.
.
1000-INITIALIZATION-PARA-EXIT.
EXIT
.
2000-OPEN-PARA.
OPEN INPUT PS
EVALUATE TRUE
WHEN PS-SUCCESS
DISPLAY 'PS OPENED'
CONTINUE
WHEN OTHER
DISPLAY 'PS OPEN ERROR' WS-PS
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
OPEN INPUT ESDS
EVALUATE TRUE
WHEN ESDS-SUCCESS
DISPLAY 'ESDS OPENED' WS-ESDS
CONTINUE
WHEN OTHER
DISPLAY 'ESDS OPEN ERROR' WS-ESDS
CLOSE PS
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
.
2000-OPEN-PARA-EXIT.
EXIT
.
2100-READ-PARA.
READ ESDS
EVALUATE TRUE
WHEN ESDS-SUCCESS
ADD 1 TO ARR
MOVE ESDS-REGNO TO ARRAY-REGNO (ARR)
MOVE ESDS-NAME TO ARRAY-NAME (ARR)
MOVE ESDS-COUNTRY TO ARRAY-COUNTRY (ARR)
MOVE ESDS-STATE TO ARRAY-STATE (ARR)
MOVE ESDS-SALARY TO ARRAY-SALARY (ARR)
WHEN ESDS-EOF
DISPLAY " MOVED ALL RECORD INTO THE ARRAY"
WHEN OTHER
DISPLAY 'ESDS READ ERROR' WS-ESDS
END-EVALUATE
.
2100-READ-PARA-EXIT.
EXIT
.
2200-SEARCH-PARA.
READ PS
EVALUATE TRUE
WHEN PS-SUCCESS
SEARCH ARRAY
AT END
DISPLAY 'RECORD NOT FOUND' PS-REGNO
WHEN PS-REGNO = ARRAY-REGNO(IDX)
DISPLAY ARRAY(IDX)
END-SEARCH
WHEN PS-EOF
CLOSE PS
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
WHEN OTHER
DISPLAY 'PS READ ERROR' WS-PS
CLOSE PS
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
.
2200-SEARCH-PARA-EXIT.
EXIT
.
9000-TERMINATION-PARA.
STOP RUN
.
9000-TERMINATION-PARA-EXIT.
EXIT
.
IDENTIFICATION DIVISION.
' PROGRAM-ID. ARRA.
AUTHOR. SRIBLOG.
DATE-WRITTEN. 4/12/13.
DATE-COMPILED. 4/12/13.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PS ASSIGN TO DD1
ORGANIZATION SEQUENTIAL
ACCESS SEQUENTIAL
FILE STATUS IS WS-PS.
SELECT ESDS ASSIGN TO AS-DD2
ORGANIZATION SEQUENTIAL
ACCESS SEQUENTIAL
FILE STATUS IS WS-ESDS.
DATA DIVISION.
FILE SECTION.
FD PS.
01 PS-REC.
02 PS-REGNO PIC 9(4).
02 FILLER PIC X.
02 PS-NAME PIC X(17).
02 FILLER PIC X(2).
02 PS-COUNTRY PIC X(5).
02 FILLER PIC X.
02 PS-STATE PIC X(13).
02 FILLER PIC X(2).
02 PS-SALARY PIC 9(6).
02 FILLER PIC X(29).
FD ESDS.
01 ESDS-REC.
02 ESDS-REGNO PIC 9(4).
02 FILLER PIC X.
02 ESDS-NAME PIC X(17).
02 FILLER PIC X(2).
02 ESDS-COUNTRY PIC X(5).
02 FILLER PIC X.
02 ESDS-STATE PIC X(13).
02 FILLER PIC X(2).
02 ESDS-SALARY PIC 9(6).
02 FILLER PIC X(29).
WORKING-STORAGE SECTION.
01 VARIABLES.
05 WS-PS PIC 9(2).
88 PS-SUCCESS VALUE 00.
88 PS-EOF VALUE 10.
88 PS-KNF VALUE 23.
05 WS-ESDS PIC 9(2).
88 ESDS-SUCCESS VALUE 00.
88 ESDS-EOF VALUE 10.
88 ESDS-KNF VALUE 23.
05 ARRAY OCCURS 15 TIMES INDEXED BY IDX .
06 ARRAY-REGNO PIC 9(4).
06 ARRAY-NAME PIC X(17).
06 ARRAY-COUNTRY PIC X(5).
06 ARRAY-STATE PIC X(13).
06 ARRAY-SALARY PIC 9(6).
05 ARR PIC 9(2)
VALUE 00.
PROCEDURE DIVISION.
0000-MAIN-PARA.
PERFORM 1000-INITIALIZATION-PARA
THRU 1000-INITIALIZATION-PARA-EXIT
PERFORM 2000-OPEN-PARA
THRU 2000-OPEN-PARA-EXIT
PERFORM 2100-READ-PARA
THRU 2100-READ-PARA-EXIT
UNTIL ESDS-EOF
PERFORM 2200-SEARCH-PARA
THRU 2200-SEARCH-PARA-EXIT
UNTIL PS-EOF
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
.
0000-MAIN-PARA-EXIT.
EXIT
.
1000-INITIALIZATION-PARA.
.
1000-INITIALIZATION-PARA-EXIT.
EXIT
.
2000-OPEN-PARA.
OPEN INPUT PS
EVALUATE TRUE
WHEN PS-SUCCESS
DISPLAY 'PS OPENED'
CONTINUE
WHEN OTHER
DISPLAY 'PS OPEN ERROR' WS-PS
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
OPEN INPUT ESDS
EVALUATE TRUE
WHEN ESDS-SUCCESS
DISPLAY 'ESDS OPENED' WS-ESDS
CONTINUE
WHEN OTHER
DISPLAY 'ESDS OPEN ERROR' WS-ESDS
CLOSE PS
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
.
2000-OPEN-PARA-EXIT.
EXIT
.
2100-READ-PARA.
READ ESDS
EVALUATE TRUE
WHEN ESDS-SUCCESS
ADD 1 TO ARR
MOVE ESDS-REGNO TO ARRAY-REGNO (ARR)
MOVE ESDS-NAME TO ARRAY-NAME (ARR)
MOVE ESDS-COUNTRY TO ARRAY-COUNTRY (ARR)
MOVE ESDS-STATE TO ARRAY-STATE (ARR)
MOVE ESDS-SALARY TO ARRAY-SALARY (ARR)
WHEN ESDS-EOF
DISPLAY " MOVED ALL RECORD INTO THE ARRAY"
WHEN OTHER
DISPLAY 'ESDS READ ERROR' WS-ESDS
END-EVALUATE
.
2100-READ-PARA-EXIT.
EXIT
.
2200-SEARCH-PARA.
READ PS
EVALUATE TRUE
WHEN PS-SUCCESS
SEARCH ARRAY
AT END
DISPLAY 'RECORD NOT FOUND' PS-REGNO
WHEN PS-REGNO = ARRAY-REGNO(IDX)
DISPLAY ARRAY(IDX)
END-SEARCH
WHEN PS-EOF
CLOSE PS
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
WHEN OTHER
DISPLAY 'PS READ ERROR' WS-PS
CLOSE PS
PERFORM 9000-TERMINATION-PARA
THRU 9000-TERMINATION-PARA-EXIT
END-EVALUATE
.
2200-SEARCH-PARA-EXIT.
EXIT
.
9000-TERMINATION-PARA.
STOP RUN
.
9000-TERMINATION-PARA-EXIT.
EXIT
.