on 08-27-2010 12:59 AM
Hi SDN gurus,
can somebody pls help me in the following scenario,
I have a value node with three attributes called date,time and value in it
in the runtime the value nodes element will look like the follwoing
date time value
============================
11/05/2010 23:37 black
12/05/2010 23:37 black
13/05/2010 23:37 black
14/05/2010 23:37 black
now my issue is I want to find out the latest date and display the rest of the element associated with that
like my output should be
14/05/2010 23:37 black
can somebody pls point some code snippet on how to find the latest day and fetch the value associated with it
Thanks in advance
RAD
Hi Rad,
Have a look on this page [IWDNode.sortElements|http://help.sap.com/javadocs/NW04s/current/wd/com/sap/tc/webdynpro/progmodel/api/IWDNode.html] at sortElements Method i think this is the right pointer for your problem.
Regards
Jeetendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If the data is not already sorted according to your criteria, sorting it will not necessarily speed anything up. This is because when sorting data every element needs to be looked at at least once anyways.
Essentially you need to simply loop through every element in the list and check if that element is the most recent. If it is save it to your element that displays on the screen; if not go on.
Here is the pseudocode (I assume you know enough to translate into Java and Web Dynpro Framework Java)
LOOP through every element
IF element is most recent then
SAVE to ANSWER ELEMENT
END IF
END LOOP
DISPLAY ANSWER ELEMENT
Actually sorting the data will make thing slower as you are thereby requiring every element to be put in its "rightful" place instead of just finding the "latest" date. This requires more calculation and more processor time. So the best way of doing this in terms of performance is by not sorting and just by processing each element in the collection.
Edited by: Ilan Pillemer on Aug 27, 2010 10:46 AM
Hi Illan,
thanks very much for the information,
for (int i=0;i<wdContext.nodeabcSort().size();i++){
String dv = wdContext.nodeabcSort().getabcSortElementAt(i).getDisplayValue();
//append the to the results
//set the Date and Time field
wdContext.nodeAudit_Trail().getabcSortElementAt(i).getUDate(i).);
wdContext.nodeAudit_Trail().getabcSortElementAt(i).getTime(i);
from here how to find out the recent items and save it to element, can you pls help me with the sniippet from here, appreciate your help
Thanks
RAD
Edited by: RAD on Aug 27, 2010 11:15 AM
long getTime()
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.
Use the getTime() method of the date and compare to current latest.
If the Dates are equal then compare the times themselves.
pseudocode
latestdate = first date in list
latesttime = first time in list
latestvalue = first value in list
Loop through list
if latest date is earlier than current element in list then update latest date, time and value
if latest date equals current element then compare times etc
End Loop
Edited by: Ilan Pillemer on Aug 27, 2010 11:56 AM
Hi Illan,
I am really sorry to say this but I am unable to transform your suedo code to wdJava as I am having minimal knowledge of java.
I am having a list of elements in one node
date time value
============================
11/05/2010 23:37 black
12/05/2010 23:37 white
13/05/2010 23:37 yellow
14/05/2010 23:37 redb
I have looped the whole node and have got the date and time from them. now I need to identify which is the latest date and time and need to get the complete element based on it..
based on the below code colud you or somebody please help me to complete this. I really appreciate your reply ...
for (int i=0;i<wdContext.nodeabcSort().size();i++){
String dv = wdContext.nodeabcSort().getabcSortElementAt(i).getDisplayValue();
//append the to the results
//set the Date and Time field
wdContext.nodeAudit_Trail().getabcSortElementAt(i).getUDate(i).);
wdContext.nodeAudit_Trail().getabcSortElementAt(i).getTime(i);
Hi,
Check if these links could be of help to you:
http://digiassn.blogspot.com/2007/07/java-sorting-dates.html
http://www.allinterview.com/showanswers/88422.html
http://santy.wikidot.com/sortnode
Regards,
Poojith MV
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.