0

I am calling an as400 Rpg program from C#. I pass it 6 parameters with value and a 7th that is null and to be returned from the program. I do receive a value from the program in the form of a byte. The returned value is supposed to be either 1 or 0 depending on the execution of the program. enter image description here

enter image description here

I have tried using this string result = System.Text.Encoding.UTF8.GetString(byteArray);

Which returns this � symbol. I have tried converting to Hex which returns F1. How can i get the value of that byte in C#? Again i know that the only possible values are 1 or 0.

Update if I use stringConverter.FromBytes(parameters["p7"].Value i always receive a 1.

  ProgramParameters parameters = new ProgramParameters();
                parameters.Append("P1", cwbrcParameterTypeEnum.cwbrcInout, 3);
                parameters["P1"].Value = stringConverter.ToBytes(uwDecision.Param1.PadRight(paramLength, ' '));
                parameters.Append("P2", cwbrcParameterTypeEnum.cwbrcInput, 10);
                parameters["P2"].Value = stringConverter.ToBytes(uwDecision.Param2.PadRight(parmlenth2, ' '));
                parameters.Append("P3", cwbrcParameterTypeEnum.cwbrcInput, 10);
                parameters["P3"].Value = stringConverter.ToBytes(uwDecision.Param3.ToUpper().PadRight(parmlenth2, ' '));
                parameters.Append("P4", cwbrcParameterTypeEnum.cwbrcInput, 1);
                parameters["P4"].Value = stringConverter.ToBytes(uwDecision.Param4.PadRight(paramlength3, ' '));
                parameters.Append("P5", cwbrcParameterTypeEnum.cwbrcInput, 3);
                parameters["P5"].Value = stringConverter.ToBytes(uwDecision.Param5.PadRight(paramLength, ' '));
                parameters.Append("P6", cwbrcParameterTypeEnum.cwbrcInput, 3);
                parameters["P6"].Value = stringConverter.ToBytes(uwDecision.Param6.PadRight(paramLength, ' '));
                parameters.Append("P7", cwbrcParameterTypeEnum.cwbrcInout, 1);
                program.Call(parameters);


                var read = stringConverter.FromBytes(parameters["P7"].Value);

                isValid = read == "1";
                system.Disconnect(cwbcoServiceEnum.cwbcoServiceAll);
Leonardo Wildt
  • 2,529
  • 5
  • 27
  • 56

1 Answers1

0

It appears that the message is using a Extended Binary Coded Decimal Interchange Code. You will need to convert or translate, however, it appears the system is attempting to send 0 and 1, just in it's representation.

EBCDIC Hex              EBCDIC Text        ASCII Translation
------------------    --------------     -----------------
       F1                    1                 241 = 0xF1
       F0                    0                 240 = 0xF0  
Ross Bush
  • 14,648
  • 2
  • 32
  • 55