COBOL COMP-3数字格式问题 [英] COBOL COMP-3 number format issue

查看:1172
本文介绍了COBOL COMP-3数字格式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个cobol磁带格式转储,它有文本和数字字段的混合。我正在阅读C#中的文件作为二进制数组(字节数组)。我有复制书和格式排列在文本字段罚款。还有一些COMP-3领域。这些字段中的数据似乎不符合任何BCD格式。我知道数据应该是什么,我有COMP-3的原始字节。我试图先转换到EBCDIC,没有得到更好的结果。有关COMP-3号码如何在内部存储的任何想法?以下是PIC,原始数据和预期编号的三个例子。我知道我的字段位置是正确的,因为在数字的两边都有字母数据,并且所有的字符都是正确的。

第一个例子:
PIC (9)COMP-3
数据有5个字节,十六进制值是02 01 20 91 22
结果数据应该是一个日期(00CCYYMMDD)。

第二个例子:
这个字段的PIC是S9(3)COMP-3
有2个字节的数据,十六进制值是0A 14
结果值应该在900和999
我的理解是,S意味着最后半字节应该是0xC或0xD到第三个例子:
这个字段的PIC是S9(15)V99 COMP-3
这个字段有9个字节数据,十六进制值是00 00 00 00 00 00 01 80 0C
结果值应该是12.00

好的,多谢那些回应的人指出我正确的方向。这确实是一个ASCII / EBCDIC表示问题。 BCD存储在EBCDIC中。使用ASCII到EBCDIC转换表可以得到格式正确的BCD数字:

我用这个链接来映射数据: http://shop.alterlinks.com/ascii-table/ascii-ebcdic-us.php



我的数据:0A 14转换:25 3C(原来253是一个有效值,spec是错误的)C = +,都很好

我的数据:01 80 0C(不包括前导零)转换:01 20 0C 12.00 C = +,隐含2位数字格式, :02 01 20 91 22转换:02 01 40 31 7F 2014/03/17(F是未使用的半字节),所有的都是好的

解决方案

<好的,谢谢两位正在向我指出正确方向的人。这确实是一个ASCII / EBCDIC表示问题。 BCD存储在EBCDIC中。使用ASCII到EBCDIC转换表可以得到格式正确的BCD数字:

我用这个链接来映射数据: http://shop.alterlinks.com/ascii-table/ascii-ebcdic-us.php

 我的数据:0A 14 
转换:25 3C(原来253是一个有效值,spec是错的)C = +,所有好的

我的数据:01 80 0C(不包括前导零)
转换:01 20 0C 12.00 C = +,格式中暗示2位数,全部为好

我的数据:02 01 20 91 22
转换为:02 01 40 31 7F 2014/03/17(F为未用半字节),全部为

再次感谢上述两个答案,让我朝着正确的方向前进。


I have a cobol "tape format" dump which has a mixture of text and number fields. I'm reading the file in C# as a binary array (array of byte). I have the copy book and the formats are lining up fine on the text fields. There are a number of COMP-3 fields as well. The data in those fields doesnt seem to match any BCD format. I know what the data should be and I have the raw bytes of the COMP-3. I tried converting to EBCDIC first which yielded no better results. Any thoughts on how a COMP-3 number can be otherwise internally stored? Below are three examples of the PIC, the raw data and the expected number. I know I have the field positions correct because there is alpha data on either side of the numbers and that all lines up correctly.

First Example: The PIC of the field is 9(9) COMP-3 There are 5 bytes to the data, the hex values are 02 01 20 91 22 The resulting data should be a date (00CCYYMMDD). This particular date should be 3-17-14.

Second Example: The PIC of the field is S9(3) COMP-3 There are 2 bytes to the data, the hex values are 0A 14 The resulting value should be between 900 and 999 My understanding is that the "S" means that the last nibble should be 0xC or 0xD to indicate + or -

Third Example: The PIC of the field is S9(15)V99 COMP-3 There are 9 bytes to the data, the hex values are 00 00 00 00 00 00 01 80 0C The resulting value should be 12.00

Ok so thanks to the people who responded as they pointed me in the right direction. This is indeed an ASCII/EBCDIC representation issue. The BCD is stored in EBCDIC. Using an ASCII to EBCDIC conversion table yields properly formatted BCD digits:

I used this link to map the data: http://shop.alterlinks.com/ascii-table/ascii-ebcdic-us.php

My data: 0A 14 Converted: 25 3C (turns out that 253 is a valid value, spec was wrong) C = +, all good

My data: 01 80 0C (excluding leading zeros) Converted: 01 20 0C 12.00 C = +, implied 2 digits in format, all good

My data: 02 01 20 91 22 Converted: 02 01 40 31 7F 2014/03/17 (F is unused nibble), all good

解决方案

Ok so thanks to both people who responded as they pointed me in the right direction. This is indeed an ASCII/EBCDIC representation issue. The BCD is stored in EBCDIC. Using an ASCII to EBCDIC conversion table yields properly formatted BCD digits:

I used this link to map the data: http://shop.alterlinks.com/ascii-table/ascii-ebcdic-us.php

My data:    0A 14
Converted:  25 3C  (turns out that 253 is a valid value, spec was wrong) C = +, all good

My data:    01 80 0C  (excluding leading zeros)
Converted:  01 20 0C  12.00  C = +, implied 2 digits in format, all good

My data:    02 01 20 91 22
Converted:  02 01 40 31 7F     2014/03/17  (F is unused nibble), all good

Thanks again for the two above answers which led me in the right direction.

这篇关于COBOL COMP-3数字格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆