Skip to Content
avatar image
Former Member

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)

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 13, 2006 at 07:52 AM

    Hi,

    Isn't this a better way of doing it

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

    regards

    Vijaya

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 13, 2006 at 08:41 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 13, 2006 at 10:13 AM

    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

    Add comment
    10|10000 characters needed characters exceeded