Skip to Content

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

problem with UDF


I need to do a select from database and know the number of register founded.

I've the following UDF:

String Query = " ";

Channel channel = null;

DataBaseAccessor accessor = null;

DataBaseResult resultSet = null;

String ret = "0";

// Build the Query String

Query = "Select * from SAP_INTERF_PROYECTOS where NUMDOC = '" + BELNR + "' and POSDOC = '" + POSEX +"'";


//Determine a channel, as created in the Configuration

channel = LookupService.getChannel("bs_arteche_tp_db_jdbc","cc_lookup_receiver");

//Get a system accessor for the channel. As the call is being made to an DB, an DatabaseAccessor is obtained.

accessor = LookupService.getDataBaseAccessor(channel);

//Execute Query and get the values in resultset

resultSet = accessor.executeQuery(Query);


//for(Iterator rows = resultSet.getRows();rows.hasNext();){

//ret = "1";


catch(Exception ex){






if (accessor != null)

ret = "1";


catch (Exception ex)




return ret;

The statment 'for' doesn't work, because it stays in an infinite loop.

The statment 'if' always return the same value, does not mind if exist register in the database

How can i verify if the database return register or not?

Thanks very much,


for(Iterator rows = resultSet.getRows();rows.hasNext();){
Map rowMap = (Map);
//do your logic here

use the above code.

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

0 View this answer in context

Helpful Answer

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