Solved

What is the Library that the WRKSPLF command resides in?

Posted on 2008-10-15
8
1,606 Views
Last Modified: 2013-12-06
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

0
Comment
Question by:pprater1
8 Comments
 

Author Comment

by:pprater1
ID: 22724479
Sorry about the code above.  In CreateNew, Line 45 IS NOT commented out.  This was something I was testing
0
 
LVL 5

Expert Comment

by:JBart_17
ID: 22725098
the CMD object it should be in QSYS
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 22725249
WRKSPLF is a command, not a program.  Use cwbx.Command to invoke it.

- Gary Patterson

0
 
LVL 34

Accepted Solution

by:
Gary Patterson earned 250 total points
ID: 22725844
Every AS/400 native object has an object type.  

You use cwbx.Program to execute *PGM (Program) objects.  You use cwbx.Command to invoke *CMD (Command) objects.  Command objects are front ends to *PGM objects that provide interactive (green-screen) prompting and validation of parameters, and then perform a behind-the scenes CALL to the command processing program that is associated with the *CMD object.  

IBM does not document the parameters for IBM-supplied command processing programs (like the QSYS/QSPWRKF *PGM that is the CPP for the QSYS/WRKSPLF *CMD), only the parameters or the *CMD object.


- Gary Patterson
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 27

Expert Comment

by:tliotta
ID: 22726836
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
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 22727017
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
0
 

Author Comment

by:pprater1
ID: 22727508
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.
0
 

Author Comment

by:pprater1
ID: 22727613
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!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
#Citrix #POC #XenDesktop #vCenter #VMware #ESX
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now