ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Calling 400 program from VB6

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling 400 program from VB6

    I want to call 400 program from my VB6 program. Here is my code:
    PHP Code:
    ======================
       
    Dim MetalNet As cwbx.AS400System
        Dim MetalNetPgm 
    As cwbx.Program
        Dim PgmParms 
    As cwbx.ProgramParameters
        Dim strCnvtr 
    As cwbx.StringConverter
        
        Set MetalNet 
    = New cwbx.AS400System
        Set MetalNetPgm 
    = New cwbx.Program
        Set PgmParms 
    = New cwbx.ProgramParameters
        Set strCnvtr 
    = New cwbx.StringConverter
        
        Call MetalNet
    .Define("mySystem")
        
    Set MetalNetPgm.System MetalNet

        MetalNetPgm
    .System.UserID "myuserid"
        
    MetalNetPgm.System.Password "mypassword"
        
    MetalNetPgm.System.Connect (cwbcoServiceRemoteCmd)
        
    MetalNetPgm.libraryName "mylib"
        
        
    If MetalNetPgm.System.IsConnected(cwbcoServiceRemoteCmdThen
            MetalNetPgm
    .System.Disconnect (cwbcoServiceRemoteCmd)
            
    MetalNetPgm.System.Connect (cwbcoServiceRemoteCmd)
        
    End If
        
        
    MetalNetPgm.ProgramName "MYPGM"
        
        
    Call PgmParms.Append("PARM1"cwbrcInput4)
        
    Call PgmParms.Append("PARM2"cwbrcInput6)
        
    Call PgmParms.Append("PARM3"cwbrcInput9)

        
    PgmParms("PARM1").Value strCnvtr.ToBytes("2006")
        
    PgmParms("PARM2").Value strCnvtr.ToBytes("EIR")
        
    PgmParms("PARM3").Value strCnvtr.ToBytes("1100019")
        
        
    Call MetalNetPgm.Call(PgmParms
    ==========================

    when it acutally calls the 400 program (at last line), this VB program hangs. Could anyone tell me why???

    Thank you in advance!
    Last edited by Hopehe; August 22, 2008, 02:24 PM. Reason: formatting

  • #2
    Re: Calling 400 program from VB6

    Which program hangs? The one on the 400 or the VB program?
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

    Comment


    • #3
      Re: Calling 400 program from VB6

      Sorry i wasn't clear. The VB program hangs.

      Comment


      • #4
        Re: Calling 400 program from VB6

        Is the 400 program finishing? How does the vb program know that the 400 program is done? Is anything returned?
        Your future President
        Bryce

        ---------------------------------------------
        http://www.bravobryce.com

        Comment


        • #5
          Re: Calling 400 program from VB6

          It only takes a second to run the 400 pgm if I run it from the 400 command line. There is no return parms for this 400 program - it just updates a file.

          Thanks

          Comment


          • #6
            Re: Calling 400 program from VB6

            Don't take this question the wrong way... But did you verify that the update program ran on the 400 after calling it from the VB program? I'm sure you probably did, I just need to ask.

            What happens in the VB code after you call the 400 program?
            Your future President
            Bryce

            ---------------------------------------------
            http://www.bravobryce.com

            Comment


            • #7
              Re: Calling 400 program from VB6

              i found this @ one of those other sites



              Here's a pretty simple way of calling a program on the AS/400. No library list is set up when you call the program so you have to override any database files to their correct
              library.

              Public conn As ADODB.Connection
              dim cmdCallPgmString as string

              'Set cnAcctPay = New ADODB.Connection
              Set conn = New ADODB.Connection
              Set cmdCallPgm = New ADODB.Command
              With conn
              .Mode = adModeReadWrite
              conn.Provider = "IBMDA400"
              conn.Properties("Data Source") = "AS/400 Serial Number" 'Sxxxxxxx
              conn.Open
              End With

              cmdCallPgmString = "{{CALL LIBRARY.Program(?,?)}}" '? = Parameters to program if any

              With cmdCallPgm
              .ActiveConnection = conn
              .CommandType = adCmdText
              .CommandText = cmdCallPgmString
              .Prepared = True
              End With

              cmdCallPgm.Parameters.Append cmdCallPgm.CreateParameter(Name:="P1", _
              Type:=adChar, _
              Direction:=adParamInput, _
              Size:=8, _
              Value:=sdate)

              cmdCallPgm.Parameters.Append cmdCallPgm.CreateParameter(Name:="P2", _
              Type:=adChar, _
              Direction:=adParamInput, _
              Size:=8, _
              Value:=edate)
              cmdCallPgm.Execute

              You can also look at this. Very helpful:

              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment


              • #8
                Re: Calling 400 program from VB6

                Which library list the vb program will use to call the 400 program ?

                Just my 0.02 $.
                Last edited by Mercury; August 22, 2008, 04:06 PM.
                Philippe

                Comment

                Working...
                X