读取来自文本文件的 S9(07)V99 COMP-3、S9(4) COMP-4 和 S9(3) COMP-3 值,在 Java 中。

huangapple go评论94阅读模式
英文:

read S9(07)V99 COMP-3, S9(4) COMP-4, S9(3) COMP-3 values from text file in java

问题

我已从主机下载了一个文本文件,其中包含 S9(07)V99 COMP-3、S9(4) COMP-4、S9(3) COMP-3 的值。请问如何在 Java 中读取它们的实际值。

英文:

i have downloaded a text file from Mainframe which contains S9(07)V99 COMP-3, S9(4) COMP-4, S9(3), COMP-3 value in text file, how to read actual value of it in java.

答案1

得分: 1

以下是翻译好的部分:

有2个基本的处理文件的方向

  • 将主机上的comp-(n)字段转换为文本字段(排序工具是一个不错的选择),然后执行标准的EBCDIC到ASCII转换/翻译。
  • 进行二进制(不进行EBCDIC转换)传输。您将需要处理以下内容
    • 主机文件结构(它们与PC / Unix结构不同)
    • 将EBCDIC转换为Java-Unicode(对于美国EBCDIC,编码是CP037(或IBM037))
    • 转换Comp-(n)变量
    • JRecord 可以使用Cobol Copybook在Java中读取主机文件。它还可以处理主机文件结构

无论哪种方式,您可能都需要执行另一个文件传输。
如果您使用记事本编辑已传输的文件并且能够读取其中的一些文本,
则该文件已损坏

为什么将二进制主机文件转换为EBCDIC

在将EBCDIC文件转换为ASCII时,转换程序将尝试转换每个字节,包括二进制字段。

考虑一个值为400的comp-3字段

  十六进制表示   转换为ASCII后的十六进制表示
  
  
    40 0c               20 0c 

在这种情况下,EBCDIC空格字符(x'40')已被转换为
ASCII空格字符(x'20'),400现在变为200。

主机文件结构

主机上最常见的2种文件结构是

  • 固定宽度文件(RECFM=FB) - 其中每个记录(行)都具有固定长度
  • 变长记录长度文件(RECFM=FB) - 其中每个记录(行)都以长度(RDW -记录描述符字)开头。

RecordEditor / JRecord

JRecord 允许您使用Cobol Copybook读取主机文件。它可以执行转换并处理
主机文件结构。

RecordEditor生成选项可以创建用于从示例文件和Cobol Copybook读取主机Cobol文件的框架代码。

还请参阅 https://stackoverflow.com/questions/46313332/how-do-you-generate-javajrecord-code-for-a-cobol-copybook

英文:

There are 2 basic directions for a file like this

  • Convert comp-(n) fields to Text Fields on the mainframe (the sort utility is a good option) and do standard EBCDIC to ASCII transfer / translate.
  • Do a binary (no EBCDIC Translation) transfer. You will have to handle
    • Mainframe file Structures yourself (they are different to PC / Unix strucutures)
    • Translate Ebcdic to Java-Unicode (For US Ebcdic, the encoding is CP037 (or IBM037)
    • Translate the Comp-(n) variables
    • The JRecord can Read mainframe files in java using a Cobol Copybook. It can also handle mainframe file Structures

Either way you will probably have to do another file Transfer.
If you edit your transferred file with notepad an can read some of the Text,
the file is corrupt.

Why Transfer binary Mainframe files as EBCDIC

When converting an EBCDIC file to ASCII, the conversion program will
try and convert every byte, including binary fields.

Consider a comp-3 field with a value of 400

  Hex Represention   Hex representation after translation to ASCII
  
  
    40 0c               20 0c 

in this case the EBCDIC space character (x'40') has been translated to
the ASCII space character (x'20') and 400 is now 200.

Mainframe File Structures

The 2 most common file structures on the Mainframe are

  • Fixed Width files (RECFM=FB) - where every record (line) is a fixed length
  • Variable Record Length files (RECFM=FB) - where every record (line) is
    preceded by the length (RDW -record descriptor word).

RecordEditor / JRecord

JRecord will let you read the
mainframe file using a Cobol copybook. It can do the translation and handle
mainframe file structures.

The Generate option of the RecordEditor can create skelton
code to read a mainframe Cobol file from a sample file and Cobol Copybook.

Also see https://stackoverflow.com/questions/46313332/how-do-you-generate-javajrecord-code-for-a-cobol-copybook.

huangapple
  • 本文由 发表于 2020年9月23日 22:17:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/64029977.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定