是否需要查看我的read语句是否可以完成3种类型的输出? [英] Need to see if I can use my read statements to accomplish 3 types of output?
问题描述
我被要求编写程序来处理 2个输入文件(客户和员工),匹配两个文件的键并生成以下 3个输出文件:
I have been asked to write program to process 2 input files (customer and employee), matching the keys of both files and producing the following 3 output files:
- 文件1:两个文件上的记录
- 文件-2:客户文件上的记录,但雇员文件上的记录
- 文件3: employee 文件而不是 customer 文件
- File-1: records that are on both files
- File-2: records that are on the customer file but not the employee file
- File-3: records that are on the employee file but not the customer file
我的循环已设置为将 customer 文件中的每条记录与 customer 文件中的一条记录进行比较,然后从 customer 文件中获取另一个密钥对值,并开始该过程
My loop is set so that it checks one record in customer file against every record in the employee file and then gets another key-pair value from the customer file and starts the process over.
当前:
- 匹配记录-必须在File1和File2中(有效)
- File1中但不在File2中的记录(不起作用)
- Re在File2中但不在File1中的软线(不起作用)
问题:有没有办法使用与我目前相同的阅读段落来一次完成所有任务,而不必为每种文件比较类型重新运行JCL
Questions: Is there a way to use the same read paragraphs as I have currently to accomplish all of my tasks at one time, without having to rerun the JCL for each file compare type
代码我发布的作品仅适用于匹配的案例
代码:(记录版式-全部可行)
Code: (Record Layout -- This all works)
01 MAIN-LINE1.
05 FILLER PIC X(03). <-- won't use in comparison
05 ID-1 PIC X(09).
05 FILLER PIC X(01).
05 KEY-1 PIC X(20).
05 FILLER PIC X(47).
01 MAIN-LINE2.
05 ID-2 PIC X(09).
05 FILLER PIC X(55).
05 KEY-2 PIC X(20).
05 FILLER PIC X(66).
阅读下面的语句。
下面的代码适用于文件中的匹配情况。
This code below works for a Matching situation in the files.
MATCH-INFILE1.
READ INFILE1 INTO MAIN-LINE1
AT END
MOVE 'Y' TO EOF1
GO TO X-INFILE1
NOT AT END
PERFORM READ-INFILE2 THRU X-INFILE2 UNTIL EOF2 = 'Y'
END-READ.
X-INFILE1. EXIT.
READ-INFILE2.
READ INFILE2 INTO MAIN-LINE2
AT END
MOVE 'Y' TO EOF2
GO TO X-INFILE2
NOT AT END
PERFORM COMP-FILE THRU X-COMP-FILE <-- I did not include this because
I forgot to but can add it in in
the morning when I have access
to the mainframe. (simple compare)
END-READ.
X-INFILE2. EXIT.
记录布局
客户布局:
**107458982** ****FM00000000000713432****CH <-- discard the CH
员工布局:
(丢弃SD两个字节字段)
Employee Layout: (discard the SD two byte fields)
SD **331067113** **FFM00000000004556402**
推荐答案
我认为无法使用您当前的代码来完成全部三个任务。如果文件包含 1,000,000条记录,也会发生什么情况。您将读取文件 1,000,000次。 永远要完成(假设硬盘仍然存在)。
I do not think it is possible to do all three tasks with your current code. Also what would happen if the files contained 1,000,000 records. You would be reading a file 1,000,000 times. It would take forever to finish (assuming the hard-disks survived).
为此处理类型我建议使用一种排序合并过程:
For this type of processing I would suggest a sort-merge process:
- 排序,将文件分为键序列
- 对2个文件进行合并(对于3个文件,过程类似,您只是要进行更复杂的评估)。
- Sort the files into key sequence
- Do a merge on the 2 files (for 3 files the process is similar, you just have more complicated evaluate).
键序列中2个文件的处理逻辑变为:
The processing logic for 2 files in key sequence becomes:
while not eof
evaluate true
when key-file1 < key-file2
Write file1-record to output-file-2
read file1
when key-file1 > key-file2
Write file2-record to output-file-3
read file2
when key-file1 = key-file2
/* match processing,
will involve reading at least one of the files */
move key-file1 to hold-key
while key-file1 = hold-key
Write Output-File-1
read file1
end
while key-file2 = hold-key
read file2
end
end
end
将添加文件结束逻辑
注意:从这个问题尚不清楚,应该如何处理同一个键的多个条目
Note: It is unclear from the question how multiple entries for the same key should be handled
这篇关于是否需要查看我的read语句是否可以完成3种类型的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!