on 04-13-2006 8:45 AM
Hi,
i am struggling in testing lookup in User-Defined function. I have a good result of testing JCO using in User-Defined function, but when i executed in using JDBC, i got no error, however, no result turn on, just empty,
i am wondering if i use java.sql.* on imports line or not and wondering if url and driver should be used in User-Defined Function.
anyway, what i want to do, while mapping, i would like to get data from MSSQL DB in using User-Defined Function.
if you have a good solution instedad of this in order to do, please let me know
User-Defined Function
Description
Imports java.sql.*;
public String UOMLookupJDBC(String a,Container container){
//write your code here
String url = "jdbc:microsoft:sqlserver://10.100.100.1:1433;DatabaseName=TESTDB";
String user = "TESTUSER";
String pass = "TESTPASS";
Connection con = null;
Statement stmt = null;
ResultSet rset = null;
String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String expStr = "";
String sql = "";
try{
Class.forName( driver );
con = DriverManager.getConnection(url, user, pass );
stmt = con.createStatement();
sql = "SELECT CODE FROM Material03 WHERE MEINS = '"+ a +"'";
rset = stmt.executeQuery ( sql );
while(rset.next()){
expStr = rset.getString(1);
}
if(rset != null)
rset.close();
if(stmt != null )
stmt.close();
if(con != null )
con.close();
}catch(Exception e) {
e.getMessage();
e.printStackTrace();
}
return expStr;
Thanks
venjamin(YD)
Hi,
Isn't this a better way of doing it
/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
regards
Vijaya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Venjamin, Have you deployed the drivers of your MSSQL DB in XI. It is required that these drivers are in the classpath of your JVM.
If ur tsting in the Test tab of ur mesage mappign , u shud see the error stack trace rite !! let kow what it throws. u shud turn on "debug trace for this i beleive in ur mapping editor test tab.
Regards
Saravana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
MappingLookupAPI is the answer to your question.
Refer
http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/406642ea59c753e10000000a1550b0/frameset.htm
and the blog link specified by Vijaya for more details.
Regards,
Amol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.