Reading the generated Cobol file

I'm currently in the process of writing a C # application, which is going to be between two existing applications. All I know about the second application is that it processes the files generated by the first. The first application is written in Cobol.

Steps: 1) Cobol application, writes some files and copies to the directory. 2) The second application selects these files and processes them.

My C # application will be between 1) 2). He will have to collect the file generated 1), read it, modify and save, so that the application 2) would not know that I was even there.

I have a few issues.

  • First of all, if I open the file generated by 1) in notepad, most of them are unreadable, and the other parts.
  • If I read the file, modify it and save it, I have to save the file with the same notation as used by the cobol application, so application 2) does not know that I was there.

I tried reading the file this way, but it still cannot be read:

the code:

        string ss = @"filename";

        using (FileStream fs = new FileStream(ss, FileMode.Open))
        {
            StreamReader sr = new StreamReader(fs);
            string gg = sr.ReadToEnd();
        }

Also, if I find a way to make it readable (using some kind of coding technique), I'm afraid that when I save the file again, I can change its original format.

Any thoughts? Suggestions?

+5
source share
3 answers

To read the COBOL-genned file, you need to know:

First you need a record layout (copy) for the file. The COBOL recording format will look something like this:

01  PATIENT-TREATMENTS.
    05  PATIENT-NAME                PIC X(30).
    05  PATIENT-SS-NUMBER           PIC 9(9).
    05  NUMBER-OF-TREATMENTS        PIC 99 COMP-3.
    05  TREATMENT-HISTORY OCCURS 0 TO 50 TIMES
           DEPENDING ON NUMBER-OF-TREATMENTS
           INDEXED BY TREATMENT-POINTER.
        10  TREATMENT-DATE.
            15  TREATMENT-DAY        PIC 99.
            15  TREATMENT-MONTH      PIC 99.
            15  TREATMENT-YEAR       PIC 9(4).
        10  TREATING-PHYSICIAN       PIC X(30).
        10  TREATMENT-CODE           PIC 99.

IBM (S/360, S370, z/OS, ). IBM

8 ( ) 9 ( ) .

.

COBOL. :

  • PIC (PIC 9 (4), , 4 , , ). Pic 999V99 - 5 . So-on .
  • BINARY [] . - (2 ) (4 ).
  • COMP-1 - .
  • COMP-2 - .

IBM, COMP-1 COMP-2, , IEE: IBM -16 64 . - S/370, .

  • COMP-3 " ", . - . : PIC S9999V99 COMP-3. , , 6 . ( 0-9). - . A-F, . PIC ceil( (6+1)/2 ) 4 . -345.67, PIC, 0x0034567D. ( C/, D/, A, C, E F , B D ). , . S\370 .

COMP-3 . "PIC S9999V99" (, 5 , ). EBCDIC - 0xFO - 0xF9. "Unpack" ( ) . :

  • . , .
  • ( ), . F.

  • , , .

  • , , "0" (oxF0).

, -345.67, (hex D), 0xF0F0F0F3F4F5F6D7 ('0003456P', EBDIC).

[ . ]

  • COBOL IBM, EBCDIC ASCII? , (: , , - (COMP-1, COMP-2, COMP -3 BINARY , ). , EBCDIC - , .

... . , , , , , , .

.

+26
  • , Cobol Dialect , Cobol. Cobol (Micro Focus) " " ( Micro Focus VB/Indexed).

  • RecordEditor (http://record-editor.sourceforge.net/). , .

  • /AS 400, EBCDIC (cp037 - Coded Page 37 US EBCDIC), , , Ascii.

  • , , Packed-Decimal (Comp3) Binary-Integer. Big-Endian ( Comp) Intel ( ).

  • , Cobol PIC s9 (6) V99 comp x'0001 ', 0,01. , Cobol, , 1 1 0,1, 0,01 ..

+2

, , , "" COBOL: , .

, , , ! "" , ​​ / "" . , , . , , , COBOLish, .

, . , "" , "" . , , / , . , .. - , . , ( , , , ). " " , ( ).

+2
source

All Articles