on 04-22-2009 9:24 AM
Hello,
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 +"'";
try{
//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){
}
finally
{
try
{
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,
Regards,
for(Iterator rows = resultSet.getRows();rows.hasNext();){
Map rowMap = (Map)rows.next();
//do your logic here
}
use the above code.
Ref: /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Shabarish,
I have done the same at /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler, but the UDF does't work fine.
When I test the message mapping, it returnrs the error "Cannot produce target element /ns0:MT_OFERTAS/STATEMENT/TABLENAME/ACCESS/ESTADO. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd". If I display the queue of the UDF it returns "SUPPRESS".
Do you know how can I solve this problem?
Thanks very much.
Hi,
If you interested in number of registers, please use count(*) instead of * which will return number of records which are satisfying the where condition. No need to use the loop and all just check the return value for greater than 1 and do the needful.
Hope this helps.
Thanks,
Kalpesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check the syntax with this [https://help.sap.com/javadocs/NW04/current/pi/com/sap/aii/mapping/lookup/LookupService.html]
and have a look here
[https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/5365aa90-0201-0010-5a9a-e231f40187db]
Hope it will help u.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.