Defining SData Feeds for Sage 300 ERP
We introduced SData support with Sage ERP Accpac 6.0A; however, the product as it shipped only defined a few SData feeds that it needed to support the new Web Portal, Data Snapshots, Inquiry Tool and Quotes to Orders features. But Sage 300’s support for SData is based on converting SData Web Service requests into View calls. So it is possible to expose any View (or collection of composed Views) as an SData feed.
In a future version of Sage 300 ERP we will expose all the relevant Views via SData, but in the meantime if you want to use SData with Sage 300, then you need to provide XML files to define the feeds you need.
All the feed definitions are XML files, which means you can read all the existing ones that come with Sage 300 using a normal text editor. Hence you can use the existing ones either as examples or templates for the definitions you need.
One thing to be careful of is that most of the fields in these XML files are case sensitive. This means they must match exactly or they won’t work. When things don’t work, it’s worth looking in the Tomcat\log folder at the relevant SDataServlet.log as this will often point out errors when parsing the XML files.
Class Map Files
The classmap files are a series of XML files located in the sub-folders under: C:\Program Files (x86)\Common Files\Sage\Sage Accpac\Tomcat6\portal\sageERP. The feeds for a given application are stored under the application’s program id and version id directory such as oe60a. Note that these need to be in a folder for an activated application to be read, but within an application you can define feeds that access Views in any application.
All the configuration XML files are loaded into memory by the SDataServlet on startup. So if make any changes to these files, you need to restart the “Sage Accpac Tomcat6” service for your changes to take effect.
You can use these to define custom Java classes to process the SData requests, I’ve covered this a bit in other blog postings, but won’t go into that here, since this article is only considering what can be done by editing XML files.
The classmap defines each SData feed and specifies the class to handle the feed and then a detailed feed definition file called a resourceMap file.
Example – Currency Codes
The currencyCodes resource is implemented by the Java class: ViewResourceKind and is defined by the resource map file: currencyCodeViewMapping.xml. ViewResourceKind is a system provided Java Class for generically converting SData requests into View calls. You can use this to expose most Views (that have data) as SData feeds.
<resource name=”currencyCodes” className=”com.sage.orion.sdata.servlet.accpac.ViewResourceKind>
<parameter name=”ResourceMapFile“ value=”currencyCodeViewMapping.xml”/>
If you aren’t programming server classes then this is all you need to know about the classmap files.
Resource Map File
Maps an SData resource to a backing family of Accpac Views and fields. These are stored in the resourceMap folder under the folder that holds the classmap file.
By default all fields from the view are exposed as SData Resource Elements.
Has the ability to exclude or include or overwrite Sage 300 fields from the SData resource.
Example – Currency Codes
The currencyCodeViewMapping.xml resource map file contains the following:
<resource name=”currencycode” description=”Currency Codes”>
<resourceViewField viewFieldName=”CURID” />
<resourceViewField viewFieldName=”CURNAME” name=”Description”/>
<resourceViewField viewFieldName=”DECIMALS” />
<resourceViewField viewFieldName=”SYMBOLPOS” />
<resourceViewField viewFieldName=”THOUSSEP” />
<resourceViewField viewFieldName=”DECSEP” />
<resourceViewField viewFieldName=”NEGDISP” />
<resourceViewField viewFieldName=”SYMBOL” />
The key points are the viewID that maps this feed to the currency codes view CS0003. The URI of the feed is the plural name, namely currencyCodes. Then you can specify the list of fields you want included in the feed. You might specify a shorter list of fields to keep the size of the feed to a minimum. The includedFields section is optional. I tend to prefer using an excludedFields section to just list the fields I don’t want.
Example – Single Level Resource
SData resource “customer” is defined from the view AR0024.
<resource name=”customer” description=”AR Customers”>
Example – Multi-Level Resource
SData resource ‘arInvoiceBatch’ is defined from a set of composed views – AR0031, AR0032, AR0033, AR0041 and AR0034.
<resource name=”arInvoiceBatch” description=”AR Batches”>
<resource name=”invoice” description=”AR Invoice”>
<resource name=”detail” description=”AR Invoice Details”>
<resource name=”optional” description=”AR Invoice Detail Optional Fields”>
<resource name=”schedule” description=”AR Invoice Payment Schedules”>
Resource Map File Details
Resource Mapping File Attributes / Elements:
name: name of the resource
description: description of the resource.
viewID: The ViewID of the resource. Remember you can get further information on the Views from the Sage 300 ERP Application Object Model (AOM).
pluralName: plural name of the resource. If undefined then the pluralName = name +”s”. This will be the URI of the resource.
resources: Collection of sub-resource elements
kind: resource kind name of the resource. Top resource of the resource tree the resource name and the resource kind name should be the same. However for a sub-resource the resource name reflects the name of the property that refers to it in the parent while the kind name is the name that it appears as at the top level of the schema.
includedFields: list of resourceViewFields that are to be included in the resource (by default all fields are included)
excludedFields: list of resourceViewFields that are not to be included in the resource
overridenFields: list of resourceViewFields that are to be overriden in the resource (usually done to change the SData name)
virtualFields: list of resourceViewFields that are to be added to the resource. Note: virtual fields requires extending ViewResourceKind with a custom class that implements these virtual fields.
lookupFields: These are a 6.1A feature that allow you to add fields looked up from another view like to get a description.
Hopefully this article gives an idea of how to setup additional SData feeds for Sage 300 ERP, without requiring any programming.