cancel
Showing results for 
Search instead for 
Did you mean: 

GlobalContainer object values acessed among UDF's in message mapping ?

former_member192079
Participant
0 Kudos

hi

i have scenario where i am using globalContainer variable functionality in my message mapping.

in edit java section

String usr;

Container container ;

GlobalContainer globalContainer ;

intialize usr = "";

in First UDF

 
String inlogin_sess =  " ashutosh test value" ;

globalContainer.setParameter(usr,inlogin_sess);
return any value :

now if i create another 2nd UDF and use :

String out =globalContainer.getParameter(usr);

return out ;

now 2nd UDF is giving null pointer exception...

for testing the code functionality..

IF i use the SET and GET in 1st UDF :

globalContainer.getParameter(usr); in 1st UDF than it is working sucessfully...

 
globalContainer.setParameter(usr,inlogin_sess);
String  out = globalContainer.getParameter(usr);
return out ;

in help.sap it is mentioned that Globalcontainer objects values can be fetched among UDF's in one message mapping....

[http://help.sap.com/saphelp_nw04/helpdata/en/0f/80243b4a66ae0ce10000000a11402f/frameset.htm]

i have gone a lot of thread in sdn where Global container are used like sequence no creation etc, but every where the

GET and SET are used in SAME UDF...

any clue where is leak..

Regards,

ashutosh R

Accepted Solutions (1)

Accepted Solutions (1)

former_member181962
Active Contributor
0 Kudos

Are you sure f the usr has the same value in the set and get parameter statements?

Regards,

Ravi

former_member192079
Participant
0 Kudos

Hi Ravi

As i mentioned if i include the Set and Get method ,in the 1st UDF

the GET is fetching the value....sucessfully.

 
globalContainer.setParameter(usr,inlogin_sess);
result.addValue(globalContainer.getParameter(usr));  

for confirming whether my code syntex..sementics is ok or not..

the point is that my globalcontainer object is loosing its refrence outside the UDF..which it should not..

Regards

AshutoshR

former_member181962
Active Contributor
0 Kudos

Hi Ashutosh,

Just try this small test.

pass some value to your USR value before you use the set parameter.

and use the same value in your get parameter function.

I have tested this in my system and it is working perfectly as expected.

Regards,

Ravi

former_member192079
Participant
0 Kudos

Hi Ravi

I have tested this in my system and it is working perfectly as expected.

are u using both methods in 1 udf or seperately...

because for me also

 
globalContainer.setParameter(usr,inlogin_sess);

result.addValue(globalContainer.getParameter(usr));

is returning sucessfully value... if both are in 1 UDF

BUT

are these 2 code line can be executed in different UDF's..

udf1 and udf2.. as what globalcontainer concept says....check if i am wrong..

i tried u r test , i cou'dt got u...

i have declared global object in UDF only....

GlobalContainer globalContainer = container.getGlobalContainer();

have u executed it in Edit java -> section....?

regards

Ashutoshr

Answers (3)

Answers (3)

former_member192079
Participant
0 Kudos

Hi all

the global object decelaration object has to be done in both UDF's...

Than it is working..

But i did'nt got the logic why to intialize the object 2 times..

Thanks a lot Ravi abhisek..for u r inputs...

Regards

AshutoshR

ashutosh.rawat83atgmail.com

Former Member
0 Kudos

Hi,

That is then the error.

Please Do the Following

GlobalContainer Gb = container.GetGlobalContainer();

This container you would get as a paramter of your UDF

and then use this variable GB as the Global container.

Remember a Gloabal container is Global for a Message mapping, does not need to be defined as Global variable

Let me know if this helped.

Rewards Points if useful

Regards,

Abhishek

former_member192079
Participant
0 Kudos

Hi

in my 1st UDF..

the

 
GlobalContainer globalContainer = container.getGlobalContainer();
globalContainer.setParameter(usr,inlogin_sess);  

the object globalContainer is of global container only.....

that's what i mention it , still it working as LOCAL to UDF1

Regards

AshutoshR

Former Member
0 Kudos

Hi Aushotosh,

Onr point to be remebered whilr using the the Global Container is that, you Should always know the order in which the mapping is exceuted.

It is always the order of the Target Strcuture which is imopratnt.

Typically in case of Global containers you should be sure that the value you buffer is not used in a sequence before.

I think this is the issue in your case.

Reward points if useful

Regards,

Abhishek

former_member192079
Participant
0 Kudos

Hi Abhishek

Your point is legimate, but for my their is no such issue..

even i try to use it as :see image..

[http://www.screenshots.cc/show.php/14137_GlobalVariable.JPG.html]

UDF1 :

 
globalContainer.setParameter(usr,inlogin_sess); 
return any value :

and in UDF2

 
String  out = globalContainer.getParameter(usr);
return out ;

mainting the sequence

My concern is object globalContainer is local in UDF1, so it will through nullpointer ,if we try to access in UDF2.

if we declare globalContainer in edit jave -GlobalVariables also, still it is having the error..

Regards

AshutoshR