compacted ascii data

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
przytula
Participant
Posts: 27
Joined: Wed Apr 14, 2004 1:31 am
Location: Brussels Belgium
Contact:

compacted ascii data

Post by przytula »

Any idea how to handle in a routine compacted ascii data read from a file
digits are represented in half bytes
I want to convert these digits to real digits
Thanks for all help/info
Best Regards, Guy Przytula
Best Regards, Guy Przytula
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi,
Is it a packed decimal??

regards
kumar
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Hello Guy,

as Kumar has pointed out, this is in actuality a packed data type. There are a number of builtin routines in DataStage that can convert to and from these data types. You will need to find out if the datatype is signed or not, as this affects how to unpack the data. Once you know your data you can apply the routines in transform derivations to get a useable number from the packed strings.
przytula
Participant
Posts: 27
Joined: Wed Apr 14, 2004 1:31 am
Location: Brussels Belgium
Contact:

compacted ascii data

Post by przytula »

it is not decimal just unsigned numbers. these are not amounts, and I don't know why they used this type of data to save this flags
like : 14325678
where 1 means : next field is xxx
4 means : xxx and so on
it is a group of switches
can these translations be applied in a routine ?
because we want to create a fixed flat file from this varying format before moving the data on.
I think a transformer stage would be to complicated to handle all these conditions, that is why the routine.
Thanks for all info
Best Regards, Guy Przytula
Best Regards, Guy Przytula
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Guy,

You can still interpret these "switches" as if they were unsigned numbers, one character at a time using the SDK routines.

I don't have DS running now so I can't do a quick example, but you can interpret this information for yourself. There are various ways to do this. If you were to take SEQ(In.Yourstring[1,1]) you would get a number that you could apply binary-level math on, or just convert it into it's binary representation using ICONV(In.YourString[1,1],'MB0C'), then take the left nibble and re-convert it into a number using OCONV(Nibble1,'MB'). I am not sure about the ICONV/OCONV and codes as I always get them confused, but you could also look at the source code in a SDK portion of the routines for some examples (look at the COBOL data type conversions). The BASIC manual will also explain the 'MB' conversion code. BASIC itself will also allow you to do binary operations on the strings. I think if you were to do an OR operation on your single character with 127 and then a shift right of 128 you would get the same result.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If it's two hex digits per byte, you might also investigate the "MX0C" conversion with Oconv() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
przytula
Participant
Posts: 27
Joined: Wed Apr 14, 2004 1:31 am
Location: Brussels Belgium
Contact:

compacted ascii data

Post by przytula »

I used the technique with
InString = OCONV(FByte,'MB0C')
F1 = ICONV(InString[1,4],'MB')
F2 = ICONV(InString[5,4],'MB')
or with
Ans = OCONV(FByte,'MP')

in both cases, this is correctly done, but not correctly if input keeps the digit 9 or 0
eg.
half 12345678 --> converted is correct as real 12345678
but having 1234567890 or
90 returns in binary translation 111011111011111110111101 for which we expect only 10010000
Any comment on this, or are we missing something
Thanks for all info
Best Regards, Guy Przytula
Best Regards, Guy Przytula
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Eight hex digits represents a four-byte quantity, such as Integer. Once you go beyond eight hex digits the next larger quantity, such as BigInt, must be inferred. 1234567890 contains ten digits.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply