Using OConv with MP tag

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
vinodlakshmanan
Participant
Posts: 82
Joined: Wed Jul 14, 2004 7:21 am
Location: India

Using OConv with MP tag

Post by vinodlakshmanan »

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
Integrity is what you do when no one is watching
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vinodlakshmanan
Participant
Posts: 82
Joined: Wed Jul 14, 2004 7:21 am
Location: India

Post by vinodlakshmanan »

Hi Ray,

I am not able to view the rest of your post as it is premium content :)
Could you please tell me some way in which we can pack a decimal field?

Regds,
Vinod
Integrity is what you do when no one is watching
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
vinodlakshmanan
Participant
Posts: 82
Joined: Wed Jul 14, 2004 7:21 am
Location: India

Post by vinodlakshmanan »

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.
Integrity is what you do when no one is watching
Post Reply