We all came across the requirement to get the SAP System name at least once in many of our PI integration projects. We always wanted to get the SAP PI SID dynamically in the mapping and use it for various purposes.
We all probably used the below code snippet in the UDF to achieve this requirement-
String sysName = (String) System.getProperty("SAPSYSTEMNAME"); return sysName;
I have always wondered what are the other system properties we can fetch? and how to use this UDF more dynamically rather than hard-coding the property name.
Here is the little trick, using the below code we can retrieve the entire list of properties of the PI system-
Properties p = System.getProperties(); return p.toString();
This will return the String representation of the key-value pair for all the system properties, similar to below –
Now, we can choose any property and pass it to UDF and get the value of that property.
Below is the revised and modified UDF code which is more dynamic to get any system property value- this UDF requires only one input -property which is the name of any PI system property.
PI system properties are – SAPSYSTEMNAME,SAP_J2EE_Engine_Version,SAPSYSTEM,java.vm.version etc.
String property_val = (String) System.getProperty(property); return property_val;
Hope this will help the community!