on 07-14-2007 7:57 AM
Hi All,
In my scenario I am using a global variable wherein i ahve to subtract a source field value from the global variable and set the global variable to that value.also return the same value.
How can i do it?Can any one help me writing the source code(UDF).
regards,
Vikram
Hi Karanam,
you can define global variables in message mapping.
Below Design/Test/Messagest tabs, we have some icons.
click on the right most icon (Edit Java Sections).
Here you can declare your global variables.
for ex String b;
below that you can initialize the variable like
b= "2";
and you can use this in your UDF.
for example if you say " return b; " in your UDF, it will return the value of b.
if you want to modify the value of b using the UDF as well.
for example, if you write,
b = "aaa" + b;
return b ;
it will return "aaa2".
dont forget to award points
Regards
Pushkar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Karanam,
I don't know whats ur initial Global Container Variable Value, Lets assume it as "10" and we will continue.
UDF:<b> Set Initial Global Variable.</b> //No Input parameters, map this UDF to root node of target
GlobalContainer gc= container.getGlobalContainer();
gc.setParameter("MyValue","10");
UDF: For your any target node u want to subtract.//No Input parameters
GlobalContainer gc= container.getGlobalContainer();
Integer local= Integer.parseInt(gc.getParameter("MyValue"));
int node_subtract = (int) local -2;
String setgc ="node_Subtract";
gc.setParameter("MyValue",setgc);
return ""node_subtract"";
Hope it helps!! Since the above code is not compiled, I just wrote in the fly u might get some object conversion-I think. But the logic is correct, repl back if u hav any queries.
Best regards.
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This helped me to some extent.
But i want to check the global variable once the value of that variable has been set.
in my scenario the file has to be sent for n number of times and after each transaction the global variable has to be set to a new value i.e,
(Global variable - a source filed value)
where the value of the global variable is the value set during last transaction.
Hope you understood my requirement.
Regards,
vikram.
Hi,
I can suggest you some unconventional ways of doing this.
you can store this value in some table on abap stack of XI.
In your mapping you can write a udf to do a JDBC to fetch the value and update the value directly.
Else,
you can also create a fn module which in has an input and output parameter.
you can pass the input value to update the filed and export to get the value of that field..
I mean you can do whatever you want
and call that in your UDF to return that value.
Regards
Pushkar
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.