Rocket U2 | UniVerse & UniData

 View Only

 U2 UniVerse uopy Subroutine Error [30107]

Jump to Best Answer
  •   UOPY
Andrew Kriger's profile image
Andrew Kriger posted 12-15-2021 17:09
Just started working with the uopy python library. I'm able to connect successfully and run all the basic examples provided with no issues, but as soon as I started to extend it out to run some subroutines I've written, I started getting "Subroutine Error [30107] : The subroutine failed to complete successfully". Not entirely sure what would cause this as the same subroutine runs fine when ran outside of uopy. One thing I did notice is if I remove the READV statement within the subroutine, I do not receive this error. Below is the test subroutine I have been using.

Any help greatly appreciated.

SUBROUTINE (USER,JSON)
$INCLUDE UNIVERSE.INCLUDE UDO.H

READV USER.NAME FROM INIFILE,USER,3 ELSE NAME = ''

STATUS = UDOCreate(UDO_OBJECT, testObj)
STATUS = UDOSetProperty(testObj, "userName", USER.NAME)
STATUS = UDOWrite(testObj, UDOFORMAT_JSON, TEST)
STATUS = UDOFree(testObj)

JSON = TEST

RETURN​
Mike Rajkowski's profile image
ROCKETEER Mike Rajkowski Best Answer
Andrew,

The error you are getting is caused by trying to read from a file that was not opened, or is having issues with the opened file.  To help you debug this try putting an "ON ERROR" clause on the read statement and return and error.

 Note that while I expect that this is a learning exercise, I would recommend doing this all from Python, and only using uopy to read the user name from the file.
Andrew Kriger's profile image
Andrew Kriger
Thanks @Mike Rajkowski.

The way our system is setup is when you login it runs a program that opens a lot of commonly used files so they are "assumed" open in most other programs that run after login. Since uopy is calling directly to the Subroutine they obviously weren't open.  I now call the routine to open these files first then did the rest of my test routine and it worked flawlessly. Thank you for your help! ​