IDENTIFICATION DIVISION.
00010000
PROGRAM-ID. UPDEIN. 00020000
AUTHOR. SRIBLOG.
00030000
*From PS, check and update table rows, based on condition
ENVIRONMENT DIVISION. 00040000
INPUT-OUTPUT SECTION.
00050000
FILE-CONTROL.
00060000
SELECT BI001-INPUT-PS ASSIGN TO DD1 00061000
ORGANIZATION SEQUENTIAL 00062000
ACCESS SEQUENTIAL 00063000
FILE STATUS IS WS01-FST-PS. 00064001
DATA DIVISION.
00070000
FILE SECTION. 00080000
FD
BI001-INPUT-PS.
00081000
01
BI001-INPUT-PS-REC.
00082000
02 KEY-PS PIC 9(4). 00083000
02 FILLER
PIC X. 00084000
02 COND-PS
PIC X. 00085000
02 FILLER
PIC X. 00086000
02 NAME-PS
PIC X(9). 00087000
02 FILLER
PIC X. 00088000
02 COUNTRY-PS
PIC X(5). 00089000
02 FILLER
PIC X. 00089100
02 STATE-PS
PIC X(9). 00089200
02 FILLER
PIC X . 00089300
02 SALARY-PS
PIC 9(6). 00089400
02 FILLER
PIC X(41). 00089500
WORKING-STORAGE SECTION.
00090000
01 VARIABLES.
00091000
05 WS01-FST-PS
PIC 9(2). 00092000
88 C01-PS-SUCCESS
VALUE 00. 00093001
88 C01-PS-EOF
VALUE 10. 00094001
01
WSS-ERR-MSG.
00100000
05 WS-ERR-MSG.
00110000
10 WS-ERR-LEN PIC S9(9) COMP VALUE 800.00120000
10 WS-ERR-TEXT
PIC X(80) 00130000
OCCURS 10 TIMES. 00140000
05 WS-ERR-LRECL
PIC S9(9) COMP VALUE 80. 00150000
05 WS-DB2-ERRMSG-IDX
PIC 9(2). 00160000
05 WS-ERROR-MESSAGE
PIC X(120). 00170000
05 WS-SQLCODE-CODE
PIC S9(3) 00180000
SIGN LEADING SEPARATE.00190000
01
WS-SQLCODE-ERR PIC S9(03) 00200000
SIGN LEADING SEPARATE.00210000
88 C01-IND-EM-SUCCESS VALUE +000. 00220000
88 C01-IND-EM-DUPTABLE VALUE -601. 00230000
88 C01-IND-EM-DB-NOT-FND VALUE -204. 00240000
88 C01-IND-EM-ILLEGAL-SYMBOL VALUE -104. 00250000
88 C01-IND-EM-ILLEGAL-KEYWORD
VALUE -199. 00260000
EXEC SQL
00261000
INCLUDE CRIC
00262000
END-EXEC 00263000
EXEC SQL
00270000
INCLUDE SQLCA
00280000
END-EXEC
00290000
PROCEDURE DIVISION.
00300000
0000-MAIN-PARA.
00310000
PERFORM 1000-INITIALIZATION-PARA 00320000
THRU 1000-INITIALIZATION-PARA-EXIT 00330000
PERFORM 2000-PROCESS-PARA 00340000
THRU 2000-PROCESS-PARA-EXIT 00350000
PERFORM 9000-TERMINATION-PARA 00360000
THRU 9000-TERMINATION-PARA-EXIT 00370000
.
00380000
0000-MAIN-PARA-EXIT.
00390000
EXIT
00400000
.
00410000
1000-INITIALIZATION-PARA. 00420000
INITIALIZE WS-SQLCODE-ERR 00430000
.
00440000
1000-INITIALIZATION-PARA-EXIT. 00450000
EXIT
00460000
.
00470000
2000-PROCESS-PARA. 00480000
PERFORM 2100-OPEN-PARA 00490000
THRU 2100-OPEN-PARA-EXIT 00500000
PERFORM 2200-READ-PARA
00510000
THRU 2200-READ-PARA-EXIT 00520000
UNTIL C01-PS-EOF
00521000
PERFORM 2300-CLOSE-PARA 00530000
THRU 2300-CLOSE-PARA-EXIT 00540000
.
00550000
2000-PROCESS-PARA-EXIT. 00560001
EXIT
00570000
.
00580000
2100-OPEN-PARA.
00590001
OPEN INPUT BI001-INPUT-PS 00591000
EVALUATE TRUE
00592000
WHEN C01-PS-SUCCESS 00593000
DISPLAY 'PS OPENED SUCCESSFULLY' 00594000
CONTINUE
00595000
WHEN OTHER
00596003
DISPLAY 'PS OPEN ERROR' WS01-FST-PS 00597000
PERFORM 9000-TERMINATION-PARA 00598000
THRU 9000-TERMINATION-PARA-EXIT 00599000
.
00599100
2100-OPEN-PARA-EXIT.
00600001
EXIT
00610000
.
00620000
2200-READ-PARA.
00630001
READ BI001-INPUT-PS 00631000
EVALUATE TRUE
00632000
WHEN C01-PS-SUCCESS 00633000
DISPLAY 'READ' 00633109
DISPLAY BI001-INPUT-PS-REC 00633209
EVALUATE TRUE
00634000
WHEN COND-PS='U' 00635000
DISPLAY 'UPDATE' 00635107
PERFORM
2201-UPDATE-PARA
00635206
THRU 2201-UPDATE-PARA-EXIT 00635306
WHEN COND-PS='I' 00635406
DISPLAY 'INSERT' 00635507
PERFORM
2201-INSERT-PARA
00635606
THRU 2201-INSERT-PARA-EXIT 00635706
WHEN COND-PS='D' 00635806
DISPLAY 'DELETE' 00635907
PERFORM 2201-DELETE-PARA 00636006
THRU 2201-DELETE-PARA-EXIT 00636106
END-EVALUATE
00636206
WHEN C01-PS-EOF
00636306
CONTINUE
00636406
DISPLAY 'END REACHED' 00636506
WHEN OTHER
00636606
DISPLAY 'READ ERROR'
WS01-FST-PS 00636706
PERFORM 2300-CLOSE-PARA 00636806
THRU 2300-CLOSE-PARA-EXIT 00636906
PERFORM
9000-TERMINATION-PARA
00637006
THRU 9000-TERMINATION-PARA-EXIT 00637106
END-EVALUATE
00637206
.
00637306
2200-READ-PARA-EXIT.
00637406
EXIT 00637506
.
00637606
2201-UPDATE-PARA.
00637706
MOVE KEY-PS TO HV-EMPLOY-ID 00637800
MOVE STATE-PS TO
HV-EMPLOY-STATE 00637900
EXEC SQL
00638000
UPDATE TB_CRICKET 00638100
SET EMPLOY_STATE =
:HV-EMPLOY-STATE 00639000
WHERE EMPLOY_ID = :HV-EMPLOY-ID 00639100
END-EXEC
00639200
MOVE SQLCODE TO
WS-SQLCODE-ERR.
00660002
MOVE SQLCODE TO
WS-SQLCODE-CODE.
00670002
EVALUATE TRUE 00690002
WHEN C01-IND-EM-SUCCESS 00700002
DISPLAY 'UPDATED
SUCCESSFULLY'
00710002
DISPLAY
WS-SQLCODE-CODE
00720002
WHEN
C01-IND-EM-ILLEGAL-SYMBOL
00840002
DISPLAY 'CHECK THE BRACES,COMMA,AND SPELLINGS.INVALID'00850000
DISPLAY WS-SQLCODE-CODE 00860000
WHEN C01-IND-EM-ILLEGAL-KEYWORD 00870002
DISPLAY 'CHECK SPLELLINGS OF THE KEYWORDS.ITS INVALID'00880000
DISPLAY WS-SQLCODE-CODE 00890000
WHEN OTHER
00900002
CALL 'DSNTIAR' USING
SQLCA, 00910000
WS-ERR-MSG 00920000
WS-ERR-LRECL
00930000
DISPLAY WS-ERR-MSG 00940000
END-EVALUATE
00950000
.
00950106
2201-UPDATE-PARA-EXIT.
00950206
EXIT 00950306
.
00950406
2201-INSERT-PARA.
00950506
MOVE KEY-PS TO HV-EMPLOY-ID 00952000
MOVE NAME-PS TO HV-EMPLOY-FNAME 00953000
MOVE COUNTRY-PS TO
HV-EMPLOY-COUNTRY 00954000
MOVE STATE-PS TO HV-EMPLOY-STATE 00955000
MOVE SALARY-PS TO HV-SALARY 00956000
EXEC SQL
00957000
INSERT INTO
TB_CRICKET
00958000
VALUES
00959000
(
00959100
:HV-EMPLOY-ID 00959200
,:HV-EMPLOY-FNAME 00959300
,:HV-EMPLOY-COUNTRY 00959400
,:HV-EMPLOY-STATE 00959500
,:HV-SALARY 00959600
)
00959700
END-EXEC
00959800
MOVE SQLCODE TO WS-SQLCODE-ERR. 00959900
MOVE SQLCODE TO WS-SQLCODE-CODE. 00960000
EVALUATE TRUE
00960100
WHEN C01-IND-EM-SUCCESS 00960200
DISPLAY 'INSERTED
SUCCESSFULLY'
00960300
DISPLAY
WS-SQLCODE-CODE
00960400
WHEN C01-IND-EM-ILLEGAL-SYMBOL 00960500
DISPLAY 'CHECK THE BRACES,COMMA,AND SPELLINGS.INVALID'00960600
DISPLAY WS-SQLCODE-CODE 00960700
WHEN C01-IND-EM-ILLEGAL-KEYWORD 00960800
DISPLAY 'CHECK SPLELLINGS OF THE KEYWORDS.ITS INVALID'00960900
DISPLAY WS-SQLCODE-CODE 00961000
WHEN OTHER
00961100
CALL 'DSNTIAR' USING
SQLCA, 00961200
WS-ERR-MSG
00961300
WS-ERR-LRECL 00961400
DISPLAY WS-ERR-MSG 00961500
END-EVALUATE
00961600
.
00961706
2201-INSERT-PARA-EXIT.
00961806
EXIT
00961906
.
00962006
2201-DELETE-PARA.
00962106
MOVE KEY-PS TO
HV-EMPLOY-ID
00962304
EXEC SQL
00962404
DELETE FROM 00962504
TB_CRICKET 00962604
WHERE
EMPLOY_ID=:HV-EMPLOY-ID
00962704
END-EXEC 00962804
MOVE SQLCODE TO
WS-SQLCODE-ERR.
00962904
MOVE SQLCODE TO
WS-SQLCODE-CODE.
00963004
EVALUATE TRUE 00963104
WHEN
C01-IND-EM-SUCCESS
00963204
DISPLAY 'DELETED
SUCCESSFULLY' 00963304
DISPLAY
WS-SQLCODE-CODE
00963404
WHEN
C01-IND-EM-ILLEGAL-SYMBOL
00963504
DISPLAY 'CHECK THE BRACES,COMMA,AND SPELLINGS.INVALID'00963604
DISPLAY WS-SQLCODE-CODE 00963704
WHEN C01-IND-EM-ILLEGAL-KEYWORD 00963804
DISPLAY 'CHECK SPLELLINGS OF THE KEYWORDS.ITS INVALID'00963904
DISPLAY WS-SQLCODE-CODE 00964004
WHEN OTHER
00964104
CALL 'DSNTIAR' USING
SQLCA, 00964204
WS-ERR-MSG
00964304
WS-ERR-LRECL
00964404
DISPLAY WS-ERR-MSG 00964504
END-EVALUATE
00964604
.
00964706
2201-DELETE-PARA-EXIT. 00964806
EXIT
00964906
.
00965006
2300-CLOSE-PARA.
00990000
CLOSE BI001-INPUT-PS 00991000
EVALUATE TRUE
00992000
WHEN C01-PS-SUCCESS 00993000
DISPLAY 'PS CLOSED SUCCESS' 00994000
WHEN OTHER
00995000
DISPLAY 'PS NOT CLOSED' 00996000
PERFORM
9000-TERMINATION-PARA
00997000
THRU 9000-TERMINATION-PARA-EXIT 00998000
.
00999000
2300-CLOSE-PARA-EXIT.
00999101
EXIT
00999200
.
00999300
9000-TERMINATION-PARA.
01000000
STOP RUN
01010000
.
01020000
9000-TERMINATION-PARA-EXIT. 01030000
EXIT
01040000
.
01050000
No comments:
Post a Comment