type conversion/ Transformer stage

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
kavuri
Premium Member
Premium Member
Posts: 161
Joined: Mon Apr 16, 2007 2:56 pm

type conversion/ Transformer stage

Post by kavuri »

Hi,
I am having some problem in Transformer stage. I am having a 64 bit integer is there in my input side. I need to derive a string from that. But the string should have a max length is 12 characters.

Now what I need to do is,

Plan :
1. Convert bigint into 64bit string.
2. Take 10 6-bit strings and one 4 bit string.
3. I am having a lookup table where I will find equivalant character for every 6bit string.
4. So I can make up 11char string.

For this situation How can I approach? Please tell me what are all stages I need to use. If I need to incorporate C++ code How and where I need to incorporate.

Your comments are most appreciated.

Thanks
Kavuri
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

string[12] is not sufficient to store all int64 values.

Can you be more precise about what you are attempting to achieve, in particular what is supposed to happen if the BigInt contains more than 12 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.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Kavuri,

I'm not sure what you are trying to achieve. Do you intend to do a lossless compression of the integer value into a length 12 string? In that case it makes more sense to keep the original 8-bytes and leave them into a fixed 8-byte length string with no conversion (i.e. RAW). Or build up your string using 8-bit chunks from the converted integer and get the equivalent ASCII character by using the SEQ() function.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

By creating either a parallel routine or a Build stage and coding it in C++.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kavuri
Premium Member
Premium Member
Posts: 161
Joined: Mon Apr 16, 2007 2:56 pm

Post by kavuri »

Hi Ray,
can you tell me more specific where to write and how to compile and incorporate it to use with in Transformer stage. I think, here I need to pass a bigint value to the routine as an argument. is this somewhere in the command prompt I need to write the routine? or Can I write somewhere in dataStage client tool?

Thanks
Kavuri
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You create the routine outside of DataStage. You compile and link it outside of DataStage. Then, within DataStage, you create a "new parallel routine", which is actually an entry in the Repository that tells DataStage where to find your routine and with what arguments it needs to be called.

Your alternative, to keep it within DataStage, is to create a new stage (a Build stage), where you put the code into the stage directly.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kavuri
Premium Member
Premium Member
Posts: 161
Joined: Mon Apr 16, 2007 2:56 pm

Post by kavuri »

Hi ray,
I am keep on trials with C routine, at the same time I would like to know how can I make a build stage? If you can give me some hint so that I can do it or otherwise if you have some link for this material please send me I appreciate it.

Thanks
Kavuri
kavuri
Premium Member
Premium Member
Posts: 161
Joined: Mon Apr 16, 2007 2:56 pm

Post by kavuri »

Hi ray,
I found some information in advanced developers guide. Ok I will go ahead with it and If at all I found any difficulty I will post again.

Thanks
Kavuri
kavuri
Premium Member
Premium Member
Posts: 161
Joined: Mon Apr 16, 2007 2:56 pm

Post by kavuri »

Hi,
I worked out with C program its running fine. Now can you tell me what should I do to include it in the routines.
One more thing the program what I had written consisting of a main() function , I think I need to include only object file without main. can anybody tell me how to create an object file without main? and also how to pass the parameter from the datastage? etc.

here below I am giving total code what I had written.

Thanks
Kavuri

#include<stdio.h>
#include<iostream.h>
#include<stdlib.h>
char Convert(int);
int main()
{
long long Value = 6732123;
int part = 0;
char strOut[12] = {0};
for(int i = 0; i < 11; i++)
{
//printf("%d \n", sizeof(Value));
//printf("%d \n", sizeof(part));
part = (int)(Value & 0x3F);
Value = Value >> 6;
//printf("Value = %d \n", Value);
//printf("Part = %d \n", part);
//printf("%d \n", sizeof(part));
strOut[10 - i] = Convert(part);
//printf("String Value = %s \n", strOut);
}
strOut[11] = '\0';
printf("String Value = %s \n", strOut);
return 0;
}
char Convert(int nPart)
{
char chCode = ' ';
switch(nPart)
{
case 0 :
chCode = '*';
break;

case 1 :
chCode = '+';
break;

case 2 :
chCode = ',';
break;
.
.
.
.
. other cases included.
.
.
.
.
case 60 :
chCode = 'f';
break;

case 61 :
chCode = 'g';
break;

case 62 :
chCode = 'h';
break;

case 63 :
chCode = 'i';
break;

default:
chCode = '$';
// break;
}
return chCode;
}
Post Reply