Here are 3 examples, all from the same DB2 field. ASCII_STRING EBCDIC_STRING 4A000000000029 D100000000005D 490000008798F04A0000000082F0 C900000017388CD100000000228C 4200000019D8F0430000007FF80C4400000001DF14 C200000019808CC300000007700CC400000001593C The the ascii_string variable comes from using $HEX. on the DB2 column, the ebcdic_string column is what I produced with my array. Lets look at the ebcdic strings one by one, since those are what I need. 1) D100000000005D Characters 3-13 represent a number, and I need to dived by 100 to put the decimal back. In this case, the number would be 0.05 after stripping off the leading zeros. If the first two characters are in ('C3','C7','C8','','C9','D1','D2','D3'), then the entire value in 3-13 gets multiplied by 0, else 1. If the last character is in ('B', 'D') then the number is negative, else it is positive. So, for this one, the only thing that matters is the initial 'D1', since it renders the value to 0.00, and the rest is moot. 2) C900000017388CD100000000228C This one has two values, C900000017388C and D100000000228C. In both cases, the leading 2 characters of 'C9' and 'D1' render it 0.00, so again the rest is moot. 3) C200000019808CC300000007700CC400000001593C This one has three values C200000019808C, C300000007700C, and C400000001593C. The first value, having characters 1-2 = 'C2' renders it a non-zero value, so the absolute value becomes 77.00, and since the last character is not in ('B','D'), it has a positive value. The second value, having characters 1-2 = 'C3' renders it 0.00, so the rest of it is moot. The third value, having characters 1-2 = 'C4', renders it a non-zero absolute value of 15.93, and the last character of 'C' makes it a possitive value. So, for this one, having three values, I end up with a positive +77.00, 0.00, and +15.93, which are to be summed, so the total value of the one ebcdic string is 92.93. I know it may seem convoluted, but that is the data, so I have to deal with it. A little SQL and a numbers table make light work of dicing it up. And to your point, If the mainframe field is packed decimal with a length of 78, then I know I need to double that for my ebcdic string. So I do use the length function to determine how long it needs to be. Greg
... View more