如何处理其中“{”的主机编号是最后一个字符
我有一个大型机文件数据,如下所示,
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要的数字是 7200000,即 72000.00。
您要查找的转换是:
正数
负数(这会使整个值变为负数)
让我们解释一下原因。
根据您的问题,您遇到的问题是将打包的十进制数据解包为字符数据。基本上,
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
Negative numbers (this makes the whole value negative)
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, thePIC 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.
Note that in the rightmost byte the sign is stored as
C
which is positive, to represent a negative value you would see aD
.When it is converted to character data it will look like this
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
and here for negative numbers
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.