Link to home
Start Free TrialLog in
Avatar of pprater1
pprater1

asked on

What is the Library that the WRKSPLF command resides in?

I am using the i Series Access for Windows cwbx.dll module to make remote calls to an AS400 machine for the first time.  I have posted the code below as to the method I am using.  The jist of the code is there is 2 buttons 1) Connect and 2) Send command - some text boxes are filled in (IP, UserID, Password, Library, Program.  Right now I am testing just the WRKSPLF call which is why the parameter building is static.  The library I am entering in the txtLibrary textbox is QSYS and the program in txtProgram is WRKSPLF.  When I run this code it gives me the message

MCH3401 - Cannot resolve to object WRKSPLF. Type and Subtype X'0201' Authority X'0000'.

I assume that I am not using the right Library.  Keep in mind that I am a .NET developer and am ignorant to most AS400 terminology and technique.
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
        CreateNew(txtIP.Text, txtUserID.Text, txtPassword.Text, _
                  txtLibrary.Text, txtProgram.Text)
    End Sub
 
 
 Private Sub btnSendCommand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendCommand.Click
        Dim stringConverter As cwbx.StringConverter = New cwbx.StringConverterClass()
        'Dim parameters As cwbx.ProgramParameters = New cwbx.ProgramParametersClass()
 
        'parameters.Append("Parameter1Name", cwbx.cwbrcParameterTypeEnum.cwbrcInout, 12)
        'stringConverter.Length = 12
        'parameters("Parameter1Name").Value = stringConverter.ToBytes("SomeString".PadRight(12, " "c))
 
 
        Dim prmParameterList As New cwbx.ProgramParameters
        Dim prmParameter As cwbx.ProgramParameter
 
        Try
            prmParameter = prmParameterList.Append("PRINTPARAM", cwbx.cwbrcParameterTypeEnum.cwbrcInout)
            stringConverter.Length = 6
            prmParameter.Value = stringConverter.ToBytes("OUTPUT (*PRINT)".PadRight(15, " "c))
 
            SendCommand(prmParameterList)
        Catch ex As Exception
            Output("Error sending command" & vbCrLf & ex.Message)
        End Try
    End Sub
 
Public Sub CreateNew(ByVal strAS400 As String, ByVal strUserID As String, _
                         ByVal strPassword As String, ByVal strLibrary As String, _
                         ByVal strProgram As String)
        If Not mblnConfigured Then
            as400 = New cwbx.AS400SystemClass()
            prgAS400Program = New cwbx.Program()
 
            Try
                as400.Define(strAS400)
 
                Try
                    With prgAS400Program
                        .system = as400
                        .system.UserID = strUserID
                        .system.Password = strPassword
                        '  .libraryName = strLibrary
                        .ProgramName = strProgram
                    End With
                Catch e As Exception
                    as400 = Nothing
                    prgAS400Program = Nothing
                End Try
 
                Try
                    as400.Connect(cwbx.cwbcoServiceEnum.cwbcoServiceRemoteCmd)
                                    Catch ex As Exception
                End Try
            Catch ex As Exception
                as400 = Nothing
                prgAS400Program = Nothing
            End Try
 
        End If
    End Sub
 
  Public Sub SendCommand(ByRef prmParameterList As cwbx.ProgramParameters)
        Try
            If as400.IsConnected(cwbx.cwbcoServiceEnum.cwbcoServiceRemoteCmd) = 0 Then
                '  Lost connection with the AS400. Disconnect, then reconnect. 
                as400.Disconnect(cwbx.cwbcoServiceEnum.cwbcoServiceAll)
                as400.Connect(cwbx.cwbcoServiceEnum.cwbcoServiceRemoteCmd)
            End If
 
            prgAS400Program.Call(prmParameterList)
        Catch e As Exception
 
           ' Capture to log the errors
            If as400.Errors.Count > 0 Then
                Dim intAS400IX As Int16 = 0
 
                ' Log something here. 
                For Each [error] As cwbx.Error In as400.Errors
                    intAS400IX += 1
                Next
            End If
 
            If prgAS400Program.Errors.Count > 0 Then
                Dim intPRGIX As Int16 = 0
 
                ' Log something here. 
                For Each [error] As cwbx.Error In prgAS400Program.Errors
                    intPRGIX += 1
                Next
            End If
 
        End Try
 
    End Sub

Open in new window

Avatar of pprater1
pprater1

ASKER

Sorry about the code above.  In CreateNew, Line 45 IS NOT commented out.  This was something I was testing
the CMD object it should be in QSYS
Avatar of Gary Patterson, CISSP
WRKSPLF is a command, not a program.  Use cwbx.Command to invoke it.

- Gary Patterson

ASKER CERTIFIED SOLUTION
Avatar of Gary Patterson, CISSP
Gary Patterson, CISSP
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
pprater1:

Gary's comments above are very appropriate. Can you describe what you want to do?

The WRKSPLF command wouldn't seem as useful for .NET as something like the wrksplf.exe that's part of iSeries Access. Or perhaps even better:

http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/rzaik/rzaikappobj.htm
and/or
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/rzaik/rzaiksoa.htm

About the only thing you can do with the WRKSPLF *CMD object from .NET would be to generate a printed list of spooled files; and then you have to figure out what to do with that printed list. But the .exe and the .dlls might give you some ideas.

Tom
pprater1:

Tom brings up a good point.  

I thought I understood from your post that you were just experimenting with executing commands and chose WRKSPLF, but if that is not the case, then I certainly agree that there are better ways of manipulating spooled files from .NET than via the WRKSPLF command.

- Gary Patterson
Gary -

You are right, current I am just experimenting with executing commands agains the AS400.  However I did not realize the true difference in a Program/Command and was making some incorrect assumptions.  I am using the WRKSPLF OUTPUT(*PRINT) command because it will generate something that I can see on the AS400 as a successful test.  

I have found the Command object of the cwbx.dll module and am researching this topic.  Any sample code calling commands using the cwbx.Command object would greatly be appreciated.
Gary was correct and it was easier than I expected.  In CreateNew I replaced the configuration of the cwbx.Program object with configuring a cwbx.Command object:

 With comAS400Command
     .system = as400
     .system.UserID = strUserID
     .system.Password = strPassword
 End With

And invoked the command using the .Run procedure:

comAS400Command.Run("WRKSPLF OUTPUT(*PRINT)")

No Library to set.  I believe the end object that will be called on the AS400 is a custom program however, but I will have more details from the developer on this.  Thanks!