Heya, all. I'm having a doozy of a problem and am beating my head against the wall. My employer needs me to convert and parse data from a file, and I'm semi-stuck. I had been told the information was simply packed decimal numbers and began the conversions until I noticed really strange trends in the numbers. It would seem that they're really zoned decimals. As such, I'm obviously doing something wrong. Does anyone have code handy to convert the zoned decimal data over to an integer? Thanks in advance!
Theodore Jonathan Casser
SCJP/SCSNI/SCBCD/SCWCD/SCDJWS/SCMAD/SCEA/MCTS/MCPD... and so many more letters than you can shake a stick at!
Thanks, Cindy. I don't know. I feel mildly stupid at the moment, because I'm obviously doing something wrong even with the example in front of me (I only know this because I continue to get nonsense numbers out). The information for each zoned number I'm trying to retrieve is 6 bytes long in storage. From reading the code, I get the feeling I should be looping to have it go byte by byte and reassemble the number into a plain, old base-10 integer... but what I'm getting on the other end almost certainly is wrong. I've enclosed the method I call to convert the number below - I've used the code referred to in the the prior response as the 'backbone', so I've not included it in my listing. As I've said, I'm obviously doing something wrong here....
I appreciate any help anyone can give me. I'm really feeling rather... well, overwhelmed and slow-witted at the moment.
I'll have to take a look at that - I did take a very quick glance when I began the current project and had thought it really not suited for what I'm trying to do, but you might be right in that being the better way to do it. The other aspect, something that really didn't occur to me until Thursday evening (after COB, so I just now have dropped email to the program manager) is that I have no idea what the real data should look like. In essense, I could already be decoding it properly and not realize it. Bah. I'll let you all know what I find and whether or not JTOpen or the earlier code manages to solve the problem, or if I end up having to write my own more detailed solution.
Okay, so I'm back with a new problem with regards to using the JTOpen API. The text functions work great. Everything, in fact, works great... until I get to the numbers. For some strange reason, the numbers are packed into 6 byte clumps. I don't know why - they just are. Trying either AS400PackedBinary or AS400ZonedBinary gives me a NumberFormatException... and I cannot, offhand, think of how to get around this. I'm still toying with ideas, but if anyone has thoughts, I'd appreciate having other opinions.