cancel
Showing results for 
Search instead for 
Did you mean: 

Global Variables in PI

Former Member
0 Kudos

Hi All,
I need some help in understanding the use of global variables in SAP PI.

My scenario is as follows:
Source Message structure
<SMS>
<SMSParameters>
<User/>
<Password/>
<RequestID/>
</SMSParameters>
<SMSMessage>
<DestinationAddr/>
<Text/>
<TransactionId/>
<Priority/>
<SourceAddr/>
</SMSMessage>
</SMS>

Target Message Structure:
User=ABC&Password=DEF&RequestID=90342
<SMSMessage>
<DestinationAddr>ABC&XYZ</DestinationAddr>
<Text>testing</Text>
<TransactionId>4534534</TransactionId>
<Priority>2</Priority>
<SourceAddr>QWE@ZXC</SourceAddr>
</SMSMessage>


Is it possible to read the SMSParameters(User, Password, RequestID) from the Source message as global variables and use them in java mapping to achieve the above target message?

I dont want to use the UDF for this.
Hope im making sense.

Regards,
J

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ,

I'm not sure whether I understood you correctly .Correct me if I misunderstood .

1)Global variables (scope within mapping) ,If you want in graphical mapping then we have graphical variable option(rightclick-->Add variable),if you want to use in java mapping/udf you just need to define a static variable and use it across in that mapping.

2)For using in multiple mappings within an Operation mapping ,you can only dynamic configuration values say FileName,Filesize...

3)For usage in multiple operation mapping then need to go for Look ups.

Regards

Venkat

Former Member
0 Kudos

Hi Venkat,

My scenario - incoming message structure contains - 3 fields - user, password, requestid.

But i dont map them to the outgoing message.

And i somehow need to access these field values in my java mapping.

Static variables are the ones which we define in attributes and methods section of message mapping.i declared 3 variables for user, password, request id.but how do i read the values from incoming message to these variables, and how do i use them in java mapping?

Regards,

J

Former Member
0 Kudos

Hi,

You can easily achieve your requirement by finding the start and end positions using indexOf() fn


Ex:<XYZ>val</XYZ>

Manipulating Characters in a String (The Java&amp;trade; Tutorials &amp;gt; Learning the Java Langua...

Parametrized Java Mapping in PI 7.1 - Process Integration - SCN Wiki

I'm sure you can achieve it .Let me know if you face any trouble.I will share the code based on your requirement.

Regards

Venkat

iaki_vila
Active Contributor
0 Kudos

Hi Janan

Have you checked this document http://scn.sap.com/docs/DOC-58916?, the way to access in java mapping will be similar.

If you want to sharing data between mapping you can use also dynamic configuration: also to use static variables with methods get/set:

Regards.

Former Member
0 Kudos

Hi

I checked the document.

but i guess the version of PI is different from the one we are on(7.11 SP09)

i cannot find the option - Edit Java Sections

Not sure if that is relevant to my scenario

Regards,

J

iaki_vila
Active Contributor
0 Kudos

Hi Jana,

And the option of using static variables inside a java library? (the last option i pointed before)

Regards,

Former Member
0 Kudos

Hi

Im not sure if i understand it completely.

As per my understanding, (correct me if im wrong):

Create static variables for User, password, request id in "Attributes and Methods" section of Message mapping.

How do i read the values from source message into the static variables?

and how do i use them in the java mapping?

Regards,

J

iaki_vila
Active Contributor
0 Kudos

Hi Janan,

Just now i haven't any example to show you how to work with variables.

However, i haven't clear your problem because:

1. You can get payload values in java mapping: com.sap.aii.mapping.api

2. You can set dynamic values with dynamic configuration and to get them in java mapping

Java Mapping of Adapter-Specific Message Attributes - Enterprise Services Repository - SAP Library

Check the code how to set and get values with dynamic configuration

Regards.