type conversion/ Transformer stage
Moderators: chulett, rschirm, roy
type conversion/ Transformer stage
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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?
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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.
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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;
}
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;
}