Is there a way to test for a program that has gone onto message wait on an AS400 system?
My VB program is currently hanging because the AS400 program is expecting a reponse due to a function check etc. I've tried a couple of different methods...
Method 1 - ADODB.Connection Program just hangs at con400.Execute...
Private Function ExecuteAS400Cmd(ByRef con400 As ADODB.Connection, strCmd As String) As Boolean
On Error GoTo AS400_Error
con400.Execute "CALL QSYS.QCMDEXC('" & strCmd & "', " & Format(Len(strCmd), "0000000000") & ".00000)"
ExecuteAS400Cmd = True
Dim lErrNo As Long
Dim sErrMSG As String
Dim sErrSource As String
lErrNo = .Number
sErrMSG = .Description
sErrSource = .Source
Err.Raise lErrNo, sErrMSG, sErrSource
Method 2 - IBM Client Access Express Activex Objects Program hangs at objAS400Command.Run
Private Function IBMExecuteCommand(SystemName As String, CommandString As String) As Boolean
Dim objAS400Command As cwbx.Command
'// Create new command object
Set objAS400Command = New cwbx.Command
'// Create new as400 system object
Set objAS400Command.System = New cwbx.AS400System
'// Define the system and sign on
.System.UserID = "MYUSER"
.System.Password = "MYPASSWORD"
'// Run the command
If objAS400Command.Errors.Count > 0 Then
IBMExecuteCommand = True
Does anyone have any idea how to execute the command, then test for the response, handling any possible MSGW status or other errors on the AS400 system?
It would be hard for me to judge whether something has timed out due to an actual AS400 program error or if the program is just taking a long time to finish! The data going into the program will vary considerably...so I couldn't just put '30 secs' and assume anything over this is an error.
I suppose what I really need to do is submit the job rather than calling interactively, retrieve a handle to the job, then monitor it for completion or message waits...
Batch on as 400 could be a solution: it could write on a file if any matter arise,
and you could read from it via Vb to know....it might be easier linking teh "msg
file" via access and then reading the access "table" (Iouri used to, and could be
the one to contact if you need details)
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Well I've managed to submit the job under its own name now, my program wont hang anymore because I am submitting rather than calling interactively...
Private Function RunCommandMonitorQue(SystemName As String)
'// Each of these variables are provided from the ActiveX object provided by IBM
Dim objAS400 As cwbx.AS400System
Dim objAS400Cmd As cwbx.Command
Dim objdQueue As cwbx.DataQueue
Dim strData As String
Dim sJobCommand As String
' // Setup AS400 Session object. This signs on and provides you with a session. At this point a new
' // QTEMP library is provided
Set objAS400 = New cwbx.AS400System
.UserID = "MYUSER"
.Password = "MYPWD"
'// Build the submit command job
sJobCommand = "SBMJOB CMD(CALL PGM(MMHOFPLT/COR050CL)) JOB(COEDIDATA) JOBQ(QS36EVOKE) LOG(4 *JOBD *SECLVL) LOGCLPGM(*YES)"
' // Add any libraries required by the job
Set .System = objAS400
.Run sJobCommand '// Job submit here!
'// THIS IS WHERE I NEED TO WRITE CODE TO MONITOR FOR THE RESULTS...
'// NEED TO FIGURE OUT HOW TO GET A 'HANDLE' TO THE JOB I HAVE SUBMITTED
'// AND READ ITS OUT Q / MESSAGE Q??
Set objAS400 = Nothing
Set objAS400Cmd = Nothing
This is all good, but at the moment my VB interface will just return OK because it has submitted a job - regardless of the outcome of that job.