You shouldn't be utilizing the same relationship as the UI and closing the set. Leave that to the UI framework to close when the user navigates away from the record. That should avoid your closed connection errors you're seeing.
Unrelated to your question, be aware that utilizing the UI sets is a mixed bag. It's great for most use cases because you can get the in memory values, such as a value from the header record to bring down to children records. But you run the risk of a user filtering the result set in a way that breaks your validation. For example, if I filter for polinenum=1 on the PO Line table in the PO application, my set is going to have 1 record even though there might be 10+ lines.
Without knowing your customization, you seem to be trying to validate that something exists in both tables. If they're added at the same time (IE you have to add the object to each child object before you can save) you'll be OK because a user can't filter a set when there are pending changes to save. But if you add the receipt to Maximo first and then add into your custom object later, just be aware that records may be filtered from your view.
When looping, avoid counts as they execute an unnecessary count query against the database when you're just trying to iterate. You can simply do:
i=0
while aSet1.getMbo(i):
pokMbo1=aSet1.getMbo(i)
# logic here
i+=1
------------------------------
Steven Shull
Director of Development
Projetech Inc
Cincinnati OH
------------------------------
Original Message:
Sent: Wed April 14, 2021 06:17 AM
From: Blaz Rakar
Subject: Maximo error invalid operation result set is closed
Hello, I created custom automation script which works, but while I was testing I got errors like this.
BMXAA6713E - The MBO fetch operation failed in the mboset with the SQL error code {0}. The record could not be retrieved from the database. See the log file for more details about the error.
BMXAA6713E - The MBO fetch operation failed in the mboset with the SQL error code -4470. The record could not be retrieved from the database. See the log file for more details about the error.
com.ibm.db2.jcc.am.SqlException: [jcc][t4][10120][10898][3.68.61] Invalid operation result set is closed. ERRORCODE=-4470, SQLSTATE=null
My idea of script is to create two list, at first I get values without duplicates from table MATRECTRANS in applications from column MXZPORECEIPTNUM and at second list I get values without duplicates from my custom table MXZPAKGAGE. Then at the end I check if some of value from list1 is missing in list2 then throw error when user try save record, this works but when I click at green arrow I get errors when I mentioned before.
It works If I throw warning instead error, but then user could save record but that I dont want.
Any help?
I must add, that even I try with script just to try errorgroup and errormessage without any conditions I get error which I mentioned.



------------------------------
Blaz Rakar
------------------------------
#AssetandFacilitiesManagement
#Maximo