Link to home
Start Free TrialLog in
Avatar of hapibooda
hapiboodaFlag for United States of America

asked on

Detect QSYSOPR message in MS Access VB function?

I've created a Visual Basic function that runs an AS/400 CL program.  The function is called when a button on a form is clicked.

Access receives messages from the AS/400 as long as the message is not waiting on a response.  Is it possible to create a VB error handler when there is a message waiting in the QSYSOPR message queue?
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

I'd suspect so, but how you handle this would depend on how the "messages" are received and processed by Access. Do you use a third party object to do this, a DLL/OCX etc? In other words, how does Access "receive" the messages from the AS/400?
Avatar of hapibooda

ASKER

Access receives the AS/400 messages through an ADODB connection.
How does Access know a message has been received via the ADO connection? Does Access somehow moniter the connection?
According to MS TechNet: "ADO uses an errors object and errors collection to return standard error information such as SQLSTATE, native error number, and the error message string. These are the same as their ODBC counterparts."
Avatar of Member_2_276102
Member_2_276102

Minor note... It's almost certain that you will not want the QSYSOPR message queue allocated to some Windows function. Usually this message queue should never be allocated to _any_ process except an actual QSYSOPR interactive session.

Allocation to an external process can interfere with usage of that message queue for system operation tasks. Sooner or later, there will be a conflict.

Tom
I agree with you tliotta.  I am only interested in receiving a message in Access that tells the user there is a message waiting in QSYSOPR.  I do not want to send the reply through Access to QSYSOPR.

If Access can receive a message from QSYSOPR, I'd like the VB function to exit and display a message box indicating a message is in QSYSOPR waiting on a reply.  I don't want the ADO connection to remain open waiting on a reply.
<According to MS TechNet: blah blah>

Yes, but errors only occur in response to something (at least in a perfect world <g>) ... at some point, Access/VB/ADO must do _something_ in order for an error to occur. If you open an ADO connection and constantly moniter the Errors collection, you might be able to determine what is occurring, but I'm not an AS/400 expert by any means so don't know what you should look for. My point was simply - how does Access receive the "message" ... I understand you'll have a connection to the database, but how does that connection receive messages? In VB/Access you'd need to moniter the connection in some way (i.e. use a Form Timer and loop through, checking the Errors collection to see what's happening).

hapibooda:

Then the issue is that an Access/ADO function causes a message to QSYSOPR. In an interactive session, for example, this would result in a message back that session that "Message needing reply sent to QSYSOPR". Such a message would be visible in that case; but in a batch process, there is no clear visibility. You're looking to locate that message that directs the user to QSYSOPR.

Okay, much clearer. Interesting question. I'll see if I can track it down if no one knows off the top of their head.

Tom
ASKER CERTIFIED SOLUTION
Avatar of hapibooda
hapibooda
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Closed, 250 points refunded.
Vee_Mod
Community Support Moderator