In the previous article “Dealing with the Python time module from Rocket MV BASIC” I showed how it is possible to access the python internal time module and convert the python date to string display format, then convert it back into the number of seconds since Epoch.
While it is possible to write a subroutine to handle the interaction between MV BASIC and Python, you can get more from you subroutine if you write it as a User Defined User Exit.
User exits are the codes used in the ICONV and OCONV functions. In the first article of this series we showed how we can call the u2py.DynArray.iconv and u2py.DynArray.oconv functions to convert display dates into internal format, and then convert back into display format:
The limitation on the MV date conversion is that it only deals with the date. There is a separate conversion code that deals with time. The following user defined user exit calls the python module we worked with in the previous article, and exposes it to the MV Developer as a conversion code that handles timedate values.
Note that this is a simple example that handles limited formats and does minimal error checking. Yet it allows us to create a display formatted date from the internal python representation, which is the number of seconds from Epoch.
Another benefit of having the code as a user defined user exit is that it works in a dictionary item as well.
While this is a simple example, there are countless uses for accessing python modules in this manner. A quick search of python.org will surely show numerous modules that you may want to access to add additional information to your MV Query Reports.