Monday 24 February 2014

Short and Effective way to Sort a Set with its Key in Java

Many times we need to sort the data to represent in a particular order.
Here is a trick  to sort the data sets in Java. In this example i am using an unordered MapSet to demonstrate the sorting of MapSet with its key.


Map<String,String> maps_set=new Map<String,String>;

maps_set.put("Java","developed by SunMicroSystems");

 maps_set.put("CSHARP","developed by Microsoft");

 maps_set.put("PYTHON","Python Organization");



 SortedSet<string> keys=new TreeSet(maps_set.keySet());//Here the Keys were sorted by the TreeSet and placed in the keys object

  System.Out.Println("Key         Value");

 foreach (String key : keys) {
      System.Out.Println("Maps_Key:"+key+"  Map_Value:"+maps_set.get(key));
}


In the above example the I had put the 3 values into the maps_set and they are not in a alphabetical order 

Tuesday 11 February 2014

How to Know the list of processes run by a User with distribution status description from backend in Peoplesoft


By default the "Process Monitor Process List(PS_PMN_PRCSLIST)" table will not have the description of the Distribution status it will have the Fieldvalue (i.e the translate field value of the DISTSTATUS field) of the distribution status. The below Query will give you the Description of the process distribution status.

Here is the Query to know the Processes ran by a user with its distribution status description:

SQL Syntax:  
select * from PS_PMN_PRCSLIST P,PSXLATITEM X where OPRID='<operator id>  and P.DISTSTATUS=X.FIELDVALUE

Example for The processes Run By the VP1 user:

select OPRID,PRCSINSTANCE, PRCSTYPE, RUNSTATUSDESCR, DISTSTATUS, X.XLATSHORTNAME as DISTSTATUSDESCR from PS_PMN_PRCSLIST,PSXLATITEM X where  X.FIELDNAME='DISTSTATUS' and X.Fieldvalue=DISTSTATUS and  OPRID ='VP1';

Friday 7 February 2014

Effective and Faster String Building in Python

          Many times we use string building in many languages and also in python. Here is a tip for a fast string building in Python.

Commonly Used:

string1 = "Example" + " for "+ " String Building"   #Commonly used by regular developers

The above method of concatenation is not a best practice most of object oriented language will provide methods for such operations like "join" method in Python.


Best Practice:

string1 = "".join("Example"," for","String Building")   #Best practice for faster execution


 Using String Building in Python:

string1 = "%s %s %s" % ("Example","for","String Building") # Another Best Practice and very fast







Wednesday 5 February 2014

How To check the Report Distribution Node From Backend

Some times we may need to check the Report Distribution Node Details from the backend through any SQL Plus or Toad.

The table used for the Report Distribution Node is:  PS_CDM_DIST_NODE
The Query To Execute to know the distribution node details with its node name:

select * from PS_CDM_DIST_NODE where DISTNODENAME='<node_name>'

Replace the <node_name> withe node you want to search for.

Example for PROD node:  select * from PS_CDM_DIST_NODE where DISTNODENAME='PROD';