cancel
Showing results for 
Search instead for 
Did you mean: 

Message mapping using system variables

former_member201275
Active Contributor
0 Kudos

On the ESB in Message Mappings I am moving a Constant value to USERID field e.g. USR01. This is the user we want for Dev, however on Quality system we want to use userid USR02, and on Production USR03.

My question is how do we cater for this in the Message Mapping section of ESB? Bear in mind that none of the other fields in our structure contain the system details. Are there system variables we can use, like in ABAP? If so, then how?

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Glen,

No need for UDF, just use mapping parameters (string category) and enter the value in integration directory.

Regards,

Mark

former_member201275
Active Contributor
0 Kudos

Hi Mark,

I don't really understand. Are you saying I can do this without any coding?

On the ESB I should have a mapping? How should this look: DEV - USR01, QAS - USR02, PRD - USR03. And then in IB?

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Glen,

Yes, this is possible without coding. In the signature tab, just add an importing parameter of string type like the one in this blog

Mapping importing parameters can be read in a message mapping by using a constant e.g

Where mode is an importing parameter of string type

PS: You also need to bind the mapping parameters in an OM, otherwise it will not appear in integration directory.

Regards,

Mark

former_member201275
Active Contributor
0 Kudos

But I don't have any importing parameters that can be read?

I have to determine which system I am on, and then based on this pass a USERID. For example if i am on QAS system then I should pass 'USR02' to field USERID.

At the moment I have a constant i.e. I have put 'USR03' as a constant to USERID and transported this to Production because in Production USERID is USR03.

Then I changed the constant in Dev to 'USR02' and transported this only to QA system.

Then on Dev I changed this to USR01 without transporting.

So I have on all 3 systems 3 different constant values but of course this is not best practice, and every time when this message mapping changes I have to make sure that this USERID field constant is corrected and transported to relevant system.


markangelo_dihiansan
Active Contributor
0 Kudos

Hi Glen,

The idea is to create an importing parameter for your user and then configure its value in integration directory accordingly. If you are in QAS system, all you have to do is to open the interface determination and just replace the value of user to USR02.

The value of user can be passed to USRID by using this mapping (with importing parameter User):

constant: $User$ -> USRID

By using the parameterized mapping approach, you only have to change the value of the users in integration directory.

Regards,

Mark

former_member201275
Active Contributor
0 Kudos

Thank you Mark, I get it now. Thank you for your patience.

Answers (3)

Answers (3)

iaki_vila
Active Contributor
0 Kudos

Hi Glen,

You can start with Venkat code and link to practice with UDF PI concept. However, i recommend don't hardcode the DEV, QUA and PRO environments directly on the UDF. You can take only the machine name and later use a value-mapping (Value mapping - Process Integration - SCN Wiki). The benefits to use value mapping are the value are configurable on the ID, if tomorrow you basis team change the machine name you won't need to change your ESR in all your environments, you only need to change this value directly in the ID. Summing up, Configurable values should be in the ID and not in the ESR.

Regards.

Former Member
0 Kudos

Hi Glen,

Here is the sample code for your reference.

// Assume XID is Dev, XIQ is QA etc

String sysName = (String) System.getProperty("SAPSYSTEMNAME");

if(sysName.equals("XID"))

{

//your logic here

}

else if(sysName.equals("XIQ"))

{

//your logic here

}

else

{

// your logic

}

You can pass the values dynamically after determining type of the system (DEV/Quality/PROD) if required.

Regards

Venkat

iaki_vila
Active Contributor
0 Kudos

Hi Glen,

You can take the system name form java code Find physical machine name in Java - Stack Overflow

and with value-mapping or any lookup to set if that machine is dev, qua or pro.

Regards.

former_member201275
Active Contributor
0 Kudos

Hi Iñaki,

Thank you for your help.

I am a bit new to PI. Where would I put the Java Code to determine this, how would i code the if statement to pass the USERID?

Currently I have:

Former Member
0 Kudos

Hi Glen,

You can write an UDF for achieving your requirement.

UDF Execution Type - Context and Queue. - Process Integration - SCN Wiki

Regards

Venkat