将由COBOL生成的顺序文件转换为字母数字,并使用压缩数据(Convert to alphanumeric a sequential file generated by COBOL with comp

编程入门 行业动态 更新时间:2024-10-28 19:24:28
将由COBOL生成的顺序文件转换为字母数字,并使用压缩数据(Convert to alphanumeric a sequential file generated by COBOL with compacted data)

我有一个COBOL程序,它生成一个具有以下结构的顺序文件:

FD ALUMNOS-FILE. 01 ALUMNOS-DATA. 88 EOF VALUE HIGH-VALUES. 05 STUDENTID PIC 9(7). 05 STUDENTNAME PIC X(10). 05 FILLER PIC X(8). 05 COURSECODE PIC X(4). 05 FOO PIC S9(7)V USAGE COMP-3.

如果我在Notepad ++中打开文件,我会看到由COMP-3变量导致难以阅读的奇怪的unicode符号。 类似于下图的图像(图像来自另一个文件):

有没有办法不使用COBOL重写这个顺序文件是可读的? 也许使用像VBS这样的脚本语言? 任何提示或建议将不胜感激,如果您需要更多信息,请告诉我,我将编辑该帖子。

I have a COBOL program which generates a sequential file with this structure:

FD ALUMNOS-FILE. 01 ALUMNOS-DATA. 88 EOF VALUE HIGH-VALUES. 05 STUDENTID PIC 9(7). 05 STUDENTNAME PIC X(10). 05 FILLER PIC X(8). 05 COURSECODE PIC X(4). 05 FOO PIC S9(7)V USAGE COMP-3.

If I open the file in Notepad++, I see strange unicode symbols which are difficult to read caused by the COMP-3 variable. Something similar to the image below (the image is from another file):

Is there any way without using COBOL to rewrite this sequential file to be readable? Maybe using a script language like VBS? Any tip or advice will be appreciated, and if you need more info let me know and I'll edit the post.

最满意答案

我建议看一下Last Cobol问题

但RecordEditor将允许您使用Cobol Copybook查看/编辑Cobol文件。 在RecordEditor中,您可以根据需要将文件导出为Csv,Xml。

正如Last Cobol问题中所提到的,有几种解决方案可以用Java读取Cobol文件,也可能用其他语言编写。


要将Cobol Copybook导入RecordEditor,请选择: 记录布局 >>> 导入Cobol Copybook

Import_Cobol_Copybook

文件结构控制文件的读取方式。 如果所有记录的长度相同(没有carraige返回),请使用固定长度二进制 文件结构

支持的其他结构包括

标准文本文件文件结构 :** ..Text .. ** Cobol可变记录长度文件。 这些通常具有记录长度,后跟数据。 有大型机,Open-Cobol,富士通的版本。 默认文件结构将根据记录定义选择最可能的文件结构 。 在您的情况下,它应该选择固定长度二进制,因为定义中有一个二进制字段。

注意:从记录编辑器0.94.4开始,如果需要,可以使用固定长度二进制 文件结构编辑基本文本编辑器中的固定长度文本文件。

注意:我是RecordEditor的作者

回答更新2017/08/09

转换实用程序

对于简单的Cobol文件,可以使用这些转换实用程序(基于JRecord):

[CobolToCsv] [5] [CobolToXml] [6] [Cobol To Json] [7]

RecordEditor

RecordEditor有一个Generate选项,用于生成Java / JRecord代码。 参见[RecordEditor代码生成注释] [8]

在此处输入图像描述

I would suggest having a look at the Last Cobol Questions

But the RecordEditor will let you view / edit Cobol Files using a Cobol Copybook. In the RecordEditor you can export the file as Csv, Xml if you want.

As mentioned in the Last Cobol Questions there are several solution for Reading Cobol files in Java and probably some in other languages.


To import the Cobol Copybook into the RecordEditor, Select: Record Layout >>> Import Cobol Copybook

Import_Cobol_Copybook

The File-Structure controls how the file is read. Use a File-Structure of Fixed length Binary if all the records are of the same length (no carraige return).

Other Structures supported include

Standard Text files File Structures: ** ..Text.. ** Cobol Variable Record Length Files. These Typically have a Record-Length followed by the Data. There are versions for Mainframes, Open-Cobol, Fujitsu. The Default File structure will choose the most likely File-Structure based on the Record-Definition. In your case it should choose Fixed length Binary because there is a binary Field in the Definition.

Note: From Record Editor 0.94.4, with a File-Structure of Fixed Length Binary you can edit Fixed Length Text files in a basic Text Editor if you want.

Note: I am the author of RecordEditor

Answer Updates 2017/08/09

Conversion Utilities

For simple Cobol files these conversion utilities (based on JRecord) could be used:

[CobolToCsv][5] [CobolToXml][6] [Cobol To Json][7]

RecordEditor

The RecordEditor has a Generate option for generating Java / JRecord code. See [RecordEditor Code Generation notes][8]

enter image description here

更多推荐

本文发布于:2023-07-09 00:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1082107.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:将由   转换为   字母   顺序   数字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!