Wednesday, June 27, 2012

Create new Function to Set date to 1st day of the next month from suggest Date

Propose Scenario
There are two date.
1.)    Due date - :user can select a date
2.)    Termination Date- : will be 1st day of the next month of the Due Date.
User can suggest a date (Due date) then Termination Date will be 1st day of the next month of the Due Date. EX: Due date from is Sep 22 then Termination Date = Oct 1
1.) Create a new function 


2.) Select particular library name or create new library to add this function.
 

3.) At Parameter tab- : Add input parameter name with String data type and In/Out filed selected as In. Output Return type name as String.


4.) At java tab- : Used following java code for logic and pass input parameter which defined in Parameter tab.

DateFormat format = new SimpleDateFormat("yyyyMMdd");
Calendar calendar = Calendar.getInstance();
try{
calendar.setTime(format.parse(datein[a1] ));
}catch(Exception ex){}
calendar.add(Calendar.MONTH, 1[a2] );
calendar.set(Calendar.DATE, 1[a3] );
String dateout = format.format(calendar.getTime());
return dateout[a4] ;                           

5.) At Imports and Exception tab-: Import following packages to compile above java code.


java.text.DateFormat;
java.text.SimpleDateFormat;
java.util.Calendar;

6.) Generate Library and used as a function.
 Test Library Generation  
After you've saved the instance, but before you click the Generate Library   button, click to find any language errors.
 Generate Library  
Click to update the library on the Process Commander system (on the current node only).
CautionDo not click this button until you have clicked Test Library Generation  and performed other testing to confirm that your function works as intended. If you generate a library that includes compilation errors, but has the same Rule Set and version as a previously generated library that compiled, the older, working CLASS files are overwritten. This can affect processing of other users of the library

7.) Usage of this function







 [a1]Pass input parameter to set as calendar date (input parameter which used in Parameter tab.)

 [a2]Add one month to date which passed as input parameter.

 [a3]Select and set 1st day of the month from date which set above.


 [a4]Return 1st day of the next month of the Date which pass as input parameter.

No comments:

Post a Comment