Hello Ankush,
Please find the solution in below link.
http://scn.sap.com/thread/1139172
Before going to implement function modules in your logic, its better to test from SE37 and write the logic either in load-of-program or initialization event.
Regards,
Venkat.