分析超额价值的解析器?

Sli*_*345 5 .net c# asp.net signed cobol

我正在处理一些旧的数据导入,并从外部来源获得了大量数据,这些数据通过签名的超量报告来报告财务数据.我见过很多,但这是在我的时间之前.在我创建一个解析这些陌生人的函数之前,我想检查是否有一种标准的方法来处理这些.

我想我的问题是,.Net框架是否提供了转换签名过冲字符串的标准工具?如果不是.NET,我可以使用任何第三方工具,所以我不重新发明轮子?

Bru*_*tin 7

过度打孔的数字(Cobol中的Zoned-Decimal)来自旧打孔卡片,在那里他们在数字的最后一位数上打了过去.该格式通常用于Cobol.

由于既有AsciiEbcdic Cobol编译器,也有Zoned -Numeric的AsciiEBCDIC版本.为了使它更复杂,US-Ebcdic(IBM037)的-0和+0值({}对于德语-Ebcdic(IBM273,它们是äü)而言是不同的,而在其他Ebcdic语言版本中则不同.

要成功处理,您需要知道:

  • 数据是否源自Ebcdic或Ascii系统
  • 如果Ebcdic - 哪种语言美国,德国等

如果数据是原始字符集,则可以计算符号

对于EBCDIC,数字十六进制代码是:

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
Run Code Online (Sandbox Code Playgroud)

对于US-Ebcdic Zoned这是转换字符串的java代码:

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;
Run Code Online (Sandbox Code Playgroud)

对于德语-EBCDIC {}成为äü,对于其他EBCDIC语言,您需要查找适当的编码页面.

对于Ascii Zoned,这是java代码

    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;
Run Code Online (Sandbox Code Playgroud)

最后,如果你在EBCDIC工作,你可以计算它

sign = '+'
if (last_digit & x'F0' == x'D0') {
   sign = '-' 
} 
last_digit = last_digit | x'F0'
Run Code Online (Sandbox Code Playgroud)

最后一个问题是小数点不是存储在一个分区,十进制它们被假定.你需要看看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{  
Run Code Online (Sandbox Code Playgroud)

最好在Cobol中翻译!或使用Cobol翻译包.

有几个用于处理Cobol Data的商业软件包,它们往往很昂贵.有一些Java是一些可以处理Mainframe Cobol Data的开源软件包.