Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Sorting Date and Time

Former Member
0 Likes
605

Hi Everyone,

I have requirement to sort date and time fiields in an internal table.

The internal table looks something like this during runtime.

Line Objectclass UDATE UTIME OBJECTID CHANGENR CHANGE_IND

8 ISU_EEIN 20080305 144814 000000000111 0000035262 I

9 ISU_EEIN 20080305 145735 000000000112 0000035281 I

10 ISU_EEIN 20080305 151418 000000000113 0000035319 I

11 ISU_EEIN 20080305 154931 000000000114 0000035378 I

12 ISU_EEIN 20080305 155002 000000000115 0000035389 I

13 ISU_EEIN 20080305 162803 000000000116 0000035400 I

14 ISU_EEIN 20080306 095028 000000000113 0000035450 U

15 ISU_EEIN 20080306 123835 000000000117 0000035613 I

16 ISU_EEIN 20080306 133532 000000000118 0000035628 I

Now if you observe Line 10 and Line 14.

OBJECT ID has two entries. One with Change_Ind 'I' on 05.03.2008 and 'U' on 06.03.2008 ,

so here I need to have only ie... Line 14 for objectid 113 after sorting and deleting.

The current sort stmt which i am using is not solving the purpose,

Can you guys help me as how to achieve the result?

Awaiting your replies.

Regards,

Vinay

4 REPLIES 4
Read only

Former Member
0 Likes
576

hi,

after select statement

use sort itab by field1 field2 descending.

delete adjacent duplicates from table itab comparing field1.

regards ,

venkat.

Read only

0 Likes
576

Hi,

Did not achieve the desired,

Just for your information the internal table is as follows.

objuectclas udate utime objectid changenr change_ind

ISU_EEIN 20080305 144814 000000000111 0000035262 I

ISU_EEIN 20080305 145735 000000000112 0000035281 I

ISU_EEIN 20080305 151418 000000000113 0000035319 I

ISU_EEIN 20080305 154931 000000000114 0000035378 I

ISU_EEIN 20080305 155002 000000000115 0000035389 I

ISU_EEIN 20080305 162803 000000000116 0000035400 I

ISU_EEIN 20080306 095028 000000000113 0000035450 U

ISU_EEIN 20080306 123835 000000000117 0000035613 I

ISU_EEIN 20080306 133532 000000000118 0000035628 I

If i use the delete statements only 1 entry will remain.

Because i have to have only the latest record if it was updated,

since document 113 was updated on 06.03.2008. I should have only one record.

My result should be as follows.

ISU_EEIN 20080305 144814 000000000111 0000035262 I

ISU_EEIN 20080305 145735 000000000112 0000035281 I

ISU_EEIN 20080305 154931 000000000114 0000035378 I

ISU_EEIN 20080305 155002 000000000115 0000035389 I

ISU_EEIN 20080305 162803 000000000116 0000035400 I

ISU_EEIN 20080306 095028 000000000113 0000035450 U

ISU_EEIN 20080306 123835 000000000117 0000035613 I

ISU_EEIN 20080306 133532 000000000118 0000035628 I

Read only

Clemenss
Active Contributor
0 Likes
576

Hi Vinay,

hope I get you right: You want to reduce the internal table to the last operation on one object id.

Arrange the fields in itab structure like

Objectclass OBJECTID UDATE UTIME CHANGENR CHANGE_IND

then create a second table itab2 with the same structure.


sort itab.
loop at itab.
  at end of OBJECTID.
    append itab to itab2.
  endat.
endloop.

itab[] = itab2[].

Now you have what you want: Only one entry per Objectclass OBJECTID.

Regards,

Clemens

Read only

Former Member
0 Likes
576

Hi Clemens,

50% achieved, but I need to retain the values of the date and time and changenr. Once they are copied to itab2,

the values are set to '*' . Any pointer as to how to retain the values.