cancel
Showing results for 
Search instead for 
Did you mean: 

Get SYSID in XSLT mapping

Former Member
0 Kudos

Hello,

Does anybody know a way to get the sysid (or the current environment) at runtime using XSLT mapping.

Some simple java code is also Okay

Cheers

Emile

Message was edited by: Emile Hermans

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

1) Write some Java code to get the hostname

package com.company.xi;

public class MappingFunctions {

public String getServerHostname()

throws UnknownHostException {

InetAddress myAddress = InetAddress.getLocalHost();

return myAddress.getHostName();

}

}

2) Package it in a JAR and load it into the IR as an imported archive.

3) Call it from your XSLT

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:mapping="java:com.company.xi.MappingFunctions">

<HostName><xsl:value-of select="mapping:getHostName()"/></HostName>

Thanks,

Jesse

former_member184154
Active Contributor
0 Kudos

Good job Jesse!

That's not exactly the SID, but works great!

Alex

Former Member
0 Kudos

HI Alessandro,

Like what Jessie told you need to make a java code called in between. In the java code which is imported as an archive with the XSLT mapping you can add the following code to get the system id.

// Get the system properties

String sysNr = (String) System.getProperty("SAPSYSTEM");

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

Cheers

JK

Steven_UM
Contributor
0 Kudos

Great Jesse !!!

I have been looking for something similar as well ...

Your solution is a perfect alternative !

Steven

former_member184154
Active Contributor
0 Kudos

JK,

really as simple as effective. I'll give it a try right now!

Thanks

Alex

Former Member
0 Kudos

I like the above solution to get the SID using the System.properties calls.

If you need to get any other information for the environment like JCO connection parameters, etc you can do the following:

1) Maintain an XML file which maps hostname (or SID) to the values you want to lookup. I'd recommend maintaining all environments in this file (DEV, QA, PROD).

2) Load this file as an imported archive into the IR.

3) In your Java code:

- Get the hostname (or SID)

- Lookup the values from the XML file based on the hostname or SID

Thanks,

Jesse

Former Member
0 Kudos

Emile,

I have similar question: in what environment is a mapping executed: development, QA or production. There doesn't seem to be a standard way to obtain this.

Solution is (probably) to store it somewhere, e.g. in properties file on disk and read it from there with some Java code.

Good question. Kind regards, Guy Crets

STALANKI
Active Contributor
0 Kudos

USE MSS_GET_SY_SYSID FM and call it using mapping lookups or anything and that can be used for getting the system runtime id.

abap WITH XSLT CAN BE USED IF U WANT JSUT XI SYSTEM ID.

I HOPE THIS HELPS..;)

STALANKI
Active Contributor
0 Kudos

do u want the system id of the XI or sender or reciver?

former_member184154
Active Contributor
0 Kudos

Emile,

that could seem trivial but, believe, it is not...

I had tried this challenge some months ago but gave up.

What I can tell you is: (1) it's very likely to find Java code working rather than XSL and (2) I think you need to use some <i>forbidden</i> classes which are not documented...

Do you want me to go on checking that?

Let me know

ALex