cancel
Showing results for 
Search instead for 
Did you mean: 

Global Variable creation

Former Member
0 Kudos

Hi guys,

i have to create two global variables in SAP PI 7.1 EHP1 which i want to use in mapping. I am referring to this blog to test the given scenario.

/people/karthiknarayan.kesavan2/blog/2007/08/22/file-content-conversion-for-multi-hierarchical-structure

Please let me know how can i declare the following global variables in PI 7.1

Map hashMap = new LinkedhashMap();

int cntkey =0;

Thanks

Sahil

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member518917
Participant
0 Kudos

For this ,

Goto Functions tab of message Mapping

Cick Attributes and Method (left pane)

then in Right Pane write your variables

Map hashMap = new LinkedhashMap();

int cntkey =0;

|

Go to UDF and access these variables

Former Member
0 Kudos

Thanks Stefan and Ritu,

I am still getting the error in my UDF as follows.

Source text of object Message Mapping: MM_Intermediate | http://XXXXX.com/ has syntax errors:

Function Populate_recd, Line 4:

cannot find symbol

symbol : method addvalue(java.lang.String)

location: interface com.sap.aii.mappingtool.tf7.rt.ResultList

result.addvalue((String)hashMap.get((String)it.next()));

i have defined the below variables in Attrubue and methods.

Map hashMap = new LinkedhashMap();

int cntkey =0;

Kinldy help me with this.

regards

Sahil

stefan_grube
Active Contributor
0 Kudos

> Kinldy help me with this.

In Java it makes a differences, if you use a capital letters or not, so

addvalue <> addValue

Check your source that the spelling of your code is exactly the same, including all capital letters.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

> cannot find symbol

symbol : method addvalue(java.lang.String)

location: interface com.sap.aii.mappingtool.tf7.rt.ResultList

result.addvalue((String)hashMap.get((String)it.next()));

Check the method name signature.. Since java language is case sensitive you have to define exactly same everywhere

method name: addValue

Former Member
0 Kudos

Hi,

just change this statement in your UDF from

result.addvalue((String)hashMap.get((String)it.next()));

to

result.addValue((String)hashMap.get((String)it.next()));

and it will work.

Java is case sensitive and hence cannot call the addValue method correctly from your UDF.

I hope this helps.

Regards, Gaurav.

Former Member
0 Kudos

Thanks gaurav

stefan_grube
Active Contributor
0 Kudos

> Please let me know how can i declare the following global variables in PI 7.1

>

> Map hashMap = new LinkedhashMap();

> int cntkey =0;

In PI 7.1 you choose tab function and put the code in section Attributes and Methods.

Don't get confused with the new variables in graphical mapping. This has nothing to do with it.

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

refer below blog..

/people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable

Regards,

Raj

Former Member
0 Kudos

Hi,

I have refferd the blog but i do i pass values to the variable..

I have to define like this.

Map hashMap = new LinkedhashMap();

int cntkey =0;

please let me know how i can acheive this.

Sahil

Former Member
0 Kudos

Hi,

In PI 7.1 graphial variables are used as substitute for global variable.

graphical variable only works within the mapping session. It's similiar like global container.

However if you want to have real global variable that is valid across mapping session, (like it's valid from message to message), you can define static data member in a java class, then use the java class in your UDF by using the static data memeber as real global variable.

refer below discussion,

Link: [;

Regards

Amol