cancel
Showing results for 
Search instead for 
Did you mean: 

How to read container variable in UDF

0 Kudos

Hello expert,

I have created a container variable(var_callerId) in an integrationprocess.

In a mapping I want to read the container variable with an UDF.

Can anyone send me the code for the UDF please ?

I can't find the solution in any post message / blog.

Thx for your help!

Best regards,

Juergen

Accepted Solutions (0)

Answers (4)

Answers (4)

SudhirT
Active Contributor
0 Kudos

Hi Jurgen,

You can always use Global container for that. What you need to do is just create an object of globalContainer type. and then just set the parameter like sessionID and callerID for that object and use these parameter wherever you want by directly mapping to particular field as explained below

GlobalContainer global;

global = container.getGlobalContainer( );

SET Global

String globalParameterObject = new String(""); container.getGlobalContainer ().setParameter ("SID/CID",global); return "";

GET Global

String global = (String) container.getGlobalContainer().getParameter ("SID/CID");

container.getGlobalContainer ().setParameter ("SID/CID",global);

return feld;

Try this , I hope it shud work. Thanks!

0 Kudos

Hello Sudhir,

thanks very much for your help!

Is SID/CID the var_callerID (designed in my integrationprocess) ?

I don't unterstand : return feld

What is feld? (I think this should be another variable, I have modified the code, but without success

Best regards,

Juergen

Former Member
0 Kudos

Hi,

####### Write value to GlobalContainer ##################
public String setRefNr_ORIGIN(String value,Container container){
************************************************
//caches value USCHI in GC
container.getGlobalContainer ().setParameter ("USCHI",value);
return "";
####### Read value from GlobalContainer ##################
public String getRefNr_ORIGIN(Container container){
***************************************
return (String) container.getGlobalContainer().getParameter ("USCHI");

0 Kudos

Hello Mario,

thanks very much for your help!

I don't understand where you use the container variable "var_callerID" (designed in the integration process)?

Best regards

Juergen

SudhirT
Active Contributor
0 Kudos

Hi Jurgen,

Check out this discussion thread on same topic,

0 Kudos

Hi Sudhir,

thx very much for your answer. Your link was very informative.

I solve the problem with interface-mappings. I've created a new interface, which store the information and at the end I mapped it to the output interface. This solution works fine.

In your answer there was an interesting link for the subject "Container variable and mapping" but unfortunately it doesn't work.

There was written that I can use a container variable direct in a mapping to map it to a data field. I don't know how to do this. Do you know this?

Best regards,

Juergen

Former Member
0 Kudos

Hi,

I dont think that you can use or read the container veriable defined at IP in your UDF.these verible can only be filled using the container opretion in IP.

but in UDF you can define your set of container veriable and use them.

here you can define two type if containe veriable

1) globle container veriable

2)simple container veriable.

to define the container veriable you can use

the following code

GlobalContainer globalContainer;

globalContainer = container.getGlobalContainer( );

sap provided 2 method to set the parameter and to read the set value from these container veriable

1)void setParameter (String parName, Object obj);

2)Object getParameter(String parName);

similar method can be used for defining the simple container veriable.

regards,

navneet

0 Kudos

Hi navneet,

thanks for your fast reply.

Let me explain why I wanted to use container variables:

(Perhaps there is a better way to fix the requirement)

I've following IP

Message Interface (input)

<getData>

<callerInfo>

<callerID>SYSA</callerID>

<SessionID>43545455545355</SessionID>

<number>3434344334</number>

</callerInfo>

</getData>

Then I have a mapping (<number>) to call a webservice.

I get the data from the webservice.

At last I will send the data back to the business System.

But I need the both tags from the input interface (SessionID, callerID) again, to send it back.

I tried a mapping to map sessionID and callerID from the input interface to the output interface, but it doesn't work.

So I thought I can store the sessionID and callerID in a container variable and in a mapping I will get it back with an UDF.

I think there should be a possiblility to get the stored value from the container variable inside the IP. But I don't find any solution.

I don't understand your solution with the global container. How can I access to the container variable(IP).

Thx for your help

Best regards

Juergen