将字段添加到现有 COBOL 数据文件
我有一个现有的 MF COBOL 4.0 程序,在 ISAM 文件中包含多年的数据,但我需要向现有文件添加一个新字段。该记录当前有 1208 个字符,我需要再添加 10 个字符。
如果我只是将额外的 PIC X(10) 字段放入我的抄写本中,则会出现错误。
I have an existing MF COBOL 4.0 program with years of data in a ISAM file but I need to add a new field to the existing file. The record currently has 1208 chars and I need to add another 10 to it.
If I simply put the extra PIC X(10) field in my copybook, it gives me an error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要修改基础数据文件以匹配 COBOL 中的文件定义。一种方法是定义一行输出,与现在的数据行完全相同,但在其末尾添加一个额外的 Pic x(10)。然后,您将逐行读取数据,并将其输出到新位置,并在末尾添加 10 个额外空格。这样你的数据就长了 10 个字符,你可以返回并将额外的 Pic x(10) 添加到你的主程序中。之后应该可以工作。
You need to modify the underlying data file to match your file definition in COBOL. One way to do so would be to define a line of output exactly like what lines of your data look like now, but with an extra Pic x(10) on the end of it. You would then read in your data line by line, and output it to a new location with 10 extra spaces on the end of it. That way your data is 10 characters longer, and you can go back and add that extra Pic x(10) to your main program. It should work after that.
通过更改抄写本,您只是更改了程序中使用的数据的表示形式。难道您不应该也重构数据源(即ISAM 文件)吗?
With changing the copybook, you're only changing the representation of the data used in your program. Shouldn't you be restructuring the data source (i.e. the ISAM file) as well?
迟到的回答,但我想你可能会感兴趣。
我在 Cobol 系统上工作了 20 多年,我们多次遇到过这个问题。
对索引文件结构的更改被我们视为“主要版本”。这些需要特定的转换程序,这些程序:
转换需要系统“关闭”,因此它们被视为主要版本。
如果您的文件将来可能会添加字段,您可以在索引文件末尾添加额外的 FILLER ,以便您应对添加的新字段。我们倾向于添加 50 或 100 的 FILLER。当然,如果您更改现有字段之一,甚至任何键的结构,这对您没有帮助。
Late answer, but I thought you might be interested.
I've been working on our Cobol system for over 20 years and we've come across this issue many times.
Changes to the structure of our index files are what we consider a "Major Release". These require specific Conversion programs which:
Of course these conversions require the system to be 'down', hence the reason why they are considered major releases.
If you have files which are likely to have fields added to them in the future, you can add extra FILLER to the end of index file to let you cope with new fields being added. We tend to add a FILLER of 50 or 100. Of course this doesn't help you if you change one of the existing fields, or even the structure of any of the keys.
对于文件错误,您需要保留一个方便的列表。我建议从您在网上找到的列表开始,每当您遇到无法在 5 秒内解决的错误时,请添加解决方案的详细说明,以便下次发生时将其记录在笔记中。这里有一些不错的列表,可以从
在我的列表中,文件状态 39 是:
这是来自个性化注释:检查您在 JCL 中分配给 ddname 的文件。尤其是长度分配。就您而言,您知道长度不匹配,因为您刚刚更改了程序。
有一些实用程序可以重新格式化数据集,特别是 SYNCSORT。或者当然您可以自己编写。
For file errors, you will want to keep a list handy. I recommend starting with a list you find online, and any time you get an error you cannot figure out in 5 seconds, add a detailed explanation of the resolution so you will have it in your notes the next time it happens. Here are a couple decent lists to start with
In my list, file status 39 is:
And this is from the personalized note: Check the file that you have assigned to your ddname in your JCL. Especially the length allocation. In your case, you know that the length does not match, since you just changed the program.
There are utilities to reformat datasets, particularly SYNCSORT. Or of course you can write your own.