cancel
Showing results for 
Search instead for 
Did you mean: 

to set global variables

0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (1)

Answers (1)

justin_santhanam
Active Contributor
0 Kudos

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.

0 Kudos

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.

justin_santhanam
Active Contributor
0 Kudos

Vikram,

<i>in my scenario the file has to be sent for n number of times and after each transaction</i>

Are u sending files to target system multiple times, and after each transaction u want to decrement am I right? If yes its not possible vikram.

Best regards,

raj.

Former Member
0 Kudos

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

henrique_pinto
Active Contributor
0 Kudos

If you need to have relation between different transactions in the process, you need to use BPM.

Regards,

Henrique.