cancel
Showing results for 
Search instead for 
Did you mean: 

Get the Server Name from The Mapping

former_member181928
Participant
0 Kudos

Dear All

Is it possible to get the Server name / Hostname of server dynamically by using the java code / java API in User Defined function . Any help is appreciated .

regards

Nilesh .

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Use this Blog and Implement the Logic inside this.

Check the Check box Source FTP Host in ASMA of sender File adapter

And Change this line in the Code

//for getting Host Name

DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Source FTP Host ");

Regards

Seshagiri

former_member181928
Participant
0 Kudos

Hi Seshagiri,

I want to access the Hostaname of the XI server and not the Source FTP Server. I think you did not get my question correctly.

regards

Nilesh.

Former Member
0 Kudos

Hi Nilesh,

you can acess System-properties like this way:

String user_login_id = System.getProperty("user.name");

return user_login_id.substring(0,3);

in UDF.

FAQ: How do I access/read system properties and environment variables?

http://www.devdaily.com/blog/post/java/java-faq-access-read-system-properties-environment/

regards Mario

Edited by: Mario Müller on Apr 23, 2008 3:54 AM

former_member181928
Participant
0 Kudos

HI Mario

Thanks this works but do you why the user name also contains the host name . Will this be consistent across all environments like (QAS, PRD systems).

regards

Nilesh .

Former Member
0 Kudos

HI Nilesh ,

that was just a sample "How to access something" not specially the system.

But on the other hand, you could provide a CSV with key-values as a imported archive an read the csv from imported archive via UDF.

Regards Mario

Former Member
0 Kudos

You also can get system properties from the System JAVA object, like SAPSYSTEMNAME for the SID or SAPGLOBALHOST (or similar) for hostname, like :

String PropertyValue = (String) System.getProperty("SAPGLOBALHOST ");

They have the same name as instance profiles vars, they are set by J2EE at startup, I think ...

Chris

Edited by: Christophe PFERTZEL on Apr 23, 2008 11:07 AM

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi yes,

it is possible. You have to fill the dynamic attributs in your communication channel.

Than access the attrubute via UDF:

http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm

Sample:

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“FileName”);

String valueOld = conf.get(key);

if (valueOld != null) {

String valueNew = valueOld.replaceAll(“input”,”output”);

conf.put(key, valueNew);

}

See also:

Adapter-Specific Message Attributes

http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm

Regards Mario

Edited by: Mario Müller on Apr 23, 2008 3:28 AM