Hi,
There are many links available to achieve this functionality in SCN. Check following links, this might help to start up.
http://scn.sap.com/thread/1414626
http://scn.sap.com/thread/1827004
http://scn.sap.com/thread/1232195
Hope this helps..
Regards,
Deepti