cancel
Showing results for 
Search instead for 
Did you mean: 

Global Container

Former Member
0 Kudos

Hi all,

I am trying to understand the concept of Global Container.

i have referred to the following blog by Michal

<a href="/people/michal.krawczyk2/blog/2005/03/04/globalcontainer--in-graphical-mapping-xi:///people/michal.krawczyk2/blog/2005/03/04/globalcontainer--in-graphical-mapping-xi

I have created the Second UDF 'getContainer'.

But, while testing I am getting the following error:

RuntimeException in Message-Mapping transformation: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._MM_TEST_IN_ method getContainer$[]

Code that i am writing in getContainer is as follows:

<b>GlobalContainer globalContainer = container.getGlobalContainer();

String[] b = (String[]) globalContainer.getParameter("our_number");

for (int i=0; i<b.length; i++)

{

result.addValue(b<i>);

}</b>

getContainer function does not have any input parameters.

Kindly, provide me some guidance about where am I getting wrong.

Thanks & Regards,

Nilima Rodrigues

Accepted Solutions (1)

Accepted Solutions (1)

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Nilima,

Try like this for UDF getContainer

GlobalContainer globalContainer = container.getGlobalContainer();

String[] b = (String[]) globalContainer.getParameter("our_number");

if( (b != null) ) {

for (int i=0; i<b.length; i++)

{

result.addValue(b);

}

This should work, Else reply again

regards,

sridhar

Former Member
0 Kudos

Hi Sridhar,

I used the same piece of code provided by you.

Now, I am not getting any error during testing.But still I am unable to get the desired result.

As specified in Michal's blog, I want to display the Numbers between given range of 'FROM' AND 'TO'.

My first UDF(setContainer) works perfectly and creates appropriate context for DEST_LINE.

But getContainer is still not working.

Awaiting for your reply.

Thanks & Regards,

Nilima Rodrigues

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Nilima,

Hi Nilima,

//write your code here

GlobalContainer globalContainer1 = container.getGlobalContainer();

String[] b = (String[]) globalContainer1.getParameter("our_number");

String str_result = "";

if( (b != null) ) {

int a1 = Integer.parseInt(b[0]);

int cnt = Integer.parseInt(counter);

int ans = a1;

str_result = String.valueOf(ans);

}

return str_result;

Note counter is a arguement for value based...

Map Now like this

use COUNTER standard function --> UDF getContainer --> then target field..

this will work..

regards,

sridhar

Message was edited by:

sridhar reddy kondam

Former Member
0 Kudos

Hi Nilima,

Please check wether you are calling setContainer UDF before getdata UDF .

to test you can do one thing - in the same mapping node call both UDfs

From to ---> setcontainer UDF -> getContainer UDF - > target map node .

It should work .

Nanda

RKothari
Contributor
0 Kudos

Hi Nilima,

getContainer calls for values which are already present in container , set by ur first UDF(setContainer). When you check the display queue, the getContainer will throw null pointer exception as setContainer has set no value in container. So, try executing the complete scenerio or test the mapping with the UDF what Sridhar has suggested.

Hope it would work.

Regards,

Rahul

Answers (2)

Answers (2)

Former Member
0 Kudos

Nilima,

>>getContainer function does not have any input parameters

u mean to say ur not passing any parameters to this function but I suppose Container is one of the default argument to this function .

Can u place this function before ur setContainer ( for testing purpose)

ur resultset in the above case will contain NULL but if there is no exception

MichalKrawczyk
Active Contributor
0 Kudos

hi Nilma,

do you have SP14 (XI)?

if so you can try using global variables

/people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14

they are much easier to use then globalcontainer

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>