I am an SAP employee. I want to know the code to open the documents directly from browser to MS office. I saw this possible via Edit Online option of alfresco.
have you looked at the code of "Edit Online" in Alfresco? That is the code you want, and there you can see how it may be used to create a functional action in a web application. Look for the onActionEditOnline function in the client side JavaScript (actions.js).