如何处理其中“{”的主机编号是最后一个字符

发布于 2025-01-16 18:33:25 字数 266 浏览 1 评论 0原文

我有一个大型机文件数据,如下所示,

000000720000{

我需要解析数据并加载到配置单元表中,如下所示,

72000

上面的字段是收入列,“{”符号表示 +ve 金额 创建表收入小数(11,2)时使用的数据类型

使用 INCOME PIC S9(11)V99 在layout.cob copybook中

有人可以帮忙吗?

I have a one mainframe file data like as below

000000720000{

I need to parse the data and load into a hive table like below

72000

the above field is income column and "{" sign which denotes +ve amount
datatype used while creating table income decimal(11,2)

in layout.cob copybook using INCOME PIC S9(11)V99

could someone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

睡美人的小仙女 2025-01-23 18:33:25

您想要的数字是 7200000,即 72000.00。

您要查找的转换是:

正数

{ = 0
A = 1
B = 2
C = 3
D = 4
E = 5
F = 6
G = 7
H = 8
I = 9

负数(这会使整个值变为负数)

} = 0
J = 1
K = 2
L = 3
M = 4
N = 5
O = 6
P = 7
Q = 8
R = 9

让我们解释一下原因。

根据您的问题,您遇到的问题是将打包的十进制数据解包为字符数据。基本上,PIC S9(11)V2 实际上占用了 7 个字节的存储空间,如下图所示。

你会看到三行。顶部是字符表示(第一张图片中缺少,因为十六进制值未映射到可显示字符),下面的行是十六进制值。最高有效数字位于顶部,最低有效数字位于下方。

中,符号存储为 C,它是正数,要表示负值,您会看到 D

当它转换为字符数据时,它看起来像这样

在此处输入图像描述

请注意 C0,它是解包以保留符号的结果。请注意,此显示位于 EBCDIC 的 z/OS 上。如果文件已传输并转换为另一个代码页,您将看到正确的字符,但十六进制值将不同。

以下是您可能会看到的正数的所有组合

在此处输入图像描述

以及此处的负数

在此处输入图像描述

为了让您的生活更轻松,如果您看到第一组字符,然后您可以将其替换为相应的数字。如果您看到第二组中的某些内容,那么它就是负数。

The number you want is 7200000 which would be 72000.00.

The conversion you are looking for is:

Positive numbers

{ = 0
A = 1
B = 2
C = 3
D = 4
E = 5
F = 6
G = 7
H = 8
I = 9

Negative numbers (this makes the whole value negative)

} = 0
J = 1
K = 2
L = 3
M = 4
N = 5
O = 6
P = 7
Q = 8
R = 9

Let's explain why.

Based on your question the issue you are having is when packed decimal data is unpacked UNPK into character data. Basically, the PIC S9(11)V2 actually takes up 7 bytes of storage and looks like the picture below.

You'll see three lines. The top is the character representation (missing in the first picture because the hex values do not map to displayable characters) and the lines below are the hexadecimal values. Most significant digit on top and least below.

enter image description here

Note that in the rightmost byte the sign is stored as C which is positive, to represent a negative value you would see a D.

When it is converted to character data it will look like this

enter image description here

Notice the C0 which is a consequence of the unpacking to preserve the sign. Be aware that this display is on z/OS which is EBCDIC. If the file has been transferred and converted to another code-page you will see the correct character but the hex values will be different.

Here are all the combinations you will likely see for positive numbers

enter image description here

and here for negative numbers

enter image description here

To make your life easy, if you see one of the first set of characters then you can replace it with the corresponding number. If you see something from the second set then it is a negative number.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文