我有三个 VSAM 文件。一种用于客户、视频和租赁。在这些 VSAM 文件中,每个客户、视频和租赁都有一个 ID。以下是客户文件的示例:
300,鲍勃,315-123-1414
301,瑞恩,315-213-2617
302,史密斯,315-123-1234
303,罗伯塔,212-125-1234
视频文件和租借文件的设置方式相同。
我需要做的是编写一个 cobol 程序来读取这些 VSAM 文件,然后列出客户、视频以及客户租用的视频。我计划通过为每个客户设置一个 ID 号,然后将该 ID 号与租借的视频一起使用来做到这一点。
我到目前为止的cobol代码如下:
ID DIVISION.
PROGRAM-ID. PROG3
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-Z10.
OBJECT-COMPUTER. IBM-Z10.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CUR-FILE ASSIGN TO MYFILE1
ORGANIZATION INDEXED ACCESS IS SEQUENTIAL
RECORD KEY IS EMP-NO FILE STATUS IS F13.
DATA DIVISION.
FILE SECTION.
FD CUR-FILE
RECORD CONTAINS 80 CHARACTERS
DATA RECORD IS CUR-REC.
01 CUR-REC.
02 EMP-NO PIC X(6).
02 EMP-NAME PIC X(24).
02 EMP-ADDRESS PIC X(50).
WORKING-STORAGE SECTION.
77 F13 PIC 99 VALUE ZEROS.
PROCEDURE DIVISION.
0001-MAIN.
DISPLAY ' I M IN MAIN '.
DISPLAY ' I M IN MAIN '.
OPEN OUTPUT CUR-FILE. IF F13 = 00
DISPLAY ' I M OPENED SUCCESSFULLY ' ELSE
DISPLAY 'OPEN-ERROR ' F13 STOP RUN.
MOVE '822655' TO EMP-NO.
DISPLAY EMP-NO.
MOVE 'MUSADDIQ USMAN' TO EMP-NAME.
MOVE 'P-5/01 STEEL TOWN' TO EMP-ADDRESS.
DISPLAY CUR-REC.
WRITE CUR-REC.
IF F13 = 00 DISPLAY 'WRITE SUCCESSFUL' ELSE
DISPLAY 'WRITE ERROR ' F13 STOP RUN.
CLOSE CUR-FILE.
STOP RUN.
下面我添加了 Read 程序,我认为这将帮助您,希望对我有所帮助:
ID DIVISION.
PROGRAM-ID. RDVSAM.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-Z10.
OBJECT-COMPUTER. IBM-Z10.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CUR-FILE ASSIGN TO MYFILE1
ORGANIZATION INDEXED ACCESS IS SEQUENTIAL
RECORD KEY IS EMP-NO FILE STATUS IS F13.
DATA DIVISION.
FILE SECTION.
FD CUR-FILE
RECORD CONTAINS 80 CHARACTERS
DATA RECORD IS CUR-REC.
01 CUR-REC.
02 EMP-NO PIC 9(6).
02 EMP-NAME PIC X(24).
02 EMP-ADDRESS PIC X(50).
WORKING-STORAGE SECTION.
77 F13 PIC 99 VALUE ZEROS.
PROCEDURE DIVISION.
0001-MAIN.
OPEN INPUT CUR-FILE. IF F13 = 00
DISPLAY ' I M OPENED SUCCESSFULLY ' ELSE
DISPLAY 'OPEN-ERROR ' F13 STOP RUN.
REAd-FILE.
READ CUR-FILE AT END GO TO CLOSE-UP.
DISPLAY EMP-NO ' ' EMP-NAME ' ' EMP-ADDRESS.
GO TO READ-FILE.
CLOSE-UP.
CLOSE CUR-FILE.
STOP RUN.
我被卡住了,不知道如何列出所有信息。
谢谢