Hi,
Can we use OCONV with MP tag to write packed decimal data to the output? The help says that the MP tag also unpacks the data for output, so I got confused.
Thanks,
Vinod
Using OConv with MP tag
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 82
- Joined: Wed Jul 14, 2004 7:21 am
- Location: India
Using OConv with MP tag
Integrity is what you do when no one is watching
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Curiously this works the other way around to what you might expect from the other conversions.
Oconv(42,"MP") returns the characters of 42 (that is, "4" and "2") represented as byte values in hexadecimal, namely "34" and "32" (the ASCII code for "4" is 52 and the ASCII code for "2" is 50).
Iconv(3432, "MP") would therefore return "42".
Iconv(42, "MP") will return "B", since the ASCII code for "B" is 66, which is 42 in hexadecimal.
Hope this makes things clearer.
Oconv(42,"MP") returns the characters of 42 (that is, "4" and "2") represented as byte values in hexadecimal, namely "34" and "32" (the ASCII code for "4" is 52 and the ASCII code for "2" is 50).
Iconv(3432, "MP") would therefore return "42".
Iconv(42, "MP") will return "B", since the ASCII code for "B" is 66, which is 42 in hexadecimal.
Hope this makes things clearer.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 82
- Joined: Wed Jul 14, 2004 7:21 am
- Location: India
Vinod - the non-premium part is enough; have you actually gone and tried the MP conversion with ICONV and OCONV? All you need to do is create a test routine in the Manager; shouldn't take more than 60 seconds including compile and run. You can try both OCONV and ICONV and actually see what the output is.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Take a look at the SDK routines for converting COMP data types, then try to reverse their logic. It will be slightly different depending on whether you are processing signed values and on the number of decimal places.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 82
- Joined: Wed Jul 14, 2004 7:21 am
- Location: India
I have tried using OCONV with MP tag, but it converts it to hex. For e.g. if I give OCONV(1234,"MP"), I get "31323334" in my output file (hex values of 1234).
I havent tried ICONV, as the help says it converts data into internal format. I will try it.
As for the routines, there is a DataComp3Unsigned (or a routine of a similar name) to convert packed decimal into integer. It uses OCONV with the MP tag.
I havent tried ICONV, as the help says it converts data into internal format. I will try it.
As for the routines, there is a DataComp3Unsigned (or a routine of a similar name) to convert packed decimal into integer. It uses OCONV with the MP tag.
Integrity is what you do when no one is watching