Solved

Call AS/400 CL Program from Visual Basic

Posted on 2001-06-26
7
1,661 Views
Last Modified: 2013-11-25
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
Comment
Question by:chandukb
  • 3
  • 2
  • 2
7 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 100 total points
ID: 6231221
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
 
LVL 4

Expert Comment

by:Nazdor
ID: 6252008
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
 
LVL 2

Author Comment

by:chandukb
ID: 6253950
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 2

Author Comment

by:chandukb
ID: 6253953
Nazdor,

Any Links for message queue between vb and cl programs.

Thanks
Chandu
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 6255577
If you have an error in CL, you will not get an error in VB. I tried it many times. Check your CL
0
 
LVL 4

Expert Comment

by:Nazdor
ID: 6256133
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
 
LVL 2

Author Comment

by:chandukb
ID: 6328063
I still can't figureout how to get the error from CL program, but your comments gave good direction.

Thanks
Chandu
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 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