Friday, 15 March 2013

Creating Custom routines in Talend or Jasper ETL

Lot of time, we come across a situation where we want to use the custom routines/functions while creating Talend Job. Custom routines can be handy and re-usable code when require to be use more than one time.

Today, I am going to create a simple routine to convert String to Date data type. User will pass the date in string format and the actual date format of the string to the routine and in return routine will provide the Date.

Follow below mentioned steps to create a user routine:

1. Right Click on Routines in Repository Pane and Select Create routine.




2. Provide the Name to the Routine in the New Routine window and click Finish.



3. Create a required function in the Routine . Copy the below code to create a function convert2Date.

Now our routine is ready. Its time to use this routine. 

4. Create a new Job and drag tJava component to the Job designer.

5. Here I will call the routine. I will pass the sample date "2013-03-15" in String format and its format "yyyy-MM-dd" as well. to use the routine write routines. and press ctr+tab to access all the available routines and select string_to_date.convert2Date.

Copy and paste below code
 
Now our job is complete. Its time to execute it.



Now you can see that date in the form of String has been converted to Date data type. You can call this routine whenever you require to convert string to Date, Just provide the string literal and its format to the routine defined above.


You may also like to read..

3 comments:

  1. You said "Copy and paste below code"

    I don't see the code. Did you forget to put it in the blog?

    Thanks for all your good examples!

    ReplyDelete
  2. Thanks David, Please check now. It was template issue. :)

    Thanks for letting me know.

    Vikram Takkar
    http://vikramtakkar.blogspot.in

    ReplyDelete
  3. Hi VIkram I wanted to create a java code on intellij and then runit on talend
    is it possible please reply I exporting jar but no point or is it through routine only.
    I need to contact you my email is anmolrane1989@gmail.com

    ReplyDelete