on 06-26-2008 12:15 PM
hi all,
I am new to caf development in DC i have created Application Service in that apllication service i have used an External service BAPI_FLIGHT_GETLIST and in that i have taken input parameter as Airlineid and based on that i am retreving the flightlist details inorder to print the output i have taken a list and after i am setting that list to retvalue.it is working fine but the problem iam facing is only one record is populated in the entire table i.e(first row is repeating) so for that i have used the fallowing code.......
BAPI__FLIGHT__GETLIST inp;
BAPI__FLIGHT__GETLIST_dot_Response out;
BAPI__FLIGHT__GETLISTLocal extref = this.getBAPI__FLIGHT__GETLIST();
inp = new BAPI__FLIGHT__GETLIST();
inp.setAIRLINE(airline);
try
{
out = new BAPI__FLIGHT__GETLIST_dot_Response();
out = extref.BAPI__FLIGHT__GETLIST(inp);
com.sap.testapplicationservice.extsrv.bapi__flight__getlist.output.FLIGHT__LIST fl;
fl = new com.sap.testapplicationservice.extsrv.bapi__flight__getlist.output.FLIGHT__LIST();
fl = out.getFLIGHT__LIST();
AbstractCollection fl_col;
Iterator fl_it;
com.sap.testapplicationservice.extsrv.bapi__flight__getlist.output.BAPISFLDAT fl_struct;
fl_col = (AbstractCollection)fl.getItem();
fl_it = fl_col.iterator();
output res = new output();
int count = 0;
retValue = new ArrayList();
while (fl_it.next()!=null)
{
fl_struct = (com.sap.testapplicationservice.extsrv.bapi__flight__getlist.output.BAPISFLDAT)fl_it.next();
res.setFldate(fl_struct.getFLIGHTDATE());
res.setDepttime(fl_struct.getAIRLINE());
res.setArrtime(fl_struct.getCITYFROM());
retValue.add(count,res);
count++;
}
}
catch (Exception e) {
// TODO: handle exception
System.out.println(e.getStackTrace().toString());
throw new ServiceException(e);
}
so plz help me out in solving this issue....
Edited by: Armin Reichert on Jun 26, 2008 2:12 PM
Hi mahesh,
What Apoorva told is correct.
Try this code ...
while()
{
result re = new result();
res.set................
res.set................
retValue.add(count,re);
op = null;
}
Edited by: krishna vemulapalli on Jun 30, 2008 12:54 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Problem regarding repetition of same record generally occurs if object to be added is intiallized outside the loop.
Make sure that object which you are adding is initiallized inside the loop.
From the code, I can see output object res is intilized as "output res = new output();" outside the loop.
Regards,
Apurva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.