Stephen Smith's Blog

All things Sage ERP…

Creating a Web Form for Accpac 6

with 12 comments


Sage ERP Accpac 6.0A is just entering beta (lucky Friday 13th August, 2010). With this release you will be able start to run Web based User Interface forms. We’ve covered how this looks in several other blog posts like http://smist08.wordpress.com/2009/12/03/the-sage-erp-accpac-6-0a-portal/ and http://smist08.wordpress.com/2009/12/24/sage-erp-accpac-6-0-data-portlets/. But as a developer, how do you create new Web Based forms using the Accpac SDK?

The new Web based forms are written using a number of tools that are integrated into the Eclipse development environment (http://www.eclipse.org/). Our SDK involves programming with the Sage Web Toolkit (SWT) which is based on the Google Web Toolkit (GWT – http://code.google.com/webtoolkit/). With this toolkit you develop your programs in Java and then GWT provides a compiler that will compile these programs into JavaScript, which will run in your browser.

To start with we provide a project wizard integrated into Eclipse. You use this to create a starting Accpac screen project. From the File menu in Eclipse you choose File – New – Project… Then select under “Sage Web Toolkit”, “New SWT UI”. This gives the following dialog that gets the basic information on the UI you want to create:

When you are done and click Finish, our wizard will create a new project in Eclipse. This eclipse has a simple UI form and everything you need to start working on your UI:

This is a completely ready to run minimal UI that is all set for you to add your own logic to. If you don’t do anything and just choose run, then your project will be run in GWT hosted mode, which means it is run as a Java program in a container that simulate browser behavior. This is how you debug your programs. In this mode you can set breakpoints, single step through code, examine variables and do anything else supported by the full Java debugger. When you run it will pull up the sign-on screen:

And then when you sign-on you get the screen with the single table control connected to the A/R customers SData feed that we put on the form. Normally you would delete this control and then add the controls you really want on your form.

Behind the scenes is the development shell that show useful messages on what is going on, especially if something goes wrong. Plus status messages are sent to the Java Console inside the Eclipse IDE.

Once you have debugged the program and have it working then you run the project through the GWT compiler to produce a Web HTML/JavaScript version of the program that you can run directly in the Browser, or which you can add to the Accpac Portal.

When you are writing code for your UI, it can go into one of two places. If can reside on the Browser side of things running as JavaScript or it can run on the server side as an SData service (http://sdata.sage.com/ or http://smist08.wordpress.com/2009/11/24/sdata-in-sage-erp-accpac-6/). In VB all the UI code was within the VB OCX control and this talked directly to the Accpac Views (Business Logic Objects). In the Web world we have JavaScript running in the Browser (created by compiling Java programs with GWT), that talk to SData services running on the Server. These SData services then talk to the Accpac Views.

When programming the Browser half, you have nearly all the power you had in VB. You can add listeners to any control and get events as things happen. You can add listeners to data sources to get notified as things happen to data. This is very similar to VB event handlers. You can make SData calls that translate directly into View calls, like you called the Accpac COM API in VB. However there are some major differences. Just because you can do something, doesn’t mean it’s a good idea. In the Web world you want as much to happen on the server as possible. Any code you add to the JavaScript side, increases the size of JavaScript that has to be downloaded to the Browser (it will be cached and JavaScript code is very compact). Plus whenever you make an SData call to the Views, this call will happen over the Internet. This means it could be slow. Generally you only want to make 1 SData call to the server to do anything. You don’t want to make a bunch of SData calls to accomplish something. You really only want to make one call. Additionally in the Web world all calls are asynchronous, meaning that other processing continues after you send off the request. When you send the call you set a listener, which will be called when the response comes back from the server. This makes it quite complicated to make multiple calls and we don’t provide any help to do this in our framework (and neither does GWT), because we really want to discourage it.

So how do you do complicated sets of View operations? You create these on the server where we’ve made it easy. We let you create your own SData services or extend the standard services that we put on top of all the Views. So for instance to perform the operation to calculate taxes, you would send all the input fields in a service SData request, the server Java class would do all the viewPuts, viewProcess, etc and return any fields that changed as a result. This way you make 1 SData call from the UI, the SData process on the server makes all the View calls and returns the request. This minimized network time both in latency and bandwidth. On the server we have a generic class that wraps a View, this class is responsible for converting SData requests into View calls. It handles all the standard View protocols. You can extend this class with your own class and add extra logic to it. You can easily add additional fields from other Views or calculated fields. Generally you would like to only interact with one SData source from a UI, so you want to include any side lookups like description fields into the main SData source. You also would rather do calculations on the server for performance reasons, plus then anyone else using your SData service benefits from this code. All these server classes are controlled by a number of XML configuration files that define all the SData sources and configure which server side Java classes process them.

This was a quick overview of how to create a new Accpac Web based UI along with a bit of discussion on conceptually what you do next without any details. Hopefully in future blog posts we can fill in a few more details on how to program both the Browser and server in this new model.

About these ads

Written by smist08

August 14, 2010 at 4:28 pm

Posted in Sage 300 ERP

Tagged with , , ,

12 Responses

Subscribe to comments with RSS.

  1. [...] This post was mentioned on Twitter by glenmund, Geek Fetch. Geek Fetch said: ACCPAC Creating a Web Form for Accpac 6: Sage ERP Accpac 6.0A is just entering beta (lucky Friday 13th August, 201… http://bit.ly/bnxH8n [...]

  2. After sending the request to server if network connectivity drops out will the request will still be processing at the server?

    How these forms can be added to user’s portal after customisation?

    All these requests are secured?

    Shamprasad

    August 15, 2010 at 3:10 am

    • If the request is received by the server it will finish processing it whatever happens to the client in the meantime. If its a long running request with a cancel option (usually a meter is displayed with a cancel button) then that long running operation will be canceled. Integrity is always maintained via database transactions, so you will never have the database corrupted or left in a bad state due to network problems.

      The forms are XML files that are stored on the server. There will be mechanisms to customize these. Right now its a matter of customizing them in the SWT UI Designer and placing them in the right folder on the server. But we will greatly improve this for 6.1.

      The recommended way to run is to use HTTPS (Transport Layer Security TLS). When running this way everything is secured and encrypted.

      smist08

      August 15, 2010 at 3:30 pm

  3. [...] Thanks Stephen Smith for this great information! [...]

  4. [...] week we talked about creating Accpac 6 Web UIs (http://smist08.wordpress.com/2010/08/14/creating-a-web-form-for-accpac-6/). Part of the process is creating the XML representation of the Web Form which we discussed [...]

  5. [...] discussed how to create Accpac 6 Web based UIs in http://smist08.wordpress.com/2010/08/14/creating-a-web-form-for-accpac-6/ and how to write code that runs as JavaScript in the Browser in [...]

  6. [...] Mobility Automated Testing in Sage ERP Accpac Development How to Layout Forms in Sage ERP Accpac 6 Creating a Web Form for Accpac 6 Client Logic for an Accpac 6 Web Form Writing Server Side Code for Accpac 6 Web UIs Preparing for [...]

  7. [...] These innovations don’t need to just target end users. They can also target the developer community. Sage ERP MAS 90 has a plug-in for doing ProvideX development in the Eclipse IDE. Originally for Accpac 6 development you did your coding inside Eclipse, but then a number of other activities in other tools like our screen designer in IE. So why not take the expertise we had from creating the MAS 90 Eclipse plug-in and create an Eclipse plug-in for Accpac? Which was done as a POC and is now part of the standard SDK and blogged on here. [...]

  8. Can you let me know the link from where I can get Accpac SDK 6.0.

    Amit

    July 27, 2011 at 4:59 am

  9. And SWT that will work in Ecclips??

    Amit

    July 27, 2011 at 5:30 am

    • Yes. You develop in Ecliipse, debugging in GWT Hosted Mode. Then Deploy to the Web as JavaScript (compiled by the GWT compiler).

      smist08

      July 27, 2011 at 2:23 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 262 other followers

%d bloggers like this: