Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1871
  • Last Modified:

Call AS/400 CL Program from Visual Basic

How do I call a CL Program in the AS400 Machine from my VB Application?

I use ADO and ODBC to connect to AS400 and the connection object is: gJDEConnection

The program I need to call:
'DBTEST is the Library and J57COMTEST is the CL program.

Can anyone give me sample code?, I tried different variations of CALL QSYS. blah blah blah, but doesn't work, so I am looking for code samples.

And if I am able to call a CL Program, what happens if an error occurs in the CL Program, Do I get the error back to my VB APP?


Thanks
Chandu

0
chandukb
Asked:
chandukb
  • 3
  • 2
  • 2
1 Solution
 
iboutchkineCommented:
First set the connection to AS400 and then run your Cl on command object

Dim cmd As ADODB.Command

Set cmd = New ADODB.Command

With cmd
    .ActiveConnection = cn
    .CommandText = "call J57COMTEST.DBTEST"
    .Execute
End With

Set cmd = Nothing
Exit Sub

You are not going to get error back to VB. Come with something how to trap this error. For example you can use timer to time out if CL was not executed.
0
 
NazdorCommented:
Just as an extra, you could use a message queue to send/receive information between the VB prog and the CL prog - but it's not exactly an easy task...
0
 
chandukbAuthor Commented:
I am calling the CL program using the command object, but
my whole application freezes and task manager shows my app
Not Responding state.  If there is any error in CL program,
my vb app should get an error right?  Why is it Not Responding state?

Any ideas/suggestions?

Chandu
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
chandukbAuthor Commented:
Nazdor,

Any Links for message queue between vb and cl programs.

Thanks
Chandu
0
 
iboutchkineCommented:
If you have an error in CL, you will not get an error in VB. I tried it many times. Check your CL
0
 
NazdorCommented:
Your VB app will be completely 'frozen' until the 400 returns.  This will look like "Not Responding", but if the 400 does finish, then it will start responding again.  This has to do with the badly-written ODBC drivers being used by the command object.  If the 400 never returns because it's stuck with an error, then your VB program will probably not start either.

You could try different ODBC drivers, eg from HiT or maybe change the commandtimeout value.

You wont ever get a 'reply' from the CL as there's no way for the VB prog to receive the return code of the program.



I'll have a look for those links and let you know later - but there should be some on the search part of the IBM site.
0
 
chandukbAuthor Commented:
I still can't figureout how to get the error from CL program, but your comments gave good direction.

Thanks
Chandu
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now