Appendix B. Example source code 139
Modified COBOL program
In this section, we show the final program after changes to make it work well with
DFSMStvs. Changed or added lines are shown in bold face.
Example 8-2 Modified COBOL program
Identification division.
Program-id. TVSAM-final.
Author. IBM ITSO San Jose.
Date-written. April 2001.
*---------------------------------------------------------------*
* Program functions: *
* *
* Read the input parameter file to determine how often to *
* commit. Check for rerun and skip committed input records *
* if necessary. *
* *
* Use an input transaction file to update a VSAM master *
* file. The input file is read sequentially. Each input *
* record contains an action code: *
* *
* A - add a new record to the master file *
* C - change a record in the master file *
* D - delete a record in the master file *
* *
* Count the number of updates and commit according to the *
* input parameter. *
* *
*---------------------------------------------------------------*
* *
* Expected output: *
* *
* Display: "TVSAM completed normally" *
* Report: "Program TVSAM - Master file maintenance" *
* *
*---------------------------------------------------------------*
Environment division.
Input-output section.
File-control.
*---------------------------------------------------------------*
* Master file is recoverable VSAM KSDS *
*---------------------------------------------------------------*
Select MASTER-FILE
Assign to MASTER
Organization is indexed
Access mode is dynamic
140 DFSMStvs Application Migration Guide
Record key is MASTER-RECORD-KEY
File status is MASTER-FILE-STATUS MASTER-VSAM-CODE.
*---------------------------------------------------------------*
* Positioning file is recoverable VSAM RRDS *
*---------------------------------------------------------------*
Select POSITION-FILE
Assign to POSFILE
Organization is relative
Access mode is random
Relative key is POSITION-FILE-KEY
File status is POSITION-FILE-STATUS POSITION-VSAM-CODE.
*---------------------------------------------------------------*
* Input transaction file is sequential *
*---------------------------------------------------------------*
Select INPUT-TRANSACTION-FILE
Assign to SYSIN
File status is INPUT-FILE-STATUS.
*---------------------------------------------------------------*
* Input parameter file is sequential *
*---------------------------------------------------------------*
Select PARAMETER-FILE
Assign to PARM
File status is PARM-FILE-STATUS.
*---------------------------------------------------------------*
* Output to recoverable RRDS for later printing *
*---------------------------------------------------------------*
Select SYSPRINT
Assign to SYSPRINT
Organization is relative
Access mode is sequential
File status is PRINT-FILE-STATUS PRINT-VSAM-CODE.
Data division.
File section.
FD MASTER-FILE
Record contains 46 characters.
01 MASTER-RECORD.
03 MASTER-RECORD-KEY pic X(8).
03 MASTER-TIMESTAMP-ADD pic X(17).
03 MASTER-TIMESTAMP-CHANGE pic X(17).
03 MASTER-UPDATE pic 9999 comp.
FD POSITION-FILE
Record contains 16 characters.
01 POSITION-RECORD.
Appendix B. Example source code 141
03 POSITION-RECORD-KEY pic x(8).
03 MASTER-COMMIT-COUNT pic 9(8) comp.
FD INPUT-TRANSACTION-FILE
Recording mode F
Block contains 0 records
Record contains 80 characters
Label record standard.
01 INPUT-TRANSACTION.
03 INPUT-KEY pic x(8).
03 INPUT-ACTION-CODE pic x.
FD PARAMETER-FILE
Recording mode F
Block contains 0 records
Record contains 80 characters
Label record standard.
01 INPUT-PARAMETER.
03 COMMIT-PARM pic 9(8).
03 filler pic x(72).
FD SYSPRINT
Record contains 121 characters.
01 PRINT-RECORD.
03 PRINT-RECORD-DATA pic x(121).
Working-storage section.
01 MASTER-FSTATUS-AREA.
03 MASTER-FILE-STATUS pic x(2).
88 I-O-OK value zeroes.
03 MASTER-VSAM-CODE.
05 VSAM-RETURN-CODE pic 9(2) comp.
05 VSAM-FUNCTION-CODE pic 9(1) comp.
05 VSAM-FEEDBACK-CODE pic 9(3) comp.
01 POSITION-FSTATUS-AREA.
03 POSITION-FILE-STATUS pic x(2).
88 I-O-OK value zeroes.
03 POSITION-VSAM-CODE.
05 P-VSAM-RETURN-CODE pic 9(2) comp.
05 P-VSAM-FUNCTION-CODE pic 9(1) comp.
05 P-VSAM-FEEDBACK-CODE pic 9(3) comp.
01 PRINT-FSTATUS-AREA.
03 PRINT-FILE-STATUS pic x(2).
88 I-O-OK value zeroes.
03 PRINT-VSAM-CODE.
05 PR-VSAM-RETURN-CODE pic 9(2) comp.
05 PR-VSAM-FUNCTION-CODE pic 9(1) comp.
05 PR-VSAM-FEEDBACK-CODE pic 9(3) comp.
01 FILE-FLAGS.
03 INPUT-FILE-EOF pic x value space.
88 EOF-INPUT-TRANSACTION-FILE value "Y".
01 WS-DATE.

Get DFSMStvs Application Migration Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.