Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

lookup jdbc in graphical mapping

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)

replied

Hi,

Isn't this a better way of doing it

/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

regards

Vijaya

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question