B4J Question run a program on iseries AS/400

C

Corrado Zamponi

Guest
Hello to all,
can someone show me, how to call a batch program on iseries AS/400 using JT400.jar ?
with VB I use this code:

B4X:
Dim xx As String = "{{CALL PGM(" & ProgramName.ToString.Trim & ") PARM('" & Format(Param1, "00000000") & "')}}"
Dim Cmd2 As New OleDb.OleDbCommand(xx, ConnAS400)
Cmd2.ExecuteNonQuery()

With jt400.jar I can access to DB, but I do not understand how run a program

Thank a lot
Corrado
 
Last edited by a moderator:
C

Corrado Zamponi

Guest
Sorry for the synthetic previous answer Erel,
exatcly, IBM prepared a jdbc tools for access to iseries as/400 : JT400.jar via ODBC.
I tried with a simply select (listed below) and it work fine and quickly:

B4X:
Dim SQL1 As SQL
SQL1.Initialize2 ("com.ibm.as400.access.AS400JDBCDriver","jdbc:as400:AS400Name;database name=S06C015P;prompt=false;translate binary=true;naming=system;",UserName,Password)
LogDebug (SQL1.IsInitialized)
....
Dim Rst As ResultSet
Rst=SQL1.ExecQuery("Select * from IIML01 Where iprod='" & TX_codice.Text.ToUpperCase & "'")
If Rst.NextRow=True Then
LB_descrizione.Text=  ( Rst.GetString("IDESC"))
LogDebug (Rst.ColumnCount).

I do not understand how run a program on AS/400.


Thanks again
 
Last edited by a moderator:
Upvote 0
C

Corrado Zamponi

Guest
for both statements return the same error:

B4X:
SQL1.ExecNonQuery ("{{CALL PGM(V82ZATOO/SFCZ57B2)}}")
SQL1.ExecQuery ("{{CALL PGM(V82ZATOO/SFCZ57B2)}}")

Waiting for debugger to connect...
Program started.
true
Error occurred on line: 73 (Main)
java.sql.SQLSyntaxErrorException: [SQL0206] Colonna o variabile globale V82ZATOO non trovata.
at com.ibm.as400.access.JDError.createSQLExceptionSubClass(JDError.java:782)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:661)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:631)
at com.ibm.as400.access.AS400JDBCStatement.commonPrepare(AS400JDBCStatement.java:1401)
at com.ibm.as400.access.AS400JDBCStatement.execute(AS400JDBCStatement.java:1755)
at anywheresoftware.b4j.objects.SQL.ExecNonQuery(SQL.java:148)
at b4j.example.main._button1_action(main.java:110)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:226)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA$2.run(BA.java:165)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)


I also found this documentation, if it may be helpful:
http://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_71/rzahh/pgmc.htm
 
Last edited by a moderator:
Upvote 0
C

Corrado Zamponi

Guest
I asked for lights to IBM support: on OS/400 there is a simplified stored procedure QSYS2/QCMEXC, that can be used by the way.
In fact through ExecNonQuery or ExecQuery It works fine.

I add some code, if it can help someone.

B4X:
 Dim a As String
 a="CALL QSYS2.QCMDEXC ('CALL PGM(Lib/Pgm)') "
 Try
 SQL1.ExecNonQuery  (a)    ' Or  SQL1.ExecQuery  (a)
Catch
 Log(LastException.Message)
End Try

Thanks for comparison.

Corrado
 
Upvote 0
Top