convert input to Ebcidic format and load to text file

Srini

Member
Joined
Nov 15, 2022
Messages
6
Programming Experience
Beginner
Hi,


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

Below are inputs

Code:
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

New to c#

Created below script, how ever the output file size i get 173 eventhoug i used byte conversion for fd/ft.


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






C#:
  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);

    }
 
Last edited by a moderator:
Welcome to the forums. In the future, please post your code in code tags. It looks like </> in the toolbar where you enter your post. That will prevent that forum software from thinking that the [i]'s in your code are italics markers, and it will also preserve your indentation.
 
Back
Top Bottom