Wednesday, 4 December 2024
en-USen-AU


You are here  >  Integration Solutions  >  Examples for the Developer

Samples

1. Editing Customer Details

This example shows the code required to load the customer details of account “1046548” and then edit the customers details. The RAMS Server web server is located on the INternet so we want to use HTTP as the communication method. The RAMS Data is located in a RAMS council system called EVERTON.

* Dimension the parameters
Dim oRamsDataServer, lSuccess, cErrorMessage

* Create the instance of the RAMS Data Server
Set oRamsDataServer = CreateObject(“RamsDataServer.RamsDataServer”)

* Set the Communication method and system
With oRamsDataServer
      * Set the communication method
      .SetConnection(“HTTP”)
       * Set the RAMS system
      .SetSystem(“EVERTON”)
Endwith

* Now just load the customer with s single command. It will return false if it cannot find the customer

lSuccess = oRamsDataServer.oCustomer.Load(“1046548”)

* You can do a test here for errors and do what you want with them

If oRamsDataServer.oCustomer.lError = True
      cErrorMessage = oRamsDataServer.oCustomer.cErrorMsg
      * Then do whatever you want
Endif

* At this point you have no loaded the customer data into an object called oData. Under the customer object which can be viewed in any way you want. For instance you could set some customer values into session parameters as follows

Session(“CustomerBalance”) = oRamsDataServer.oCustomer.oData.Balance

Session(“SiteName”) = oRamsDataServer.oCustomer.oData.Site_Name

* If I wanted to I could get an XML document representing the entire customer record

cXMLCustomer = oRamsDataServer.oCustomer.MakeCData()

* Change the site name and save the changes

oRamsDataServer.oCustomer.ADDFIELDVALUE(“Site_Name”,“JO BLOGGS NEW SITE NAME”)
oRamsDataServer.oCustomer.Save()

* Again all errors are fed back to the client. You can do a test here for errors and do what you want with them

If oRamsDataServer.oCustomer.lError = True
      cErrorMessage = oRamsDataServer.oCustomer.cErrorMsg
     * Then do whatever you want
Endif

8/02/2012 7:09:00 PM
2. Loading Work Orders

In this example our automated telephone booking system needs to determine all active work orders that are currently assigned to a customer. Again the customer is “1046548”. The Automated telephone system is sitting within our WAN so again we use HTTP. The RAMS Data is located in a RAMS Council system called EVERTON.

 

* Dimension the parameters
Dim oRamsDataServer, nNumberOfJobs , cErrorMessage

* Create the instance of the RAMS Data Server
Set oRamsDataServer = CreateObject(“RamsDataServer.RamsDataServer”)

* Set the Communication method and system
With oRamsDataServer
      * Set the communication method
      .SetConnection(“HTTP”)
      * Set the RAMS system
      .SetSystem(“EVERTON”)
Endwith

* Now just load workorders with the filter set to work orders of type “OPS”

oRamsDataServer.oWorkOrders.cPKValue = “1046548”

nNumberofJobs = oRamsDataServer.oWorkOrders.Query(“TYPE = *OPS’,””,1)

* You can do a test here for errors and do what you want with them
If oRamsDataServer.oWorkorders.lError = True

cErrorMessage = oRamsDataServer.oCustomer.cErrorMsg
  * Then do whatever you want
Endif

* At this point you have loaded all the workorders so you can extract the XML document

cXMLActiveWorkorders = oRamsDataServer.oWorkorders.cResultXML

8/02/2012 7:00:00 PM
3. ImportingPayements

oRamsDataServer = Createobject("ITRDS.RP_CLIENT")

* Set the Communication method and system
With oRamsDataServer
     * Set the communication method
      .SetConnection(“HTTP”)
      * Set the RAMS system
      .SetSystem(“EVERTON”)
EndWith

* First create a payment batch
oRamsDataServer.oBatchLog.New()
oRamsDataServer.oBatchLog.ADDFIELDVALUE("TYPE","PAYMENT")
oRamsDataServer.oBatchLog.Save()

If oRamsDataServer.oBatchlog.lError
      * Handle error
EndIf

* Get the batch number
lcBatchNumber = oRamsDataServer.oBatchLog.oData.Number

* Lock the batch
If not oRamsDataServer.oBatchLog.LockBatch(lcBatchNumber)
      * Handle error
EndIf

* Lets assume you have an import table open called curPayments which contains a list of payments that we need to get into RAMS

Select "curPayments"
Go top
Scan
      lcAccount = curPayments.Account
      ldDate = Iif(Empty(curPayments.Date),Date(),curPayments.Date)
      lcInvoice = curPayments.Invoice &&(note that if this is blank it will carry out the normal rules
      && to determine which invoice to post against or leave blank)
      lnAmount = curPayments.Amount
      lcPaymentServiceCode = "999900"
      * Now place record
      oRamsDataServer.oBatch.New()
oRamsDataServer.oBatch.addfieldvalue("ACCOUNT",lcAccount)
      oRamsDataServer.oBatch.addfieldvalue("UNITS",1)
oRamsDataServer.oBatch.addfieldvalue("UNIT_AMOUNT",lnAmount)
oRamsDataServer.oBatch.addfieldvalue("INVOICE",lcInvoice)
oRamsDataServer.oBatch.addfieldvalue("CODE",lcPaymentServiceCode)
oRamsDataServer.oBatch.addfieldvalue("DATE",ldDate
oRamsDataServer.oBatch.addfieldvalue("BATCH",lcBatchNumber)

      * Once a batch is locked by the itrds you need to keep passing the lock code 
oRamsDataServer.oBatch.cBatchLockCode = oRamsDataServer.oBatchLog.cBatchLockCode
        llSuccess = oRamsDataServer.oBatch.Save()
      If NOT llSuccess
            * Handle error. Don't forget to either delete or unlock the batch
            Return .f.
      EndIf
EndScan

* Unlock Batch
If not oRamsDataServer.oBatchLog.UnLockBatch(lcBatchNumber)
      * Handle error
EndIf

8/02/2012 7:34:00 PM
4. Web Service New Account

This is the documentation for a WEB Service method which is used to create a new customer in RAMS. It should be possible that with this one method, all setups are performed so that the customer is placed on the route and charges, work orders and route comments are setup and routed in the service diagram.

Public Function CustomerSavewithRouteandCharge(ByVal Connection as String, _

        ByVal System as String, _

        ByVal ITUser as String, _

        ByVal ITUserPass as String, _

        ByVal RamsUser as String, _

        ByVal RamsUserPass as String, _

        ByVal Table as String, _

        ByVal dsRecord as DataSet, _

        ByVal TemplateAccount as String, _

        ByVal CommentType as String, _

        ByVal Comment as String, _

        ByVal WODate as Date, _

        ByVal WOType as String, _

        ByVal WOCommentType as String, _

        ByVal WOComment as String, _

        ByVal WOServiceDescription as String, _

        ByVal WOAddServiceDescription as Boolean, _

        ByVal AddStreetIfnotFound as Boolean, _

        ByVal RoutesID as String, _

        ByVal RouteCycleID as String, _

        ByVal RouteDay as String, _

        ByVal RouteNumber as String, _

        ByVal RouteStartDate as Date, _

        ByVal ChargeServiceCode as String, _

        ByVal ChargeCycle as String, _

        ByVal ChargeOverridePrice as Decimal, _

        ByVal ChargeUnits as Decimal, _

        ByVal ChargeComment as String, _

        ByVal AddChargetoRoute as Boolean, _

        ByVal RouteComment as String, _

        ByVal RouteCommentType as String, _

        ByVal RouteCommentStartDate as Date, _

        ByVal AddRouteCommentToRoute as Boolean) as Data

Remarks

It works as follows
1. Logs into RAMS using the RamsUser and RamsUserPass (it will fail if these aren't valid. It also logs this account against any items it creates
2. Creates a new RAMS Account using ;

·         a. The default values of the "TemplateAccount" if provided as Per RAMS core function

·         b. Any customer table field values provided in the "dsRecord" dataset


3. If a comment type "CommentType" is provided then it creates customer comment with type "CommentType", and comment ""Comment"
4. If a Work order type is provided then it creates a work order of type WOType, Date of "WODate", Description of "WOServiceDescription" if "AddStreetIfnotFound"is True
5. Creates any Tray items associated with this Work Order type as per RAMS core setup
6. If a work order comment type is provided it creates a work order comment of type "WOCommentType", comment of "WOComment"
7. Creates a Route Record using "RouteNumber", "RouteDay", "RouteStartDate" and "RouteCycleID"
8. Creates Charge record using "ChargeServiceCode", "ChargeUnits", "ChargeOverridePrice", "ChargeCycle" and "ChargeComment"
9. If "AddChargetoRoute" is set to true then it also assigns the new charge to the passed in route in the service diagram
10. If "RouteCommentType" is provided then it creates a route comment of type "RouteCommentType", Start date of "RouteCommentStartDate" and Comment of "RouteComment"
11. If "AddRouteCommentToRoute" is true then it assigns this route comment to the route record in the Service Diagram

8/02/2012 8:17:00 PM




Featured

Testimonials

I really didn't think the site would ever do all this. I am soooo happy, you have no idea!

Crystal Foster 

This Web solution has been great at freeing up time for our operations staff. Now our customers pay their bills, make bookings and request new services online while our staff is busy doing other things.

Doug John

Latest News

Customer Signup Wizard - Monday, 10 December 2012
Just released, a new customer signup wizard for your web site.  Customers can get area based pricing, service days and terms and conditions all in one wizard. Once they confirm, the system creates a new account in RAMS AND does all the route and charge setup for you so there is no need for user intervention from your office.  Time saver!