cancel
Showing results for 
Search instead for 
Did you mean: 

How to store a variable using user defined function even after end of the session (after clean up)

Former Member
0 Kudos

Hi Everyone,

Can anyone please answer this?

How to store a variable (need not be global) using User Defined Functions even after the end of the session.

I've tried using GlobalContainer class, creating a variable at the beginning (i.e, in Attributes and Methods) and Importing a Java class from a jar file.

nothing works. Searched entire internet, but couldn't find anything related.

Please kindly help.

Accepted Solutions (0)

Answers (2)

Answers (2)

konrad_thalheim3
Active Participant
0 Kudos

What kind of variable values do you want to store?

Maybe you can try to update a table with value mapping replication interface to your PO cache.

Former Member
0 Kudos

Thanks for the response Mr. Konrad.

I'd like to store a String which is a data in particular field of an xml.

Which I'll use it to compare with the same field of the same data type but in a different iteration. If the data in the field changes, then the new data (String) replaces the old and this new data should be stored this time.

I'm completely new to SAP but good at java. Please correct me if my approach is wrong.

Thank you

engswee
Active Contributor
0 Kudos

Can you elaborate your intention for storing such a persistent value? How will it be used after mapping completes?

Former Member
0 Kudos

Thanks for the response. I need to compare a field which is in already generated xml (output file) with the one I'm going to process now. My approach is that storing the field's value (String) in a variable when the 1st iteration pass and comparing it with the field in the 2nd iteration. But clean up method in UDF is not letting me do that.

I'm completely new to SAP, but good at java. So please correct me if my approach is wrong.

Thank you

engswee
Active Contributor
0 Kudos

Even in Java programming outside of SAP products, you cannot access the value of a variable of a previous execution during the next execution.

You will need some persistent approach to store this and GlobalContainer does not provide this. One option of persisting the value would be to store it in a custom table, if you are on single stack PI/PO, then you can store it in a Java dictionary table as detailed in the blog below.

However, storing persistent value will cause your mapping to have side effects and you should have a read on the following blog as to why that is not a good idea.

You might want to revisit the reason for the need to perform such comparison on different iterations. This is not a common requirement.

Former Member
0 Kudos

Thank you Eng Swee Yeoh

What you have suggested is absolutely right. There will be side effects.

But now can you please tell if I can atleast share data between Two message mappings?. I've followed up a lot of blogs. Nothing was helpful.

Thank you