on 05-23-2007 9:28 AM
Hi All,
In a scenario, we are using a Global container.
we are using setParameter and getParameter methods to set and get values from the Global Container.
The problem we are facing is that although we are setting the value for a parameter before getting it but it always returns "null".
Please find attached the code:
SetVar:
GlobalContainer myGlobalContainer;
myGlobalContainer = container.getGlobalContainer();
myGlobalContainer.setParameter(b.toUpperCase(), a);
return a;
GetVar:
GlobalContainer myGlobalContainer;
myGlobalContainer = container.getGlobalContainer();
if (myGlobalContainer.getParameter(a) == null) {
return "";
}
else {
return (String)myGlobalContainer.getParameter(a.toUpperCase());
}
We have also tried putting the string value excplicitly in "" but of no use.
We also read the blog by Michael but i think the problem is a little different.
If any body can help us with where to look for Global Container related errors, it would be of great help.
Regards,
Varun Joshi
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Varun,
The Signature of setParameter() is,
void
setParameter
(String parName, Object obj);
Taking this into account,
GlobalContainer myGlobalContainer;
myGlobalContainer = container.getGlobalContainer();
myGlobalContainer.setParameter(b.toUpperCase(), a);
return a;
In this method you are settting parameter b with value a.
But, in the get
GlobalContainer myGlobalContainer;
myGlobalContainer = container.getGlobalContainer();
if (myGlobalContainer.getParameter(a) == null) {
return "";
}
else {
return (String)myGlobalContainer.getParameter(a.toUpperCase());
}
You are trying to use get(a) when it should be get(b).
Regards
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Varun,
In your declaration change the statement to
myGlobalContainer.setParameter(<b>a,b.toUpperCase()</b>);
Anil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Varun,
Do not use Global Containers. You have a better option in terms of the JAVA Section in the message mapping that does the same and are simpler to use.
More in this blog,
/people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14
Regards
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bhavesh,
We have read that blog.
yes, that indeed is an option.
But one issue is, that the setParameter method is being called under a Java User defined function. And that function is being used at many places.
If we use a global variable, then we may either have to use lot of them or we may have to use a key value pair type user defined data type.
We do have that option on the back of our minds but we first want to look for a workaround for the present condition.
Regards,
Varun
Varun,
><i>If we use a global variable, then we may either have to use lot of them or we may have to use a key value pair type user defined data type.</i>
Not sure I understood this. You can define a Array, a vector, a hashmap andything you want in the Global Variables of the Java Section.
><i>We do have that option on the back of our minds but we first want to look for a workaround for the present condition.</i>
Actually using the Global Variables in the Java Section wil provide a better perfromance as you are avoiding multiple calls to the Container Object.
Regards
Bhavesh
Hey Bhavesh,
we tried using global variables and now we have another issue on our hands.
When in a user defined java function we assign the Global Variable another value
and call the global variable in another node mapping below, it takes the initial value
for that Global Variable.
Whereas we need the changed value here.
Any ideas?
Regards,
Varun
User | Count |
---|---|
89 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.