Solved

Call AS/400 CL Program from Visual Basic

Posted on 2001-06-26
7
1,682 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
message box in access 4 51
MS Access 03, TransferText, decimal places 8 78
RUNRMTCMD from AS/400 12 69
Please explain purpose of GZIP 4 36
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

828 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