cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for storing and retrieving data in global variable

Former Member
0 Kudos

Hi Guys,

              I have a requirement to extract data, storing it in a global variable and retrieving the same after a synchronous call.

I am using this mapping in BPM.

anyone have a suggestion on this. Code snippet will be great.

Thanks

Sam

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member201264
Active Contributor
0 Kudos

Hi,

Check this thresd.

http://scn.sap.com/thread/3256578

Regards,

Sreeni.

Former Member
0 Kudos

Hi please find an example below.The container variable can be accessed in other UDFs

public String getValue(String a, Container container) throws StreamTransformationException{

AbstractTrace trace=container.getTrace();

String test="";

GlobalContainer globalContainer;

globalContainer = container.getGlobalContainer();

String inlogin_sess =  " ashutosh test value" ;

globalContainer.setParameter(test,inlogin_sess);

test=""+globalContainer.getParameter(test);

trace.addInfo("c dis"+test);

return test ;

}

We can access the container variable in other udfs of same mapping using getParameter

Former Member
0 Kudos

Hi,

      I am using the global variable to store and retrieve the data in message mapping..

Here is my code.

To store..

DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey keySource = DynamicConfigurationKey.create("http://test.com/test/nl","RequestValue");

if (conf != null) {

conf.put(keySource, var1);

}

return var1;

To Retrieve

DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey keySource = DynamicConfigurationKey.create("http://test.com/test/nl","RequestValue");

return conf.get(keySource);

I am hoping this should work inside BPM..?!

Cheers

Sam

Former Member
0 Kudos

Hi,

Please check this link also for alternate solution to store the values in global variables in library:

http://scn.sap.com/people/carlosivan.prietorubio/blog/2009/12/29/sharing-data-between-message-mappin...

Also check this link: http://scn.sap.com/community/pi-and-soa-middleware/blog/2010/03/04/usage-of-dynamic-configuration-in...

Regards,

Beena.

Former Member
0 Kudos

Dear Sam,

I'm using your UDF for storing a variable in message mapping, it works well for short texts, but when I try to send to it a long text such as a PDF encoded in base64 the mapping fails.

any idea why ?

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Zevik,


I'm using your UDF for storing a variable in message mapping, it works well for short texts, but when I try to send to it a long text such as a PDF encoded in base64 the mapping fails.

any idea why ?

That is because dynamic config is limited to 200 characters only.

Regards,

Mark

engswee
Active Contributor
0 Kudos

Mark, is the limit documented somewhere?

markangelo_dihiansan
Active Contributor
0 Kudos

No, it is undocumented. It has been there since XI 3.0 e.g DC for URL is 200 characters.

engswee
Active Contributor
0 Kudos

Thanks Mark. Never had to store such a long value in DC but good to know that there is such a limit!

Former Member
0 Kudos

Hi Mark,

Thank you for your answer.

Any suggestion on how to preform this task in another way ?

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Zevik,

In BPM you use a multi-mapping , in one of the message types stored the value there.

Regards,

Mark

Former Member
0 Kudos

Hi Mark,

I've done this before in BPM a long time ago, but i'm finding it difficult reproducing it now, do u have a link to any blog/post/wiki as an example for multi mapping in BPM when source is an IDOC and target is 2 MT's  ?