Summary
Description
This documents gives a guide on how to connect to the program through the development kit. Looking at some of 200s most popular modules from customers to cash book providing a very high-level description alongside code examples for creating and amending some of the popular items within this section. This is intended for developers who are beginning their journey with sage 200 development and would like to learn the basics. All examples within this training will be in the C# programming language.
Resolution
Contents:
- Connecting from the application
- Create customer
- Amend customer
- Create supplier
- Amend supplier
- Create sales orders
- Amend sales order
- Create purchase orders
- Print purchase orders
- Create stock item
- Amend stock items
- Create bank account
- Amend bank account
- What's Next?
Connecting from the application
Open Visual Studio > New Application > Console Application
Connecting to sage from an external application
Create your external application and add the following references to your project making sure to set each of their copy local properties to false. These references are the minimum required for accessing the financials and commercial modules. You can download the assemblies here.
- Sage.Accounting.Commercials
- Sage.Accounting.Common
- Sage.Accounting.Common.PersistentObjects
- Sage.Accounting.Financials
- Sage.Accounting.PersistentObjects
- Sage.Common
- Sage.ObjectStore
- Sage.ObjectStore.Builder
- Sage.Utils
It is not necessary to ship the core assemblies along with the external application as long as it knows where to resolve them, as they are no longer installed into the GAC. In addition, this then allows any hotfixes or patches applied by Sage to also be used by the external application. Therefore, before connecting to Sage 200, it is necessary to find the native application's install location and resolve the assembly Sage.Common.dll.
- Assembly Resolver
The second step to working with an external application is to establish a connection to our Sage 200 instance. Sage utilises windows authentication and as such we can call the connect method without passing any credentials, this will log on the current windows user.
After the connection method has resolved we can iterate the collection of companies available to this user and set the active company on the application object.
Find the code example for the assembly resolver here.
Create customer
Open Sales Ledger > Sales Accounts > Enter New Account
Creating a customer within Sage 200
Customers are used in Sage 200 to store sales ledger customer details. The customer record is fundamental to the successful management of customer accounts on the Sales Ledger. Through the customer list you can create an account by selecting the enter new account option located at the far left within the action bar.
Customer information is held across several tabs. Some details are inherited from your Customer Defaults settings. Any defaults that were defined in the settings are applied automatically to each account. You can keep or change them as you create each account. Each customer has their own account record with a unique account reference number. After adding the new customers details clicking save will create the customer record.
NOTE: You can also import customer accounts.
Creating a customer through code
A new customer can be added using the CreateNew() method on the CustomerFactory object. This returns a new Customer object. There are minimum properties that need to be set before calling the Customer.Update() method to save the changes. These minimum properties are; The customer account reference unless GenerateAccountReference is to autogenerate account references, and the customer account name which by default also sets the ShortName to the first 8 characters.
The following example shows how to create a new customer using C#. Setting the relevant properties on the customer object like the customer name and reference number. Setting the country and tax code, checking they are not null and finally calling the update method which will create the customer record.
Amend customer
Open Sales Ledger > Sales Accounts > Amend Account Details
Amending a customer within Sage 200
Any changes you make to an account will only affect transactions that you enter after you've made the changes. For example, if you change the settlement discount details, this doesn't affect the discount details already entered on transactions.
- You can't change the account code once the account has been saved. If you've entered a code incorrectly and haven't entered any transactions for it, delete the account and re-create it.
- You cannot amend a customer account that is on hold.
Once transactions have been entered for an account:
- You can't change the currency.
- You can't delete the account.
Amend a customer through code
This example shows how to amend a customer account (Sage.Accounting.SalesLedger.Customer). The Customers collection object can be indexed by a string representing the customer's account reference to return a Customer object. I can then amend the property required - in this case increase the credit limit by 10% and then update the customer.
Create supplier
Open Purchase Ledger > Purchase Accounts > Enter New Account
Creating a supplier within Sage 200
Suppliers are used in Sage 200 to store purchase ledger supplier details. The supplier record is fundamental to the successful management of supplier accounts on the Purchase Ledger. Through the supplier list you can create an account by selecting the enter new account option located at the far left within the action bar.
Suppler information is held across several tabs. Some details are inherited from your Supplier Defaults settings. Any supplier defaults that were defined in the settings are applied automatically to each account. You can keep or change them as you create each account. Some of these defaults also carry through to individual transactions. Again, you can amend them as you enter the details of a transaction.
Creating a supplier through code
A new supplier can be added using the CreateNew() method on the SupplierFactory object. This returns a new Supplier object. There are minimum properties that need to be set before calling the Supplier.Update() method to save the changes. These minimum properties are; The supplier account reference unless GenerateAccountReference is to autogenerate account references, and the supplier account name which by default also sets the ShortName to the first 8 characters.
The following example shows how to create a new supplier using C#. Setting the relevant properties on the supplier object like the supplier name and reference number. Finally calling the update method which will create the supplier record.
Amend supplier
Open Purchase Ledger > Purchase Accounts > Amend Account Details
Amending a supplier within sage 200
Any changes you make to an account will only affect transactions that you enter after you've made the changes. For example, if you change the settlement discount details, this doesn't affect the discount details already entered on transactions.
- You can't change the account code once the account has been saved. If you've entered a code incorrectly and haven't entered any transactions for it, delete the account and re-create it.
- You cannot amend a supplier account that is on hold.
Once transactions have been entered for an account:
- You can't change the currency.
- You can't delete the account.
Amending a supplier through code
This example shows how to amend a supplier account (Sage.Accounting.PurchaseLedger.Supplier). The Supplier collection object can be indexed by a string representing the suppliers account reference to return a Supplier object. You can then amend the property required - in this case increase the credit limit by 10% and then update the customer.
Create sales orders
Open Sales Order Processing > Sales Orders > Enter New Order
Creating an order within Sage 200
Customer orders are central to your business as a supplier. These are contractual agreements between you, the supplier, and the customer. They define the terms (prices, quantities and times) by which you will deliver products or provide services.
Sales orders are created using customer details and the goods and services you supply held on your Sage 200 system. The detail section of the sales order consists of lines. These lines itemise the goods and services requested, including any additional charges incurred and are categorised by line type. Goods created using full order entry are despatched from the warehouse with a despatch note. An invoice is generated separately.
Creating an order through code
This example demonstrates how to build up the different elements of a sales order, including non-traceable and traceable stock, free text items, negative free text items, additional charges and comment lines. It also shows how to amend the delivery address and apply a settlement discount.
This example also shows how to link the lines to a project item in project accounting. A new feature payment with order has been added since Sage 200 2009. This example also demonstrates how to record payment with the order and generate the payment invoice.
Find the code example for creating a sales order here.
Amend sales order
Open Sales Order Processing > Sales Orders > Amend Order
Amending an order within sage 200
You can amend your sales orders depending on how complete the order is and your user permissions. You cannot change the order number. When amending an order, you can edit a line to change values or add and delete these lines.
Amending an order through code
This example gets the first line (Sage.Accounting.SOP.SOPOrderReturnLine) of an existing order and removes it whilst also creating a cancelled line for it. We also have two allowable warnings in this process which we suppress.
Create purchase orders
Open Purchase Order Processing > Purchase Orders > Enter New Order
Creating an order within Sage 200
In Sage 200 the Purchase Order Processing module is used for the creation and management of goods being received from, or despatched to, suppliers. The purchase order is pivotal within purchase order processing. It is a contractual agreement between the company and the supplier for the provision of goods and services for a price.
Sales orders are created using supplier details and the goods and services you purchase held on your Sage 200 system. The detail section of the purchase order consists of lines. These lines itemise the goods and services purchased.
Creating an order through code
This example demonstrates how to build up the different elements of a purchase order, including non-traceable stock, free text items, additional charges and comment lines. It also shows how to amend the item delivery address and apply a settlement discount.
This example also shows how to link the purchase lines to a project item in project accounting.
Find the code example for creating a purchase order here.
Print purchase orders
Open Purchase Order Processing > Purchase Orders > Print Orders
Printing an order within Sage 200
You can print purchase orders, either to send to your suppliers or if you need a copy for your files in the office. Purchase orders cannot be printed for orders that are on hold or those that are unauthorised, if you are using order authorisation.
Printing an order through code
This example demonstrates how to print a purchase order
Find the code example for printing a purchase order here.
Create stock item
Open Stock Control > Stock Records > Enter New Stock Item
Creating stock items within Sage 200
There are several ways to create a stock item record. You can create a new stock item record, using a product group to provide many default values. Copy an existing stock item record (this does not copy the stock code, name or associated stock movements) or import them.
Creating stock items through code
A new stock item can be instantiated by using the New keyword. There are minimum properties that need to be set then call the Update method to save the changes. The minimum properties that need to be set on this object are; The unique stock code reference, the stock item name and the product group to which the stock item belongs.
This example shows how to add a new stock item (Sage.Accounting.Stock.StockItem). We set the location (warehouse) on the stock item. We next have the option of setting a default supplier and unit of measure. Finally, we update the stock item calling the Update method. The parameter passed to the update method (Sage.ObjectStore.UpdateFlags.Block) informs the Update method that any dirty child objects are to be updated as well. After updating the stock item, we add an alternative item.
Find the code example for creating a stock item here.
Amend stock items
Open Stock Control > Stock Records > Amend Stock Item Detail
Amending stock items within Sage 200
There are various maintenance activities you can perform to keep your stock item records up to date. These activities range from amending the details of a stock item, putting an item on hold through to deleting items when they become redundant.
Amending stock items through code
This example shows how to change the selling price of a stock item. A stock item can be accessed by using an indexer on the Stock Items collection object. The Stock Items collection can be indexed by an integer (oStockItems = oStockItems [0]) which is the stock item's position in the collection, or by a string (oStockItems = oStockItems["ACS/BLENDER"]) which represents the stock item's Code.
Create bank account
Open Cash Book > Cash Book Accounts > Enter New Account
Creating a bank account within Sage 200
You can set up a bank account in Sage 200 for any type of account you pay money in and out of. These can be for cash and credit cards as well as standard bank accounts. Bank accounts can be in any currency and all balances are stored in that currency. Each bank account has a corresponding Nominal ledger account.
Creating a bank account through code
Banks are used in Sage 200 to store cash book ledger bank details. The bank record is fundamental to the successful management of bank accounts on the Cash Book Ledger. As you manage your bank accounts they evolve through a life cycle of creation, amendment and deletion. Each bank has their own account record with a unique account reference.
A new bank can be added by calling the Add New method on the Banks object. This returns a new Bank object. There are minimum properties that need to be set prior to calling the Update() method to save the changes. The minimum properties that need to be set on this object are; The bank account reference and the account sort code.
Find the code example for creating a bank account here.
Amend bank account
Open Cash Book > Cash Book Accounts > Amend Account
Amending bank accounts within Sage 200
Amending bank accounts through code
This example shows how to amend a bank account. The Banks collection object can be filtered to obtain the bank account we wish to amend. We can then amend the property required - in this case increase the overdraft limit by 10% and then update the bank.
What's Next?
Help Documentation
Developer services have produced a wide range of documentation with a vast number of examples to support your development on Sage 200. The content provides an in-depth view into each module, showing how to use the objects available through the development kit to successfully produce your add-ons and solutions.
Demonstration data can be found here.
Our Community
For more support you can visit our Developer community. The Developer community contains questions and answers for many of our products including Sage 200 and Sage 50 Accounts. Share your queries or access thousands of answered questions from our community of sage developers. Drill down on product and version to find exactly what you're looking for.
The Sage Developer Community can be found here.