-
February 24th, 2005, 07:35 AM
#1
Test for AS400 program MSGW?
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...
Code:
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
AS400_Resume:
Exit Function
AS400_Error:
Dim lErrNo As Long
Dim sErrMSG As String
Dim sErrSource As String
With Err
lErrNo = .Number
sErrMSG = .Description
sErrSource = .Source
End With
Err.Raise lErrNo, sErrMSG, sErrSource
Resume AS400_Resume
End Function
Method 2 - IBM Client Access Express Activex Objects
Program hangs at objAS400Command.Run
Code:
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
With objAS400Command
.System.Define SystemName
.System.UserID = "MYUSER"
.System.Password = "MYPASSWORD"
.System.Signon
End With
'// Run the command
objAS400Command.Run CommandString
If objAS400Command.Errors.Count > 0 Then
Else
IBMExecuteCommand = True
End If
End Function
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?
Thanks
-
February 24th, 2005, 07:46 AM
#2
Re: Test for AS400 program MSGW?
Coonnection timeout could help?
...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.
-
February 24th, 2005, 07:54 AM
#3
Re: Test for AS400 program MSGW?
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...
Got to try and figure out how though..!!
-
February 24th, 2005, 09:00 AM
#4
Re: Batch...
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.
-
February 28th, 2005, 06:28 AM
#5
Re: Test for AS400 program MSGW?
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...
Code:
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
With objAS400
.Define SystemName
.UserID = "MYUSER"
.Password = "MYPWD"
.Signon
End With
'// 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
With objAS400Cmd
Set .System = objAS400
.Run sJobCommand '// Job submit here!
End With
'// 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
End Function
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.
Hmmmmmm.....??!
-
February 28th, 2005, 07:33 AM
#6
Re: Test for AS400 program MSGW?
and so, have the as400 set a flag somewhere where you can read from vb (say
access linked table, looping till something enter there) to know if job is running,
is waiting, is finished ?...
...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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|