Skip to Content

If you are using NWDI, then you must have come across the scenario where you felt like putting a logger in your code for certain check. How to write a logger specific to your environment (Dev, Qua or Prod) is the question which I want to answer via this blog.

At the time of portal installation, the profile file is generated by default, with the name Default.pfl. You can access the same by navigating to the path /usr/sap/SID/SYS/profile/

The content of the file looks something like

SAPDBHOST = ###

j2ee/dbtype = ora

j2ee/dbname = SID

j2ee/dbhost = ###

SAPSYSTEMNAME = SID

SAPGLOBALHOST = ###

system/type = J2EE

SAPFQDN = ####

SAPLOCALHOSTFULL = $(SAPLOCALHOST).$(SAPFQDN)

#———————————————————————–

# SAP Central Service Instance for J2EE

#———————————————————————–

j2ee/scs/host = ###

j2ee/scs/system = ***

j2ee/ms/port = ****

You can access these information via java code. The following piece of code shows how to retrieve all system property names and then retrieve each property using its name:-

Properties props = System.getProperties();

Enumeration pNames = props.propertyNames();

String key = “”;

while (pNames.hasMoreElements())

     {

          key = (String) pNames.nextElement();

          System.out.println(key + “=” +props.getProperty(key));

     }

I have not used any property other than SAPSYSTEMNAME and so not sure if you really need to know how to retrieve the complete file (as shown above).

But to identify the environment, you can just use the following piece of code-

String SID = System.getProperty(“SAPSYSTEMNAME”).toString();

If you are aware of the system names, you can use the conditional check as

if(SID.compareToIgnoreCase(“MY_SID”) == 0)

then

     {do_my_task}

Or, you can use any of the available methods, as required.

SID.jpg

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply