on 10-09-2007 12:19 PM
Hi Experts,
I need an example UDF using the global variables.
I am new to XI and i have basic doubt of how to store the value and reterieve the value of the Global variable thru the UDF.
I have gone thru the Help.SAP but i am not sure the way to use the statements
void setParameter (String parName, Object obj); and Object getParameter (String parName); to store and retreive the values for the global variables...
So it would be help full if u could provide some example with code....
Hi,
Please refer
http://help.sap.com/saphelp_nw04/helpdata/en/75/8e0f8f3b0c2e4ea5f8d8f9faa9461a/content.htm
/people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14
this is also good...
/people/miguel.jorge/blog/2006/10/10/interesting-use-of-global-variables
/people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14
-
public static String addCounter()
{
GlobalContainer gc = container.getGlobalContainer();
Object o =gc.getParameter("counter");
try{
Integer i;
if(o==null) i = new Integer(0);
else
i = (Integer)o;
i = new Integer(i.intValue() + 1);
gc.setParameter("counter",i);
-
regards,
AKshay.
Reward points if find useful.
Message was edited by:
Akshay Jamgaonkar
null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
See the below example , it suits your requirement.
GlobalContainer - in graphical mapping (XI) - /people/michal.krawczyk2/blog/2005/03/04/globalcontainer--in-graphical-mapping-xi
Chilla
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi saravana,
When the setParameter() method is called, what is being put in the global container memory is a instance of the Object class. Since this is the root class you can set any object into the global container.
For instance if you want to store more than one value, you can add all the values to a Vector object and put this object into the container.
When you get this back, you have to type cast it back to a Vector variable to operate on it.
"In other words you need to pass array of values to the global container."
like declare array of values
-
String[] flintstones = {"Fred", "Wilma", "Pebbles"};
-
AND pass this to the setParameter().
Regards,
Akshay.
Reward points if find useful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
Thanks for your help...
I have another question can we use an array type varible in the global variables?
How can we make use of the array type global variable in the UDF...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Saravana,
You can use global conatiners to get and set the param values. This involves few lines of code
I usually go for 'Edit Java Sections' to declare my global variables. You can find this icon below Design/Test/Messages tab far right.
Declare your gloabl variable string,integer etc. and use it in your UDFs.
Hope it helps. Please let me know if you need any more information.
Regards,
Pritish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
No need of set get parameters , Just use as it is
Global Varibale declaration in Edit java section in Message MAPPING
String gStatus = ""; String gMessage = "";
Using in UDF
public String gMessage(Container container){
//write your code here
return gMessage;
}
Award points if helpful
Regards.,
V.Rangarajan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi saravana
I don't know whats ur initial Global Container Variable Value, Lets assume it as "10" and we will continue.
UDF: Set Initial Global Variable. //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.
Abhishek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.