Call a un CL desde SQL

07/10/2003 - 23:27 por Roberta Perfumo | Informe spam
Hola, debo hacer un CALL a un programa CL (Control
Language) de AS/400, pero desde un stored procedure.
El servidor AS ya está vinculado por Client Access y
actualmente hago consultas Select, Update y Delete.
Pero ahora debo (ayuda porfi!!) 'llamar' a un programa que
está en AS (hecho en CL).
Cómo puedo hacerlo ????

GRACIAS!!

Preguntas similare

Leer las respuestas

#1 Salvador Ramos
08/10/2003 - 12:31 | Informe spam
Hola:

Si tienes alguna forma de hacerlo desde la ventana de comandos, si que
podrás ejecutar esa misma llamada utilizando el procedimiento almacenado
sp_cmdshell.

Lo que debes averiguar, e informarnos es cómo puedes hacer esa llamada a la
CL desde el PC (qué alternativas hay, si las hay), y a partir de ahí podemos
ayudarte a adaptar tu solución para que eso lo gestione SQL Server.

Un saludo
Salvador Ramos
Murcia - España

No puedes conseguir software rápidamente disminuyendo su calidad.
En cambio, si que lo consigues aumentando la calidad.

www.helpdna.net (información sobre Windows DNA, SQL Server, .NET, ...)


Microsoft MVP SQL Server
MCP SQL Server
PASS Spanish Group (www.sqlpass.org)

"Roberta Perfumo" escribió en el mensaje
news:072401c38d19$cf76e400$
Hola, debo hacer un CALL a un programa CL (Control
Language) de AS/400, pero desde un stored procedure.
El servidor AS ya está vinculado por Client Access y
actualmente hago consultas Select, Update y Delete.
Pero ahora debo (ayuda porfi!!) 'llamar' a un programa que
está en AS (hecho en CL).
Cómo puedo hacerlo ????

GRACIAS!!
Respuesta Responder a este mensaje
#2 Adrian
10/10/2003 - 16:13 | Informe spam
Yo tuve que hacer algo parecido, y lo unico que pude encontrar es invocar a
un programa en Java, que genera un archivo txt como salida, y luego leo el
txt...
Podes empezar mirando http://www-1.ibm.com/servers/eserve...s/toolbox/
Ahora veo si puedo armarte un pequenio projecto con J++ y lo posteo.

Adrian

"Roberta Perfumo" wrote in message
news:072401c38d19$cf76e400$
Hola, debo hacer un CALL a un programa CL (Control
Language) de AS/400, pero desde un stored procedure.
El servidor AS ya está vinculado por Client Access y
actualmente hago consultas Select, Update y Delete.
Pero ahora debo (ayuda porfi!!) 'llamar' a un programa que
está en AS (hecho en CL).
Cómo puedo hacerlo ????

GRACIAS!!
Respuesta Responder a este mensaje
#3 Adrian
10/10/2003 - 16:18 | Informe spam
Aqui va el programa (class1.java)

/**
* This class can take a variable number of parameters on the command
* line. Program execution begins with the main() method. The class
* constructor is not invoked unless an object of type 'Class1'
* created in the main() method.
*/
import java.util.*;
import java.sql.*;
import com.ibm.as400.access.*;

public class Class1
{
/**
* The main entry point for the application.
*
* @param args Array of parameters passed to the application
* via the command line.
*/

public static void main (String[] args)
{
//Access the properties file
ResourceBundle rb = ResourceBundle.getBundle("CreditCheck");
String server = rb.getString("DBS_Host");
String user = rb.getString("DBS_User");
String psw = rb.getString("DBS_Password");
String lib = rb.getString("DBS_Library");
String cw_user = rb.getString("CW_USER");

try
{
String temp = getData(server, lib, user, psw);
System.out.println(temp);

}

catch(Throwable e)
{
}


}

public static String getData(String as400, String library, String userId,
String pws) throws Throwable
{

Connection sqlConnection = null;
String returnString = null;

//185 in length for input
StringBuffer buf = new StringBuffer();

//append Program Number sent from Exact
buf.append(formatString("EXACT", 10));
//append Doc Src sent from Exact
buf.append("RENT");
//append Document Amount sent from Exact
buf.append(formatNumber(new String("0")));

//append DBS Customer Number from CW Cross-Reference Table
buf.append(formatString("0000000", 7));

//append Currency code sent from Exact
buf.append(formatString("USD", 4));
//append menu indicator
buf.append("1");

//append doc number
buf.append(formatString("0009", 10));
//append doc date
buf.append("00000000");
//append salesman number
buf.append(" ");
//append document change amount
buf.append(formatNumber("0"));
//append process indicator for interactive
buf.append("1");
//append store and reporting level
buf.append(" ");
//Pad with spaces

while(buf.length() < 223)
buf.append(" ");

CallableStatement stmt = null;

try
{
DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
sqlConnection = DriverManager.getConnection("jdbc:as400://" + as400 + "/"
+ library + ";prompt=false", userId, pws);


stmt = sqlConnection.prepareCall("{CALL "+library+".FNC0300_SP(?)}");
stmt.setString(1, buf.toString());
stmt.registerOutParameter(1, 1);
stmt.execute();
returnString = stmt.getString(1);
stmt.close();

}
catch (SQLException e)
{

e.printStackTrace();
stmt.close();
stmt = null;
sqlConnection.close();
throw e;
}


try{stmt.close();} catch(Throwable z1){;}
try{sqlConnection.close();} catch(Throwable z2){;}


return returnString;
}


public static String formatString(String input, int desiredLength)
{
input = input.trim();
for(int i=input.length();i<desiredLength;i++)
input += ' ';
return input;
}


public static String formatNumber(String input)
{
double number = Double.valueOf(input.trim()).doubleValue();
//double number = Double.parseDouble(input);
int wholeValue = (int) number;
int decimalValue = (int) ((number-wholeValue)*100);
String wholeString = Integer.toString(wholeValue);
String decimalString = Integer.toString(decimalValue);
if(decimalString.length() == 1) //if the decimal is like .01
decimalString = '0' + decimalString;
StringBuffer retValue = new StringBuffer("00000000000000000"); //17
positions
retValue.setCharAt(15,decimalString.charAt(0));
retValue.setCharAt(16,decimalString.charAt(1));
int j;
for(int i=wholeString.length()-1;i>=0;i--)
retValue.setCharAt(j--,wholeString.charAt(i));
return retValue.toString();
}
}


"Adrian" wrote in message
news:
Yo tuve que hacer algo parecido, y lo unico que pude encontrar es invocar


a
un programa en Java, que genera un archivo txt como salida, y luego leo el
txt...
Podes empezar mirando


http://www-1.ibm.com/servers/eserve...s/toolbox/
Ahora veo si puedo armarte un pequenio projecto con J++ y lo posteo.

Adrian

"Roberta Perfumo" wrote in message
news:072401c38d19$cf76e400$
Hola, debo hacer un CALL a un programa CL (Control
Language) de AS/400, pero desde un stored procedure.
El servidor AS ya está vinculado por Client Access y
actualmente hago consultas Select, Update y Delete.
Pero ahora debo (ayuda porfi!!) 'llamar' a un programa que
está en AS (hecho en CL).
Cómo puedo hacerlo ????

GRACIAS!!


email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida