I downloaded the code from code.google and get the last version v0.5.2
I set a field in bcd fix format,which is N-6 in bcd format(bit._003_proc_code)
For ex:
*Field definition:
DefaultTemplate =new Template
{
{ Bit._002_PAN, FieldDescriptor.BcdVar(2, 19,Formatters.Ascii) },
{ Bit._003_PROC_CODE, FieldDescriptor.BcdFixed(3)},
{ Bit._004_TRAN_AMOUNT, FieldDescriptor.BcdFixed(6) },
..............
}
usage:
Iso8583 msg =new Iso8584();
msg[3]="000000";
when i unpack the message ,i can only get “0000” from message 3 .
is this a bug or error in definition
I would wait to hear from John Oxley to see if this is just a coding error. Now that I said that, I think it is a bug.
I had problems with the BcdFixed definition and ended up creating a new Fixed Length BCD formatter to work around the problem.
Here is what I did:
I created a class called FixedLengthBcdFormatter which is a variation of the FixedLengthFormatter class.
/// /// Fixed field formatter /// public class FixedLengthBcdFormatter : ILengthFormatter { private readonly int _packedLength; private readonly int _unPackedLength;
}
Modified the FieldDescription class / BcdFixed declaration
/// /// The bcd fixed. /// /// /// The length. /// /// /// public static IFieldDescriptor BcdFixed(int unpackedLength) { return Create(new FixedLengthBcdFormatter(unpackedLength), FieldValidators.N, Formatters.Bcd, null); }
Then change your formatter declaration to provide the unpacked length as the paramter.
Bit._003_PROC_CODE, FieldDescriptor.BcdFixed(6)},
Again, all this may have been unnecessary because I didn't know something about the existing code, but it is working for me.
I hope this helps.