Solved

What is the Library that the WRKSPLF command resides in?

Posted on 2008-10-15
8
1,662 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 35

Expert Comment

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

- Gary Patterson

0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 35

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
 
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 35

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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
#Citrix #POC #XenDesktop #vCenter #VMware #ESX
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

617 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