on 01-02-2010 6:48 AM
Hi Experts,
I have used Java Web Dynpro program to fetch records from the backend. Following code helps me and fetches record. As per the customer reqirement, we have to fetch only top 10 records (Actual Cost) from the backend. So I have to modify the Java code. How I can do so? Please help.
wdContext.nodeGraphData().invalidate();
IPublicCostcnt.IGraphDataElement categoryElement;
for (int i = 0; i < wdContext.nodeItab_Final1().size(); i++) {
categoryElement = wdContext.createGraphDataElement();
categoryElement.setCostElement(""+ wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getDescription());
categoryElement.setActualCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getActual_Cost().toString());
categoryElement.setPlannedCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getPlan_Cost().toString());
wdContext.nodeGraphData().addElement(categoryElement);
}
Regards,
Gary
Hello,
If you are fetching your records from an RFC then you can write a select query to fetch the top 10 records.
Abhinav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Gary,
You can not write Select in your JAVA code. You can write it in your RFC from where you are getting records. I'm assuming you are fetching records from SAP R/3. Your ABAPer can write the code for you.
One way can be like
SELECT * FROM <TABLENAME> INTO ITAB.
where itab is internal table
SORT itab DESCENDING BY <fieldname>. where <fieldname is actual cost>
LOOP AT ITAB.
<GET FIRST 10 RECORDS>
ENDLOOP.
Hope this helps You can browse in ABAP forum for more details
Abhinav
Dear SDN Users,
This is how I resolved the issue.
1) Requested ABAPer to provide me sorted data. The data has been sorted in descending order of actual_cost.
2) After that I used following code. This resolved the issue.
if (wdContext.nodeItab_Final1().size()>10){
IPublicCostcnt.IGraphDataElement categoryElement;
for (int i = 0; i < 10; i++) {
categoryElement = wdContext.createGraphDataElement();
categoryElement.setCostElement(""+ wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getDescription());
categoryElement.setActualCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getActual_Cost().toString());
categoryElement.setPlannedCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getPlan_Cost().toString());
wdContext.nodeGraphData().addElement(categoryElement);
}
}
if (wdContext.nodeItab_Final1().size()<=10){
if (wdContext.nodeItab_Final1().size()>0){
IPublicCostcnt.IGraphDataElement categoryElement;
for (int i = 0; i < wdContext.nodeItab_Final1().size(); i++) {
categoryElement = wdContext.createGraphDataElement();
categoryElement.setCostElement(""+ wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getDescription());
categoryElement.setActualCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getActual_Cost().toString());
categoryElement.setPlannedCost(wdContext.nodeItab_Final1().getItab_Final1ElementAt(i).getPlan_Cost().toString());
wdContext.nodeGraphData().addElement(categoryElement);
}
}}
Regards,
Gary
User | Count |
---|---|
93 | |
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.