Solved

Call AS/400 CL Program from Visual Basic

Posted on 2001-06-26
7
1,617 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Author Comment

by:chandukb
Comment Utility
Nazdor,

Any Links for message queue between vb and cl programs.

Thanks
Chandu
0
 
LVL 28

Expert Comment

by:iboutchkine
Comment Utility
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
Comment Utility
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
Comment Utility
I still can't figureout how to get the error from CL program, but your comments gave good direction.

Thanks
Chandu
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 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

13 Experts available now in Live!

Get 1:1 Help Now