B1 Service Layer with JavaScript – Handling B1 Objects without .Net (nor DI API)
B1 Service Layer with JavaScript – Handling B1 without .Net: Lots of new features and innovations are raising at SAP world and of course that our beloved SAP B1 is getting some of the juice. Since SAP Business One version for SAP HANA 9.1 (B1H 9.1) a new component of B1 Family has been released, the B1 Service Layer. With B1 Service Layer you can manipulate B1 objects on an open, fast, lightweight and standard approach. Break the chains of .Net and DI API!
Overview
SAP Business One Service Layer is a server based components build using OData. The Open Data Protocol enables the creation and consumption of REST APIs, which allow resources, identified using URLs and defined in a data model, to be published and edited by Web clients using simple HTTP messages.
In other words, now you can manipulate B1 Objects using our new REST API. It means that B1 is open to a lot more technologies such as JavaScript presented here. You can find more information about Service Layer on this presentation.
Code Explanation
I did a video presenting this application. Check it out:
What I am using:
Twitter BootStrap – As Front-End Framework
jQuery – JavaScript most popular library. Used on some UI controls but mainly on the REST calls to Service Layer
You can find the application code on GitHub
What do you need
This application contains 2 files:
index.html – The UI of the application.
sl.js – The intelligence of the app and where you will find the REST calls to Service Layer. This file must be saved on a folder named “js” (or you can change the reference on the index.html file)
** If your Service Layer is using a Self Signed SSL Certificate your browser probably will block the calls from this application. In this case, use your HANA Studio browser and all will be fine. I explain more on the video.
Test it yourself
There is no reason for us Solution Architects to create create those codes if you guys on the frontline do not use them! ????
Test, enhance, modify it! Your feedbacks are always welcome!
UPDATE
Shai Berkenblit, B1 Product Manager, has found a way to have the SSL Certificate trusted by your broswer. That means you are not restricted to Eclipse browser to run this app if your connection certificate is Self Signed. So you can use Chrome to debug this app for example.
The details are here. Thanks a lot, Shai!
UPDATE – Ago/2015
Some of you guys run across problems when trying this app on XS Engine. That was due to the lack of support of Cross Origin Resource Sharing (a.k.a. CORS). Although it is installed on the same server as HANA, Service Layer is not built (yet) on top of XS Engine. So when accessing the application trough HANA and performing calls to SL you were interacting with 2 different domains and most browsers block that if the called domain is not explicitly accepting this kind of interaction.
So, the allow your SL to accept this kind of interaction. Starting with B1 Version 9.1 PL08. you can add the last two lines of the image to your Service Layer configuration file, restart SL and everything will work:
You can find the Details on this blog
UPDATE – Set/2015
Sample: How to consume Service Layer oData services from .NET via WCF
and don’t forget to follow me on Twitter: @Ralphive
New NetWeaver Information at SAP.com
Very Helpfull