Effective use of RVSpy in Sage300 development
Last week there was a post on the Sage300/Accpac VBA forum asking how to automate the Reversals function in Bank Services. In short the responses were: macro recording didn’t work; the view was clumsy and difficult; and the best method to automate would be to mimic the entry via SendKeys.
Given that macro recording is not supported by the bank reversals function, it is necessary to use RVSpy to understand the view calls. This post will describe the various tips and tricks we use when we have to use RVSpy, using the reversals example as per the forum post.
A copy of the final source code and the RVSpy log can be found at the bottom of the post.
Filter the view calls
By default RVSPY captures all calls which leads to an extremely verbose and sometimes incomprehensible log file. Filtering the view calls to remove all the metadata and get requests will significantly trim the log file to the calls which are most important.
- Filter view calls: Fields, Field, Attribs, Type, Get, Name, Presents, FieldName & FieldExists
- Turn off ‘Show Nesting’: Typically you are only interested in calls the UI makes, and not calls views made to other views.
In our example the size of the generated log went from 1.8MB unfiltered to 427KB filtered.
Recording the entry
Try to enter the values into each field. Using the finder will significantly add to the log and can make it difficult to understand (see below, for exceptions).
Before you do something major such as posting, or adding an entry, insert a comment into the log. It will help you later on to identify the event in the log file and will also provide you with a cutoff where major processing is performed by the view.
The oogily-boogily nature of the Bank Reversals View
If you look at the Bank Reversals view, you can easily understand the trepidation as it appears to have several purposes:
- As a history, where posted reversals can be queried and retrieved.
- The screen supports the ability to select multiple documents to reverse, so there are a range of fields to support the selection process.
- Posting of reversals where there are several fields with conflicting names such as BANK/PBANK and SRCEAPP/PSRCEAPP.
The other major issue is around the view protocol: ‘Flat, Ordered Revisions’.
- Flat Protocol: Flat is simply a list or table of records with no hierarchical element; a lot of the setup views such as Account Sets are flat.
- Ordered Revision: Ordered Revisions means that an internal list of changes are maintained in memory until a Process or Post command is given. In our example an Insert is performed prior to the Process. If processing multiple reversals, each reversal would be Inserted before the Process performs the reversals as a batch operation.
Understanding Your Log File
After recording is complete, you need to now understand the log file.
In our example the two major issues were the fields we needed to set, and the calls required to post the reversal.
To understand the fields which need to be set, search for ‘Put’. In our example the first put is to PBANK to set the bank code. One thing to note is that RVSpy uses field numbers as opposed to names, so you will need to translate these into names using the Accpac Object Model.
Continue searching and you will find Puts to PAYORID, TRANDATE, and REASON fields.
Next you will find Puts to two key fields SERIAL and LINENO.
These two fields were a little confusing at first but we know they had to do with the transaction being reversed. In both recordings we made we actually used the finder to select the transaction we were to reverse. Prior to the two Put statements we could see the finder searching BKTRANH & BKTRAND, thus the two values corresponded to the keys in these tables.
The final step was to search for the comment we made before we posted the reversal.
Three actions were performed:
- Inserting the record into the view.
- Switching the view mode to ‘Process Reversal Selections’.
- Issuing Process to process the reversal.
It may be necessary to record something more than once. You may enter something incorrectly, or you may need to repeat an action to understand each call; but with effective use, RVSpy is the best or only tool to understand those Sage300 views/screens which do not support macro recording.Download Bank Services Reversals source code