Page 1 of 1

Call java code in datastage

Posted: Fri Jul 03, 2009 7:14 am
by prasson_ibm
Hi,
I have a java code with name Sum.java

code:-
class Sum1
{
int RetSum(int a1 , int a2)
{
return a1+a2;
}
}

class Sum
{
public static void main(String args[])
{
Sum1 a=new Sum1();
System.out.println(a.RetSum(10,20));
}
}

when i coplied this code it generates two class files
Sum.class and Sum1.class

I want to call this code in transformer.
Is it possible to do this,if it is please help me how to do ..??

Regards

Posted: Fri Jul 03, 2009 7:34 am
by chulett
It's not as far as I know. There is a Java PACK that will allow you to do things like this but it is a option you need to purchase. Perhaps with a build-op? :?

Posted: Fri Jul 03, 2009 7:38 am
by prasson_ibm
chulett wrote:It's not as far as I know. There is a Java PACK that will allow you to do things like this but it is a option you need to purchase. Perhaps with a build-op? :?
Hi Chulett Thanks for ur reply,Ok but i dont know how to use buildup stage,can u please help me writing this code in buildup stage and exec..???

Posted: Fri Jul 03, 2009 7:40 am
by chulett
Nope, sorry, can't... don't have that particular skill set.

Posted: Fri Jul 03, 2009 7:45 am
by ArndW
1. Write a c program. Here's one I use:

Code: Select all

#include <stdlib.h>
#include <stdio.h>

char * AwHelloWorld(char * InString)
{
char* OutStr;
OutStr="Hello World!";
return OutStr;
}
2. Compile the code, on AIX I use "/usr/vacpp/bin/xlC_r -O -c HelloWorld.cpp"
3. Link the code, on AIX I use "/usr/vacpp/bin/xlC_r -O -G HelloWorld.o -o HelloWorld.o"
4. In the designer, create a parallel routine. Define it with the correct entrypoint (AwHelloWorld), as an object and with the correct parameter(s) and return type. Also use the correct full path to the HelloWorld.o file.
5. Create a job with a transform stage and call up the routine.
6. Bob's your uncle :)