Busco información sobre el uso de programas creados con AS400

¿Cómo puedo conectarme con un programa creado en el AS400? Encontré un poco de cosas en inglés que no me ayudan, ¿se llama CL a un programa creado en el AS 400 o es el nombre que se le tiene que dar al agente que llama al programa?, encontré algo en el foro de IBM que indica una forma de conectarse por ODBC pero no entiendo cuál de todas las líneas es la que crea la conexión, ¿es necesario conocer el nombre del programa junto con sus parámetros o solo se puede crear un agente que sirva como estándar para todos los programas del AS400?
Por favor, necesito que me ayude en este dilema.
Le agradezco de antemano
Adriana

1 respuesta

Respuesta
1
No he probado nunca notes en un Iseries.
Pero, por ejemplo en Win32 si necesitas llamar a un comando de sistema (como por terminal) puedes hacerte un agente como el que te paso que abre el Notepad.exe
Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Declare Function WaitForSingleObject Lib "kernel32" (Byval hHandle As Long, Byval dwMilliseconds As Long) As Long
Declare Function CreateProcessA Lib "kernel32" (Byval lpApplicationName As Long, Byval lpCommandLine As String, Byval lpProcessAttributes As Long, Byval lpThreadAttributes As Long, Byval bInheritHandles As Long, Byval dwCreationFlags As Long, Byval lpEnvironment As Long, Byval lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Declare Function CloseHandle Lib "kernel32" (Byval hObject As Long) As Long
Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (Byval hObject As Long, Byval ExitCode As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
Sub Initialize
RunApp("C:\WINDOWS\notepad.exe")
Msgbox "Wordpad has finished"
End Sub
Public Sub RunApp (program$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
structure:
start.cb = Len(start)
ret& = CreateProcessA(0&, program$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
ret& = CloseHandle(proc.hProcess)
End Sub
Fijate que estoy llamando a una libreria de windows la kernel32.dll creo.
Para iseries debe haber algo parecido.
Si por otro lado deseas crear una conexión ODBC, necesitarias tener un ODBC declarado en el sistema para poder conectarte a el.
Tengo una clase que te ayudará a crear una conexión. Copiala y pegala en una libreria.
Option Declare
Uselsx "*LSXODBC"
'libODBC:
'clsApplication:
'
' Name : clsApplication (An OO class for Database Programming with Lotus Domino)
'
' Development History
' Created : Jan 29, 2003 by Ranjeet Rain ([email protected])
' Last modification : Jan 29, 2003 by Ranjeet Rain ([email protected])
'
' Feel free to use this Class in anyway you like excepting publishing its modified version
' without referencing this or without giving me the credit.
' Please leave this header intact, if you feel you should give me the credit of the work
' I have done. Thank you!
'
Public Class CODBCManager
Private CON As ODBCConnection
Private strDSN As String ' DSN Details
Private strUserID As String
Private strPwd As String
Private bUseUI As Variant ' Allow prompts and info display?
Private SN As NotesSession ' Domino DB management
Private DB As NotesDatabase
Private profileDoc As NotesDocument
Sub New(Byval AutoConnect As Variant, Byval UseUI As Variant, Byval SilentLogon As Variant)
'Sub New(Byval AutoConnect As Variant, Byval UseUI As Variant)
Set SN = New NotesSession
Set DB = SN.CurrentDatabase
Set profileDoc = DB.GetProfileDocument("Profile")
strDSN = profileDoc.DSN(0)
strUserID = profileDoc.ODBCUserID(0)
strPwd = profileDoc.ODBCPassword(0)
If UseUI Then
Me.bUseUI = True
Else
Me.bUseUI = False
End If
Set con = New ODBCConnection
With con
.SilentMode = SilentLogon
' .SilentMode = Not bUseUI
If AutoConnect Then
Me.Connect
End If
End With
End Sub
''''
''''
''''
Sub Delete
If Not con Is Nothing Then
If con.IsConnected Then
con.Disconnect
End If
Set con = Nothing
End If
End Sub
''''
''''
''''
Public Function GetDataSourceName As String
GetDataSourceName = strDSN
End Function
''''
''''
''''
Public Sub SetDataSourceName (Byval newDSN As String)
If Trim(newDSN) <> "" Then
strDSN = newDSN
End If
End Sub
''''
''''
''''
Public Function GetSilentMode As Variant
GetSilentMode = con.SilentMode
End Function
''''
''''
''''
Public Sub SetSilentMode (Byval newSM As Variant)
If newSM Then
con.SilentMode = True
Else
con.SilentMode = False
End If
End Sub
''''
''''
''''
Public Sub ListDataSources
Dim con As New ODBCConnection
Dim msg As String
Dim n%
Dim dsnList
dsnList = con.ListDataSources
For n% = Lbound(dsnList) To Ubound(dsnList)
msg = msg & dsnList(n%) & Chr(10)
Next
Messagebox msg,,"List of DSNs"
con.Disconnect
End Sub
''''
''''
''''
Public Function Connect As Variant
If bUseUI Then
On Error Goto ErrorConnect
Messagebox "Connecting using " + strDSN
con.ConnectTo strDSN, strUserID, strPwd
While Not con.IsConnected
StrDSN = Inputbox("ODBC data source name", "Connection attempt failed. Pls specify DSN Information to retry. Specify a blank string to abort", strDSN)
If strDSN = "" Then Exit Function
con.ConnectTo strDSN, strUserID, strPwd
Wend
Messagebox "Connected to " & con.DataSourceName,, " Connection successful!"
Else ' Silent logon
On Error Resume Next
con.ConnectTo strDSN, strUserID, strPwd
End If
Connect = (con.GetError = DBstsSUCCESS )
Exit Function
ErrorConnect:
Msgbox "Error connecting to database" + Chr(10) + con.GetExtendedErrorMessage,, con.GetError & " " & con.GetErrorMessage
Resume Next
End Function
''''
''''
''''
Public Function IsConnected As Variant
On Error Resume Next
IsConnected = con.IsConnected
End Function
''''
''''
''''
Public Function ActiveDSN As String
On Error Resume Next
If con.IsConnected Then
ActiveDSN = con.DataSourceName
Else
ActiveDSN = ""
End If
End Function
''''
''''
''''
Public Function GetRecordCount (Byval TableName As String) As Long
On Error Resume Next
GetRecordCount = 0
Dim rs As ODBCResultSet
Dim qry As ODBCQUery
Set rs = New ODBCResultSet
Set qry = New ODBCQuery
Set qry.Connection = con
qry.SQL = "SELECT COUNT(*) from " + TableName
If Not IsConnected Then
If Not Connect Then
Exit Function
End If
End If
With rs
.ReadOnly = True
Set .Query = qry
If Not .Execute Then
Messagebox .GetExtendedErrorMessage,, .GetErrorMessage
Exit Function
Else
.FirstRow
GetRecordCount = .GetValue(0)
End If
End With
End Function
''''
''''
''''
End Class
Por otro lado, si necesitas información de los iSeries recuerdo que ibm publicó 3 o 4 PDFs en su web en los redbooks que te los puedes descargar gratuitamente que explicaban como hacer lo que te he explicado bajo ese sistema.
Siento no poderte ayudar más :(
Ya me dirás si te funcionó
Muchisimas gracias por tu respuesta, sé que le pusistes esfuerzos en tratar de encontrar una solución para mi problema, lo malo es que el problema es más complejo de lo que parecía, de todas formas agradezco tu ayuda. :)

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas