解析器签署overpunch值?overpunch

2023-09-06 10:43:10 作者:那余伤未散

我正在与一些旧的数据导入,并从该报告的财务数据具有的签署overpunch 。我见过很多,但是这是我的时间了。在我去建立一个函数来分析这些陌生人,我想检查,看看是否有一个标准的方式来处理这些。

I am working with some old data imports and came across a bunch of data from an external source that reports financial numbers with a signed overpunch. I've seen alot, but this is before my time. Before I go about creating a function to parse these strangers, I wanted to check to see if there was a standard way to handle these.

我想我的问题是,用于将签署overpunch串.net框架提供一个标准的设施?如果没有.NET,是否有任何第三方工具可以使用,所以我不另起炉灶?

I guess my question is, does the .Net framework provide a standard facility for converting signed overpunch strings? If not .NET, are there any third party tools I can use so I don't reinvent the wheel?

推荐答案

通过打孔数字(划,小数中的Cobol)来自旧的打孔卡在哪里它们过度冲切上的号码的最后数字的符号。的格式常用于的Cobol

Over-punched numeric (Zoned-Decimal in Cobol) comes from the old-punched cards where they over-punched the sign on the last digit in a number. The format is commonly used in Cobol.

由于有两个 ASCII 和 EBCDIC的Cobol 的编译器,还有的两者的 ASCII 和 EBCDIC 版本划数字。为了使它更加复杂,-0和+ 0的值( {} 作为美国EBCDIC( IBM037 )是不同的说德语的EBCDIC( IBM273 ,他们在其他EBCDIC语言版本的金)和不同了)。

As there are both Ascii and Ebcdic Cobol compilers, there are both Ascii and EBCDIC versions of the Zoned-Numeric. To make it even more complicated, the -0 and +0 values ({} for US-Ebcdic (IBM037) are different for say German-Ebcdic (IBM273 where they are äü) and different again in other Ebcdic language versions).

要成功的过程中,你需要知道:

To process successfully, You need to know:

在没有数据的EBCDIC或ASCII系统发 如果EBCDIC - 这语言美,德等

如果数据是在原来的字符集,就可以计算出标志由

If the data is in the original character set, you can calculate the sign by

有关EBCDIC的十六进制数值codeS是:

For EBCDIC the numeric hex codes are:

Digit          0     1     2   ..    9

unsigned:   x'F0' x'F1' x'F2'  .. x'F9'     012 .. 9 
Negative:   x'D0' x'D1' x'D2'  .. x'D9'     }JK .. R
Positive:   x'C0' x'C1' x'C2'  .. x'C9'     {AB .. I

对于美国EBCDIC 划这是Java code将字符串转换为:

For US-Ebcdic Zoned this is the java code to convert a string:

int positiveDiff = 'A' - '1';
int negativeDiff = 'J' - '1';

lastChar = ret.substring(ret.length() - 1).toUpperCase().charAt(0);

    switch (lastChar) {
        case '}' : sign = "-";
        case '{' :
            lastChar = '0';
        break;
        case 'A':
        case 'B':
        case 'C':
        case 'D':
        case 'E':
        case 'F':
        case 'G':
        case 'H':
        case 'I':
            lastChar = (char) (lastChar - positiveDiff);
        break;
        case 'J':
        case 'K':
        case 'L':
        case 'M':
        case 'N':
        case 'O':
        case 'P':
        case 'Q':
        case 'R':
            sign = "-";
            lastChar = (char) (lastChar - negativeDiff);
        default:
    }
    ret = sign + ret.substring(0, ret.length() - 1) + lastChar;

有关德国EBCDIC {}成为金,其他EBCDIC语言,你需要查找相应的codeD页。

For German-EBCDIC {} become äü, for other EBCDIC-Language you would need lookup the appropriate coded page.

对于 ASCII 划这是Java code

For Ascii Zoned this is the java code

    int positiveFjDiff = '@' - '0';
    int negativeFjDiff = 'P' - '0';

    lastChar = ret.substring(ret.length() - 1).toUpperCase().charAt(0);

    switch (lastChar) {
        case '@':
        case 'A':
        case 'B':
        case 'C':
        case 'D':
        case 'E':
        case 'F':
        case 'G':
        case 'H':
        case 'I':
            lastChar = (char) (lastChar - positiveFjDiff);
        break;
        case 'P':
        case 'Q':
        case 'R':
        case 'S':
        case 'T':
        case 'U':
        case 'V':
        case 'W':
        case 'X':
        case 'Y':
            sign = "-";
            lastChar = (char) (lastChar - negativeFjDiff);
        default:
    }
    ret = sign + ret.substring(0, ret.length() - 1) + lastChar;

最后,如果您在使用EBCDIC你可以计算出它像

Finally if you are working in EBCDIC you can calculate it like

sign = '+'
if (last_digit & x'F0' == x'D0') {
   sign = '-' 
} 
last_digit = last_digit | x'F0'

最后一个问题是小数点是不存储在一个分区,小数他们假设。你需要看的Cobol-字帖。

One last problem is decimal points are not stored in a Zoned, decimal they are assumed. You need to look at the Cobol-Copybook.

例如。

 if the cobol Copybook is

    03 fld                 pic s99999.

 123 is stored as     0012C (EBCDIC source)

 but if the copybook is (v stands for assumed decimal point) 

   03 fld                  pic s999v99.

 then 123 is stored as 1230{  

这将是最好的做翻译的Cobol!或使用Cobol语言翻译包。

It would be best to do the translated in Cobol !!! or using a Cobol Translation packages.

有处理COBOL数据的几个商业软件包,他们往往是昂贵的。 有一些Java是可与大型机COBOL数据处理一些开源软件包。

There are several Commercial Packages for handling Cobol Data, they tend to be expensive. There are some Java are some open source packages that can deal with Mainframe Cobol Data.

相关推荐