0

I have got a requirement to create text file with EBCIDIC format output.

Below are the inputs

Action - string(1) - Value '1'
Key - string(32 - '11111111111111111111111111111111'
FD - string(8) - '2023188C'  (Julian)
FT  - string(12) - 00000234625C (julian)
Snil - string(20) - '                    '

Need to convert FD/FT values to bytes array, So output values store in 4 byte and 6 byte size.

I expect length would be 1+32+4+6+20 = 63

I created the script below, however the output file size I get is 173 even though I used byte conversion for fd/ft.

Can some one suggest where I am doing wrong and suggest change please.

public override void PreExecute()
{
    base.PreExecute();
    
    Encoding outputEncoding = Encoding.GetEncoding(37);
    
    textwriter = new StreamWriter(@"C:\script.txt", true, outputEncoding);
    
}

public override void PostExecute()
{
    textwriter.Close();
}

public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    textwriter.Write(Row.SourceStatus);
    textwriter.Write(Row.HeaderRecordKey);
    SByte[] ebcdicData = new SByte[Row.FileDate.Length / 2];
    for (int i = 0; i < ebcdicData.Length; i++)
    {
        string chunk = Row.FileDate.Substring(i * 2, 2);
        ebcdicData[i] = Convert.ToSByte(chunk, 16);
        textwriter.Write(ebcdicData[i]);

    }
    
    SByte[] ebcdicData1 = new SByte[Row.FileTime.Length / 2];
    for (int i = 0; i < ebcdicData1.Length; i++)
    {
        string chunk = Row.FileTime.Substring(i * 2, 2);
        ebcdicData1[i] = Convert.ToSByte(chunk, 16);
        textwriter.Write(ebcdicData1[i]);

    }
    
    textwriter.Write(Row.Filler);
}
Bagus Tesa
  • 1,317
  • 2
  • 19
  • 42
Srini
  • 17
  • 3

0 Answers0