forked from cicsdev/cics-banking-sample-application-cbsa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXFRFUN.cbl
1924 lines (1559 loc) · 64.9 KB
/
XFRFUN.cbl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
PROCESS CICS,NODYNAM,NSYMBOL(NATIONAL),TRUNC(STD)
CBL CICS('SP,EDF')
CBL SQL
******************************************************************
* *
* Copyright IBM Corp. 2023 *
* *
******************************************************************
******************************************************************
* This program gets called when someone initiates a transfer
* of funds (perhaps) over the counter or via a web application.
*
* This program takes an incoming sortcode/account number (key)
* from the account where the money is transfered from and a
* sortcode/acount number (key) combination for the account where
* the money is being transferred to. Additionally, there will
* also be an incoming amount.
*
* This program needs to be able to cope with the data in any
* format. No checking is made on overdraft limits.
*
* If the transfer can be made successfully after looking up
* the account information then the account information will be
* updated and the PROCTRAN (Processed Transaction) datastore
* will be updated to record the successful transaction.
*
* If the transaction is a success, then the available balance
* and the actual balance for the account being debited and the
* account being credited will be returned.
*
* If the update to either the ACCOUNT or PROCTRAN datastore is
* unsuccessful, then the transaction is deemed to have failed.
*
* Should there be some kind of datastore failure or other
* unpredictable failure we should report it, back out any
* updates already made and abend the transaction.
*
*****************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. XFRFUN.
AUTHOR. Jon Collett.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
*SOURCE-COMPUTER. IBM-370 WITH DEBUGGING MODE.
SOURCE-COMPUTER. IBM-370.
OBJECT-COMPUTER. IBM-370.
INPUT-OUTPUT SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
COPY SORTCODE.
* Get the ACCOUNT DB2 copybook
EXEC SQL
INCLUDE ACCDB2
END-EXEC.
* ACCOUNT Host variables for DB2
01 HOST-ACCOUNT-ROW.
03 HV-ACCOUNT-EYECATCHER PIC X(4).
03 HV-ACCOUNT-CUST-NO PIC X(10).
03 HV-ACCOUNT-KEY.
05 HV-ACCOUNT-SORTCODE PIC X(6).
05 HV-ACCOUNT-ACC-NO PIC X(8).
03 HV-ACCOUNT-ACC-TYPE PIC X(8).
03 HV-ACCOUNT-INT-RATE PIC S9(4)V99 COMP-3.
03 HV-ACCOUNT-OPENED PIC X(10).
03 HV-ACCOUNT-OVERDRAFT-LIM PIC S9(9) COMP.
03 HV-ACCOUNT-LAST-STMT PIC X(10).
03 HV-ACCOUNT-NEXT-STMT PIC X(10).
03 HV-ACCOUNT-AVAIL-BAL PIC S9(10)V99 COMP-3.
03 HV-ACCOUNT-ACTUAL-BAL PIC S9(10)V99 COMP-3.
* PROCTRAN DB2 copybook
EXEC SQL
INCLUDE PROCDB2
END-EXEC.
* PROCTRAN host variables for DB2
01 HOST-PROCTRAN-ROW.
03 HV-PROCTRAN-EYECATCHER PIC X(4).
03 HV-PROCTRAN-SORT-CODE PIC X(6).
03 HV-PROCTRAN-ACC-NUMBER PIC X(8).
03 HV-PROCTRAN-DATE PIC X(10).
03 HV-PROCTRAN-TIME PIC X(6).
03 HV-PROCTRAN-REF PIC X(12).
03 HV-PROCTRAN-TYPE PIC X(3).
03 HV-PROCTRAN-DESC PIC X(40).
03 HV-PROCTRAN-AMOUNT PIC S9(10)V99 COMP-3.
* Pull in the SQL COMMAREA
EXEC SQL
INCLUDE SQLCA
END-EXEC.
01 WS-CICS-WORK-AREA.
05 WS-CICS-RESP PIC S9(8) COMP.
05 WS-CICS-RESP2 PIC S9(8) COMP.
LOCAL-STORAGE SECTION.
01 SYSIDERR-RETRY PIC 999.
01 FILE-RETRY PIC 999.
01 WS-EXIT-RETRY-LOOP PIC X VALUE ' '.
01 DB2-DEADLOCK-RETRY PIC 999.
01 DB2-DATE-REFORMAT.
03 DB2-DATE-REF-YR PIC 9(4).
03 FILLER PIC X.
03 DB2-DATE-REF-MNTH PIC 99.
03 FILLER PIC X.
03 DB2-DATE-REF-DAY PIC 99.
*
* Pull in the input and output data structures
*
01 WS-ACC-DATA.
COPY ACCOUNT.
01 WS-ACC-DATA2.
COPY ACCOUNT REPLACING "ACCOUNT" BY "ACCOUNT2".
01 WS-EIBTASKN12 PIC 9(12) VALUE 0.
01 WS-SQLCODE-DISP PIC 9(9) VALUE 0.
*
* Pull in the input and output data structures
*
01 DESIRED-ACC-KEY.
03 DESIRED-SORT-CODE PIC 9(6).
03 DESIRED-ACC-NO PIC 9(8).
* 01 DESIRED-ACC-KEY2.
* 03 DESIRED-SORT-CODE2 PIC 9(6).
* 03 DESIRED-ACC-NO2 PIC 9(8).
01 NEW-ACCOUNT-AVAILABLE-BALANCE PIC S9(10)V99 VALUE 0.
01 NEW-ACCOUNT-ACTUAL-BALANCE PIC S9(10)V99 VALUE 0.
01 WS-ACC-REC-LEN PIC S9(4) COMP
VALUE 0.
01 NEW-ACCOUNT-AVAILABLE-BALANCE2
PIC S9(10)V99 VALUE 0.
01 NEW-ACCOUNT-ACTUAL-BALANCE2 PIC S9(10)V99 VALUE 0.
01 WS-ACC-REC-LEN2 PIC S9(4) COMP
VALUE 0.
01 WS-U-TIME PIC S9(15) COMP-3.
01 WS-ORIG-DATE PIC X(10).
01 WS-ORIG-DATE-GRP REDEFINES WS-ORIG-DATE.
03 WS-ORIG-DATE-DD PIC 99.
03 FILLER PIC X.
03 WS-ORIG-DATE-MM PIC 99.
03 FILLER PIC X.
03 WS-ORIG-DATE-YYYY PIC 9999.
01 WS-ORIG-DATE-GRP-X.
03 WS-ORIG-DATE-DD-X PIC XX.
03 FILLER PIC X VALUE '.'.
03 WS-ORIG-DATE-MM-X PIC XX.
03 FILLER PIC X VALUE '.'.
03 WS-ORIG-DATE-YYYY-X PIC X(4).
01 REJ-REASON PIC XX VALUE SPACES.
01 PROCTRAN-AREA.
COPY PROCTRAN.
01 REJTRAN-RIDFLD PIC S9(8) COMP.
01 PROCTRAN-RIDFLD PIC S9(8) COMP.
01 WS-REJ-REAS.
03 WS-REASON-TEXT PIC X(26) VALUE SPACES.
03 WS-TO-ACC PIC 9(14) DISPLAY
VALUE 0.
* 01 WS-REJ-COMBINED.
* 03 WS-REJ-COMBINED-SORT PIC X(6).
* 03 WS-REJ-COMBINED-ACC PIC X(8).
*
* 01 WS-PROC-COMBINED.
* 03 WS-PROC-COMBINED-SORT PIC X(6).
* 03 WS-PROC-COMBINED-ACC PIC X(8).
01 WS-PROC-REAS.
03 WS-PROC-TEXT PIC X(26) VALUE SPACES.
03 WS-PROC-TO PIC 9(14) DISPLAY
VALUE 0.
01 WS-TESTING-DB-NAME.
03 WS-TESTING-TYPE PIC X(9) VALUE 'STTESTER.'.
03 WS-TESTING-TABLE-NAME PIC X(4) VALUE 'PLOP'.
01 WS-SQLCODE1 PIC 9(15).
EXEC SQL INCLUDE SQLDA END-EXEC.
01 STMTBUF.
49 STMTLEN PIC S9(4) COMP
VALUE +78.
49 STMTTXT PIC X(78).
01 STMTBUF2.
49 STMTLEN2 PIC S9(4) COMP
VALUE +81.
49 STMTTXT2 PIC X(81).
01 DISP-LOT.
03 DISP-SIGN PIC X.
03 DISP-SQLCD PIC 9999.
01 WS-WANTED.
03 VAR-LEN PIC S9(4) COMP
VALUE +78.
03 VAR-TXT PIC X(78).
01 WS-WANTED2.
03 VAR-LEN2 PIC S9(4) COMP
VALUE +81.
03 VAR-TXT2 PIC X(81).
01 WS-INPUT-TAB-NAME PIC X(4).
01 WS-INPUT-TAB-NAME2 PIC X(7).
01 WS-PASSED-DATA.
02 WS-TEST-KEY PIC X(4).
02 WS-SORT-CODE PIC 9(6).
02 WS-CUSTOMER-RANGE.
07 WS-CUSTOMER-RANGE-TOP PIC X.
07 WS-CUSTOMER-RANGE-MIDDLE
PIC X.
07 WS-CUSTOMER-RANGE-BOTTOM
PIC X.
01 MY-ABEND-CODE PIC XXXX.
01 WS-STORM-DRAIN PIC X VALUE 'N'.
01 STORM-DRAIN-CONDITION PIC X(20).
01 SQLCODE-DISPLAY PIC S9(8) DISPLAY
SIGN LEADING SEPARATE.
01 NUMERIC-AMOUNT-DISPLAY PIC +9(10).99.
01 WS-TIME-DATA.
03 WS-TIME-NOW PIC 9(6).
03 WS-TIME-NOW-GRP REDEFINES WS-TIME-NOW.
05 WS-TIME-NOW-GRP-HH PIC 99.
05 WS-TIME-NOW-GRP-MM PIC 99.
05 WS-TIME-NOW-GRP-SS PIC 99.
01 WS-ABEND-PGM PIC X(8) VALUE 'ABNDPROC'.
01 ABNDINFO-REC.
COPY ABNDINFO.
LINKAGE SECTION.
01 DFHCOMMAREA.
COPY XFRFUN.
PROCEDURE DIVISION USING DFHCOMMAREA.
PREMIERE SECTION.
A010.
EXEC CICS HANDLE ABEND
LABEL(ABEND-HANDLING)
END-EXEC.
MOVE '0' TO HV-ACCOUNT-EYECATCHER.
MOVE '0' TO HV-ACCOUNT-SORTCODE.
MOVE '0' TO HV-ACCOUNT-ACC-NO.
MOVE 0 TO DB2-DEADLOCK-RETRY.
MOVE SORTCODE TO COMM-FSCODE COMM-TSCODE.
MOVE SORTCODE TO DESIRED-SORT-CODE.
*
* If the amount being transferred is negative, then
* flag this as a failure and finish.
*
IF COMM-AMT <= ZERO
MOVE 'N' TO COMM-SUCCESS
MOVE '4' TO COMM-FAIL-CODE
PERFORM GET-ME-OUT-OF-HERE
END-IF.
*
PERFORM UPDATE-ACCOUNT-DB2
*
* The COMMAREA values have now been set so all we need to do
* is finish
*
PERFORM GET-ME-OUT-OF-HERE.
A999.
EXIT.
UPDATE-ACCOUNT-DB2 SECTION.
UAD010.
MOVE 'N' TO COMM-SUCCESS.
*
* Are we trying to transfer from and to the same account?
* We don't allow that.
*
IF COMM-FACCNO = COMM-TACCNO
AND COMM-FSCODE = COMM-TSCODE
*
* Preserve the RESP and RESP2, then set up the
* standard ABEND info before getting the applid,
* date/time etc. and linking to the Abend Handler
* program.
*
INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE
*
* Get supplemental information
*
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC
MOVE EIBTASKN TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID
PERFORM POPULATE-TIME-DATE
MOVE WS-ORIG-DATE TO ABND-DATE
STRING WS-TIME-NOW-GRP-HH DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE
INTO ABND-TIME
END-STRING
MOVE WS-U-TIME TO ABND-UTIME-KEY
MOVE 'SAME' TO ABND-CODE
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
MOVE ZEROS TO ABND-SQLCODE
STRING 'UAD010 - Cannot transfer to the same account '
DELIMITED BY SIZE,
' EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,
' RESP2=' DELIMITED BY SIZE,
ABND-RESP2CODE DELIMITED BY SIZE
INTO ABND-FREEFORM
END-STRING
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
DISPLAY 'Cannot transfer to the same account'
EXEC CICS ABEND
ABCODE('SAME')
NODUMP
CANCEL
END-EXEC
END-IF.
IF COMM-FACCNO < COMM-TACCNO
*
* If the FROM account number is less than the TO
* account number
*
MOVE COMM-FACCNO TO DESIRED-ACC-NO
MOVE COMM-FSCODE TO DESIRED-SORT-CODE
*
* Update the FROM account
*
PERFORM UPDATE-ACCOUNT-DB2-FROM
*
* If the update was successful, update the TO account
*
IF COMM-SUCCESS = 'Y'
MOVE COMM-TACCNO TO DESIRED-ACC-NO
MOVE COMM-TSCODE TO DESIRED-SORT-CODE
PERFORM UPDATE-ACCOUNT-DB2-TO
*
* If the update to the TO account was unsuccessful then
* we need to flag it and roll it back
*
IF COMM-SUCCESS = 'N'
IF COMM-FAIL-CODE = '2'
EXEC CICS SYNCPOINT
ROLLBACK
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC
IF WS-CICS-RESP IS NOT EQUAL TO DFHRESP(NORMAL)
*
* Preserve the RESP and RESP2, then set up the
* standard ABEND info before getting the applid,
* date/time etc. and linking to the Abend
* Handler program.
*
INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE
*
* Get supplemental information
*
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC
MOVE EIBTASKN TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID
PERFORM POPULATE-TIME-DATE
MOVE WS-ORIG-DATE TO ABND-DATE
STRING WS-TIME-NOW-GRP-HH DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE
INTO ABND-TIME
END-STRING
MOVE WS-U-TIME TO ABND-UTIME-KEY
MOVE 'HROL' TO ABND-CODE
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
MOVE ZEROS TO ABND-SQLCODE
STRING 'UAD010(2) - Error on SYNCPOINT'
DELIMITED BY SIZE,
' ROLLBACK' DELIMITED BY SIZE,
' after UPDATING TO account '
DELIMITED BY SIZE,
' EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,
' RESP2=' DELIMITED BY SIZE,
ABND-RESP2CODE DELIMITED BY SIZE
INTO ABND-FREEFORM
END-STRING
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
DISPLAY 'XFRFUN error syncpoint rollback'
' after updating TO account '
',RESP=' WS-CICS-RESP
',RESP2=' WS-CICS-RESP2
EXEC CICS ABEND
ABCODE('HROL')
NODUMP
CANCEL
END-EXEC
END-IF
GO TO UAD999
ELSE
*
* If the COMM-FLAG is anything else other than
* 2 then abend.
*
DISPLAY 'Error updating TO account'
EXEC CICS ABEND
ABCODE('TO ')
NODUMP
END-EXEC
END-IF
END-IF
ELSE
*
* If the update to the FROM account was not successful
* rollback.
*
IF COMM-FAIL-CODE = '1'
EXEC CICS SYNCPOINT
ROLLBACK
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC
*
* If the ROLLback failed
*
IF WS-CICS-RESP IS NOT EQUAL TO DFHRESP(NORMAL)
DISPLAY 'XFRFUN error syncpoint '
' rollback after '
'updating FROM account '
',RESP=' WS-CICS-RESP
',RESP2=' WS-CICS-RESP2
EXEC CICS ABEND
ABCODE('HROL')
NODUMP
END-EXEC
END-IF
GO TO UAD999
ELSE
*
* Preserve the RESP and RESP2, then set up the
* standard ABEND info before getting the applid,
* date/time etc. and linking to the Abend Handler
* program.
*
INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE
*
* Get supplemental information
*
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC
MOVE EIBTASKN TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID
PERFORM POPULATE-TIME-DATE
MOVE WS-ORIG-DATE TO ABND-DATE
STRING WS-TIME-NOW-GRP-HH DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE
INTO ABND-TIME
END-STRING
MOVE WS-U-TIME TO ABND-UTIME-KEY
MOVE 'FROM' TO ABND-CODE
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
MOVE ZEROS TO ABND-SQLCODE
STRING 'UAD010(3) - Error updating FROM account '
DELIMITED BY SIZE,
' EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,
' RESP2=' DELIMITED BY SIZE,
ABND-RESP2CODE DELIMITED BY SIZE
INTO ABND-FREEFORM
END-STRING
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
DISPLAY 'Error updating FROM account'
EXEC CICS ABEND
ABCODE('FROM')
NODUMP
CANCEL
END-EXEC
END-IF
END-IF
ELSE
*
* The FROM account number is greater than the TO
* account number
*
MOVE COMM-TACCNO TO DESIRED-ACC-NO
MOVE COMM-TSCODE TO DESIRED-SORT-CODE
*
* Update the TO account number
*
PERFORM UPDATE-ACCOUNT-DB2-TO
*
* If the update to the TO account was successful
* then update the FROM account
*
IF COMM-SUCCESS = 'Y'
MOVE COMM-FACCNO TO DESIRED-ACC-NO
MOVE COMM-FSCODE TO DESIRED-SORT-CODE
PERFORM UPDATE-ACCOUNT-DB2-FROM
*
* Did the update to the FROM account work?
*
IF COMM-SUCCESS = 'N'
IF COMM-FAIL-CODE NOT = '1'
*
* Preserve the RESP and RESP2, then set up the
* standard ABEND info before getting the applid,
* date/time etc. and linking to the Abend Handler
* program.
*
INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE
*
* Get supplemental information
*
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC
MOVE EIBTASKN TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID
PERFORM POPULATE-TIME-DATE
MOVE WS-ORIG-DATE TO ABND-DATE
STRING WS-TIME-NOW-GRP-HH DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE
INTO ABND-TIME
END-STRING
MOVE WS-U-TIME TO ABND-UTIME-KEY
MOVE 'FROM' TO ABND-CODE
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
MOVE ZEROS TO ABND-SQLCODE
STRING 'UAD010(4) - Error updating FROM account '
DELIMITED BY SIZE,
' EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,
' RESP2=' DELIMITED BY SIZE,
ABND-RESP2CODE DELIMITED BY SIZE
INTO ABND-FREEFORM
END-STRING
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
DISPLAY 'Error updating FROM account'
EXEC CICS ABEND
ABCODE('FROM')
NODUMP
CANCEL
END-EXEC
ELSE
*
* If the FAIL code is something else
*
EXEC CICS SYNCPOINT
ROLLBACK
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC
*
* If that rollback didn't work
*
IF WS-CICS-RESP IS NOT EQUAL TO DFHRESP(NORMAL)
*
* Preserve the RESP and RESP2, then set up the
* standard ABEND info before getting the
* applid, date/time etc. and linking to the
* Abend Handler program.
*
INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE
*
* Get supplemental information
*
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC
MOVE EIBTASKN TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID
PERFORM POPULATE-TIME-DATE
MOVE WS-ORIG-DATE TO ABND-DATE
STRING WS-TIME-NOW-GRP-HH DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE
INTO ABND-TIME
END-STRING
MOVE WS-U-TIME TO ABND-UTIME-KEY
MOVE 'HROL' TO ABND-CODE
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
MOVE ZEROS TO ABND-SQLCODE
STRING 'UAD010(5) - Error on SYNCPOINT '
DELIMITED BY SIZE,
' ROLLBACK ' DELIMITED BY SIZE,
' after UPDATING the FROM account'
DELIMITED BY SIZE,
' EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,
' RESP2=' DELIMITED BY SIZE,
ABND-RESP2CODE DELIMITED BY SIZE
INTO ABND-FREEFORM
END-STRING
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
DISPLAY 'XFRFUN error syncpoint '
' rollback after '
'updating FROM account '
',RESP=' WS-CICS-RESP
',RESP2=' WS-CICS-RESP2
EXEC CICS ABEND
ABCODE('HROL')
NODUMP
CANCEL
END-EXEC
END-IF
GO TO UAD999
END-IF
END-IF
ELSE
*
* If the update to the TO account was NOT successful
* & the fail code isn't = '2'
*
IF COMM-FAIL-CODE NOT = '2'
*
* Preserve the RESP and RESP2, then set up the
* standard ABEND info before getting the applid,
* date/time etc. and linking to the Abend Handler
* program.
*
INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE
*
* Get supplemental information
*
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC
MOVE EIBTASKN TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID
PERFORM POPULATE-TIME-DATE
MOVE WS-ORIG-DATE TO ABND-DATE
STRING WS-TIME-NOW-GRP-HH DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE
INTO ABND-TIME
END-STRING
MOVE WS-U-TIME TO ABND-UTIME-KEY
MOVE 'TO ' TO ABND-CODE
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
MOVE ZEROS TO ABND-SQLCODE
STRING 'UAD010(6) - Error updating TO account '
DELIMITED BY SIZE,
' EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,
' RESP2=' DELIMITED BY SIZE,
ABND-RESP2CODE DELIMITED BY SIZE
INTO ABND-FREEFORM
END-STRING
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
DISPLAY 'Error updating TO account'
EXEC CICS ABEND
ABCODE('TO ')
CANCEL
NODUMP
END-EXEC
ELSE
EXEC CICS SYNCPOINT
ROLLBACK
RESP(WS-CICS-RESP)
RESP2(WS-CICS-RESP2)
END-EXEC
IF WS-CICS-RESP IS NOT EQUAL TO DFHRESP(NORMAL)
*
* Preserve the RESP and RESP2, then set up the
* standard ABEND info before getting the applid,
* date/time etc. and linking to the Abend Handler
* program.
*
INITIALIZE ABNDINFO-REC
MOVE EIBRESP TO ABND-RESPCODE
MOVE EIBRESP2 TO ABND-RESP2CODE
*
* Get supplemental information
*
EXEC CICS ASSIGN APPLID(ABND-APPLID)
END-EXEC
MOVE EIBTASKN TO ABND-TASKNO-KEY
MOVE EIBTRNID TO ABND-TRANID
PERFORM POPULATE-TIME-DATE
MOVE WS-ORIG-DATE TO ABND-DATE
STRING WS-TIME-NOW-GRP-HH DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE,
':' DELIMITED BY SIZE,
WS-TIME-NOW-GRP-MM DELIMITED BY SIZE
INTO ABND-TIME
END-STRING
MOVE WS-U-TIME TO ABND-UTIME-KEY
MOVE 'HROL' TO ABND-CODE
EXEC CICS ASSIGN PROGRAM(ABND-PROGRAM)
END-EXEC
MOVE ZEROS TO ABND-SQLCODE
STRING 'UAD010(7) - Error on SYNCPOINT ROLLBACK'
DELIMITED BY SIZE,
' after UPDATING the TO account'
DELIMITED BY SIZE,
' EIBRESP=' DELIMITED BY SIZE,
ABND-RESPCODE DELIMITED BY SIZE,
' RESP2=' DELIMITED BY SIZE,
ABND-RESP2CODE DELIMITED BY SIZE
INTO ABND-FREEFORM
END-STRING
EXEC CICS LINK PROGRAM(WS-ABEND-PGM)
COMMAREA(ABNDINFO-REC)
END-EXEC
DISPLAY 'XFRFUN error syncpoint rollback after '
'updating TO account '
',RESP=' WS-CICS-RESP
',RESP2=' WS-CICS-RESP2
EXEC CICS ABEND
ABCODE('HROL')
NODUMP
CANCEL
END-EXEC
END-IF
GO TO UAD999
END-IF
END-IF
END-IF.
*
* If the updates to the TO and FROM accounts were successful
* then we need to write to PROCTRAN (processed transaction)
* to record the successful transfer.
*
PERFORM WRITE-TO-PROCTRAN.
MOVE 'Y' TO COMM-SUCCESS.
UAD999.
EXIT.
UPDATE-ACCOUNT-DB2-FROM SECTION.
UADF010.
*
* Position ourself at the matching FROM account record
*
MOVE COMM-FACCNO TO DESIRED-ACC-NO.
MOVE COMM-FSCODE TO DESIRED-SORT-CODE.
MOVE DESIRED-SORT-CODE TO HV-ACCOUNT-SORTCODE.
MOVE DESIRED-ACC-NO TO HV-ACCOUNT-ACC-NO.
EXEC SQL
SELECT ACCOUNT_EYECATCHER,
ACCOUNT_CUSTOMER_NUMBER,
ACCOUNT_SORTCODE,
ACCOUNT_NUMBER,
ACCOUNT_TYPE,
ACCOUNT_INTEREST_RATE,
ACCOUNT_OPENED,
ACCOUNT_OVERDRAFT_LIMIT,
ACCOUNT_LAST_STATEMENT,
ACCOUNT_NEXT_STATEMENT,
ACCOUNT_AVAILABLE_BALANCE,
ACCOUNT_ACTUAL_BALANCE
INTO :HV-ACCOUNT-EYECATCHER,
:HV-ACCOUNT-CUST-NO,
:HV-ACCOUNT-SORTCODE,
:HV-ACCOUNT-ACC-NO,
:HV-ACCOUNT-ACC-TYPE,
:HV-ACCOUNT-INT-RATE,
:HV-ACCOUNT-OPENED,
:HV-ACCOUNT-OVERDRAFT-LIM,
:HV-ACCOUNT-LAST-STMT,
:HV-ACCOUNT-NEXT-STMT,
:HV-ACCOUNT-AVAIL-BAL,
:HV-ACCOUNT-ACTUAL-BAL
FROM ACCOUNT
WHERE (ACCOUNT_SORTCODE = :HV-ACCOUNT-SORTCODE AND
ACCOUNT_NUMBER = :HV-ACCOUNT-ACC-NO)
END-EXEC.
*
* Check that select was successful. If it wasn't then set the
* COMMAREA return flags accordingly.
*
IF SQLCODE NOT = 0
MOVE 'N' TO COMM-SUCCESS
IF SQLCODE = +100
MOVE '1' TO COMM-FAIL-CODE
ELSE
MOVE '3' TO COMM-FAIL-CODE
END-IF
*
* Check if SQLCODE indicates that Storm Drain processing
* is applicable in a workload if activated
*
PERFORM CHECK-FOR-STORM-DRAIN-DB2
GO TO UADF999
END-IF.
*
* If the SQLCODE is OK then update the row on ACCOUNT for
* the FROM account.
*
COMPUTE HV-ACCOUNT-AVAIL-BAL =
HV-ACCOUNT-AVAIL-BAL - COMM-AMT.
COMPUTE HV-ACCOUNT-ACTUAL-BAL =
HV-ACCOUNT-ACTUAL-BAL - COMM-AMT.
EXEC SQL
UPDATE ACCOUNT
SET ACCOUNT_EYECATCHER = :HV-ACCOUNT-EYECATCHER,
ACCOUNT_CUSTOMER_NUMBER = :HV-ACCOUNT-CUST-NO,
ACCOUNT_SORTCODE = :HV-ACCOUNT-SORTCODE,
ACCOUNT_NUMBER = :HV-ACCOUNT-ACC-NO,
ACCOUNT_TYPE = :HV-ACCOUNT-ACC-TYPE,
ACCOUNT_INTEREST_RATE = :HV-ACCOUNT-INT-RATE,
ACCOUNT_OPENED = :HV-ACCOUNT-OPENED,